Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def init(self):
super(PiwikPlugin, self).init()
self.connect(signals.event_management_sidemenu, self.add_sidemenu_item)
self.connect(signals.material_downloaded, self.track_download)
self.template_hook('html-head', self.inject_tracking)
@signals.menu.items.connect_via('event-management-sidemenu')
def _extend_event_management_menu(sender, event, **kwargs):
if not event.can_manage(session.user):
return
return SideMenuItem('features', 'Features', url_for('event_features.index', event), section='advanced')
continue
data.seek(0)
# XXX: mpo is basically JPEG and JPEGs from some cameras are (wrongfully) detected as mpo
if image_type == 'mpo':
image_type = 'jpeg'
elif image_type not in {'jpeg', 'gif', 'png'}:
flash(_("The image '{name}' has an invalid type ({type}); only JPG, GIF and PNG are allowed.")
.format(name=f.filename, type=image_type), 'error')
continue
content_type = 'image/' + image_type
image = ImageFile(event=self.event, filename=filename, content_type=content_type)
image.save(data)
num += 1
db.session.flush()
logger.info('Image %s uploaded by %s', image, session.user)
signals.event_management.image_created.send(image, user=session.user)
flash(ngettext("The image has been uploaded", "{count} images have been uploaded", num)
.format(count=len(files)), 'success')
return jsonify_data(image_list=_render_image_list(self.event))
@signals.users.registered.connect
def _on_user_register(user, **kwargs):
"""Remove newly-added users from pending lists"""
pending_submitter = PendingSubmittersHolder().getPendingByEmail(user.email)
if pending_submitter:
principal = pending_submitter[0]
mgr = principal.getConference().getPendingQueuesMgr()
logger.info('Removed pending submitter {0} from {1}'.format(user, principal.getConference()))
mgr.removePendingSubmitter(principal)
def _process(self):
# material pages should not be cached, since protection can change
self._disableCaching()
if len(self._material.getResourceList()) == 1:
res = self._material.getResourceList()[0]
signals.event.material_downloaded.send(self._conf, resource=res)
if isinstance(res, conference.Link):
url = res.getURL()
if url.find(".wmv") != -1:
urlwmv = urlHandlers.UHVideoWmvAccess().getURL(res)
self._redirect( urlwmv )
elif url.find(".flv") != -1 or url.find(".f4v") != -1 or url.find("rtmp://") != -1:
urlflash = urlHandlers.UHVideoFlashAccess().getURL(res)
self._redirect(urlflash)
else:
self._redirect(res.getURL())
elif isinstance(res, conference.LocalFile):
self._redirect(urlHandlers.UHFileAccess.getURL( res ))
else:
return self._processManyMaterials()
@signals.menu.items.connect_via('admin-sidemenu')
def _extend_admin_menu(sender, **kwargs):
if session.user.is_admin:
return SideMenuItem('celery', _("Tasks"), url_for('celery.index'), 20, icon='time')
@signals.import_tasks.connect
def _import_tasks(sender, **kwargs):
import indico.modules.events.surveys.tasks
@signals.event_management.get_cloners.connect
def _get_vc_cloner(sender, **kwargs):
from indico.modules.vc.clone import VCCloner
return VCCloner
signal_rv = values_from_signal(signals.rh.before_process.send(type(self), rh=self),
single_value=True, as_list=True)
if signal_rv and len(signal_rv) != 1:
raise Exception('More than one signal handler returned custom RH result')
elif signal_rv:
return signal_rv[0]
if config.PROFILE:
result = [None]
profile_path = os.path.join(config.TEMP_DIR, '{}-{}.prof'.format(type(self).__name__, time.time()))
cProfile.runctx('result[0] = self._process()', globals(), locals(), profile_path)
rv = result[0]
else:
rv = self._process()
signal_rv = values_from_signal(signals.rh.process.send(type(self), rh=self, result=rv),
single_value=True, as_list=True)
if signal_rv and len(signal_rv) != 1:
raise Exception('More than one signal handler returned new RH result')
elif signal_rv:
return signal_rv[0]
else:
return rv
def _process_POST(self):
regform = self.event.participation_regform
set_feature_enabled(self.event, 'registration', True)
if not regform:
regform = RegistrationForm(event=self.event, title="Participants", is_participation=True,
currency=payment_settings.get('currency'))
create_personal_data_fields(regform)
db.session.add(regform)
db.session.flush()
signals.event.registration_form_created.send(regform)
self.event.log(EventLogRealm.management, EventLogKind.positive, 'Registration',
'Registration form "{}" has been created'.format(regform.title), session.user)
return redirect(url_for('event_registration.manage_regform', regform))