Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
room = Room.get_one(args.pop('room_id'))
user_id = args.pop('user_id', None)
booked_for = User.get_one(user_id) if user_id else session.user
is_prebooking = args.pop('is_prebooking')
# Check that the booking is not longer than allowed
booking_limit_days = room.booking_limit_days or rb_settings.get('booking_limit')
if not self._validate_room_booking_limit(args['start_dt'], args['end_dt'], booking_limit_days):
msg = (_('Bookings for the room "{}" may not be longer than {} days')
.format(room.name, booking_limit_days))
return jsonify(success=False, msg=msg)
try:
resv = Reservation.create_from_data(room, dict(args, booked_for_user=booked_for), session.user,
prebook=is_prebooking)
db.session.flush()
except NoReportError as e:
db.session.rollback()
raise ExpectedError(unicode(e))
return jsonify(booking=reservation_schema.dump(resv).data)
def _process(self):
f = request.files['css_file']
self.event.stylesheet = to_unicode(f.read()).strip()
self.event.stylesheet_metadata = {
'hash': crc32(self.event.stylesheet),
'size': len(self.event.stylesheet),
'filename': secure_filename(f.filename, 'stylesheet.css')
}
db.session.flush()
flash(_('New CSS file saved. Do not forget to enable it ("Use custom CSS") after verifying that it is correct '
'using the preview.'), 'success')
logger.info('CSS file for %s uploaded by %s', self.event, session.user)
return jsonify_data(content=get_css_file_data(self.event))
log_fields = {}
for question in event.abstract_review_questions:
field_name = 'question_{}'.format(question.id)
rating = question.get_review_rating(review, allow_create=True)
old_value = rating.value
rating.value = questions_data[field_name]
if old_value != rating.value:
field_type = question.field_type
changes[field_name] = (question.field.get_friendly_value(old_value),
question.field.get_friendly_value(rating.value))
log_fields[field_name] = {
'title': question.title,
'type': field_type if field_type != 'rating' else 'number'
}
db.session.flush()
logger.info("Abstract review %s modified", review)
log_fields.update({
'proposed_action': 'Action',
'comment': 'Comment'
})
if review.proposed_action in {AbstractAction.mark_as_duplicate, AbstractAction.merge}:
log_fields['proposed_related_abstract'] = {
'title': 'Other abstract',
'type': 'string',
'convert': lambda change: [x.verbose_title if x else None for x in change]
}
elif review.proposed_action == AbstractAction.accept:
log_fields['proposed_contribution_type'] = {
'title': 'Contribution type',
'type': 'string',
'convert': lambda change: [x.name if x else None for x in change]
def update_event_protection(event, data):
assert set(data.viewkeys()) <= {'protection_mode', 'own_no_access_contact', 'access_key', 'visibility'}
changes = event.populate_from_dict(data)
db.session.flush()
signals.event.updated.send(event, changes=changes)
logger.info('Protection of event %r updated with %r by %r', event, data, session.user)
if changes:
log_fields = {'protection_mode': 'Protection mode',
'own_no_access_contact': 'No access contact',
'access_key': {'title': 'Access key', 'type': 'string'},
'visibility': {'title': 'Visibility', 'type': 'string',
'convert': lambda changes: [_format_visibility(event, x) for x in changes]}}
event.log(EventLogRealm.management, EventLogKind.change, 'Event', 'Protection updated', session.user,
data={'Changes': make_diff_log(changes, log_fields)})
def create_paper_revision(paper, submitter, files):
revision = PaperRevision(paper=paper, submitter=submitter)
for f in files:
filename = secure_filename(f.filename, 'paper')
content_type = mimetypes.guess_type(f.filename)[0] or f.mimetype or 'application/octet-stream'
pf = PaperFile(filename=filename, content_type=content_type, paper_revision=revision,
_contribution=paper.contribution)
pf.save(f.stream)
db.session.flush()
db.session.expire(revision._contribution, ['_paper_last_revision'])
notify_paper_revision_submission(revision)
logger.info('Paper revision %r submitted by %r', revision, session.user)
paper.event.log(EventLogRealm.reviewing, EventLogKind.positive, 'Papers',
"Paper revision {} submitted for contribution {} ({})"
.format(revision.id, paper.contribution.title, paper.contribution.friendly_id), session.user)
return revision
def delete_subcontribution(subcontrib):
subcontrib.is_deleted = True
db.session.flush()
signals.event.subcontribution_deleted.send(subcontrib)
logger.info('Subcontribution %s deleted by %s', subcontrib, session.user)
subcontrib.event.log(EventLogRealm.management, EventLogKind.negative, 'Subcontributions',
'Subcontribution "{}" has been deleted'.format(subcontrib.title), session.user)
def run(self, new_event, cloners, shared_data):
attrs = get_simple_column_attrs(db.m.EventReminder) - {'created_dt', 'scheduled_dt', 'is_sent'}
attrs |= {'creator_id'}
for old_reminder in self._find_reminders():
scheduled_dt = new_event.start_dt - old_reminder.event_start_delta
# Skip anything that's would have been sent on a past date.
# We ignore the time on purpose so cloning an event shortly before will
# still trigger a reminder that's just a few hours overdue.
if scheduled_dt.date() < now_utc().date():
logger.info('Not cloning reminder %s which would trigger at %s', old_reminder, scheduled_dt)
continue
reminder = db.m.EventReminder(**{attr: getattr(old_reminder, attr) for attr in attrs})
reminder.scheduled_dt = scheduled_dt
new_event.reminders.append(reminder)
db.session.flush()
logger.info('Added reminder during event cloning: %s', reminder)
def update_timetable_entry_object(entry, data):
"""Update the `object` of a timetable entry according to its type"""
from indico.modules.events.contributions.operations import update_contribution
obj = entry.object
if entry.type == TimetableEntryType.CONTRIBUTION:
update_contribution(obj, data)
elif entry.type == TimetableEntryType.SESSION_BLOCK:
update_session_block(obj, data)
elif entry.type == TimetableEntryType.BREAK:
obj.populate_from_dict(data)
db.session.flush()
'organizer_info', 'additional_info', 'contact_title', 'contact_emails',
'contact_phones', 'start_dt_override', 'end_dt_override'}
old_person_links = event.person_links[:]
if (update_timetable or event.type == EventType.lecture) and 'start_dt' in data:
# Lectures have no exposed timetable so if we have any timetable entries
# (e.g. because the event had a different type before) we always update them
# silently.
event.move_start_dt(data.pop('start_dt'))
changes = event.populate_from_dict(data)
# Person links are partially updated when the WTForms field is processed,
# we we don't have proper change tracking there in some cases
changes.pop('person_link_data', None)
visible_person_link_changes = event.person_links != old_person_links
if visible_person_link_changes or 'person_link_data' in data:
changes['person_links'] = (old_person_links, event.person_links)
db.session.flush()
signals.event.updated.send(event, changes=changes)
logger.info('Event %r updated with %r by %r', event, data, session.user)
_log_event_update(event, changes, visible_person_link_changes=visible_person_link_changes)
registration.data.append(data_entry)
for attr, value in form_item.field_impl.process_form_data(registration, value).iteritems():
setattr(data_entry, attr, value)
if form_item.type == RegistrationFormItemType.field_pd and form_item.personal_data_type.column:
setattr(registration, form_item.personal_data_type.column, value)
if invitation is None:
# Associate invitation based on email in case the user did not use the link
invitation = (RegistrationInvitation
.find(email=data['email'], registration_id=None)
.with_parent(regform)
.first())
if invitation:
invitation.state = InvitationState.accepted
invitation.registration = registration
registration.sync_state(_skip_moderation=skip_moderation)
db.session.flush()
signals.event.registration_created.send(registration, management=management)
notify_registration_creation(registration, notify_user)
logger.info('New registration %s by %s', registration, user)
regform.event.log(EventLogRealm.management if management else EventLogRealm.participants,
EventLogKind.positive, 'Registration',
'New registration: {}'.format(registration.full_name), user, data={'Email': registration.email})
return registration