Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.process_principal(event, entries, submitter, 'Submitter', 'magenta!', roles={'submit'})
# email-based (pending) submitters
pqm = getattr(event, '_pendingQueuesMgr', None)
if pqm is not None:
emails = set(getattr(pqm, '_pendingConfSubmitters', []))
self.process_emails(event, entries, emails, 'Submitter', 'magenta', roles={'submit'})
db.session.add_all(entries.itervalues())
# assign creators
if creator_updates:
self.print_step('saving event creators')
stmt = (Event.__table__.update()
.where(Event.id == db.bindparam('event_id'))
.values(creator_id=db.bindparam('creator_id')))
db.session.execute(stmt, creator_updates)
updated = Event.find(Event.creator_id == None).update({Event.creator_id: self.janitor.id}) # noqa
db.session.commit()
self.print_success('Set the janitor user {} for {} events'.format(self.janitor, updated), always=True)
def _process(self):
form = self.backend.form(obj=FormDefaults(name=self.backend.title))
if form.validate_on_submit():
data = form.data
name = data.pop('name')
agent = LiveSyncAgent(name=name, backend_name=self.backend_name, settings=data)
db.session.add(agent)
flash(_('Agent added'), 'success')
flash(_("Don't forget to run the initial export!"), 'highlight')
return jsonify_data(flash=False)
return jsonify_template('edit_agent.html', render_plugin_template, form=form, backend=self.backend, edit=False)
raise HTTPAPIError('Guest access to this resource is forbidden.', 403)
method_name = self._getMethodName()
func = getattr(self, method_name, None)
extra_func = getattr(self, method_name + '_extra', None)
if not func:
raise NotImplementedError(method_name)
if not self.COMMIT:
is_response, resultList, complete, extra = self._perform(user, func, extra_func)
db.session.rollback()
else:
try:
init_email_queue()
is_response, resultList, complete, extra = self._perform(user, func, extra_func)
db.session.commit()
flush_email_queue()
except Exception:
db.session.rollback()
raise
if is_response:
return resultList
return resultList, extra, complete, self.SERIALIZER_TYPE_MAP
def migrate_news(self):
self.print_step('migrating news')
old_items = sorted(self.zodb_root['modules']['news']._newsItems, key=attrgetter('_creationDate'))
for old_item in old_items:
n = NewsItem(title=self._sanitize_title(old_item._title), content=convert_to_unicode(old_item._content),
created_dt=old_item._creationDate)
db.session.add(n)
db.session.flush()
self.print_success(n.title)
db.session.commit()
def processed_records(self, records):
"""Executed after successfully uploading a batch of records from the queue.
:param records: a list of queue entries
"""
for record in records:
self.logger.debug('Marking as processed: %s', record)
record.processed = True
db.session.commit()
ReservationOccurrence.is_valid,
ReservationOccurrence.start_dt >= datetime.now(),
~ReservationOccurrence.notification_sent,
_make_occurrence_date_filter(ReservationOccurrence.start_dt, defaults, room_columns))
.order_by(Reservation.booked_for_id, ReservationOccurrence.start_dt, Room.id)
.options(contains_eager('reservation').contains_eager('room'))
.all())
for user, user_occurrences in groupby(occurrences, key=attrgetter('reservation.booked_for_user')):
user_occurrences = list(user_occurrences)
if debug:
_print_occurrences(user, user_occurrences)
else:
_notify_occurrences(user, user_occurrences)
if not debug:
db.session.commit()
def create_blocking(room_ids, allowed, start_date, end_date, reason, created_by):
blocking = Blocking()
blocking.start_date = start_date
blocking.end_date = end_date
blocking.created_by_user = created_by
_populate_blocking(blocking, room_ids, allowed, reason)
db.session.add(blocking)
db.session.flush()
return blocking
'vidyo_id': booking._roomId,
'url': booking._url,
'owner': ('User', int(booking._owner.id)),
'owner_identity': booking._ownerVidyoAccount,
'auto_mute': booking_params.get('autoMute', True)
}
vc_room.modified_dt = booking._modificationDate
vc_room.created_dt = booking._creationDate
db.session.add(vc_room)
vidyo_ext = VidyoExtension(vc_room=vc_room, extension=int(booking._extension),
owned_by_id=int(booking._owner.id))
db.session.add(vidyo_ext)
db.session.flush()
self.vc_rooms_by_extension[vidyo_ext.extension] = vc_room
print cformat('%{green}+++%{reset} %{cyan}{}%{reset} [%{yellow!}{}%{reset}]').format(
vc_room.name, booking._roomId)
return vc_room
def add_edit_log(self, edit_log):
self.edit_logs.append(edit_log)
db.session.flush()
def run(self, new_event, cloners, shared_data):
with db.session.no_autoflush:
self._clone_location(new_event)
db.session.flush()