def getVars(self): wvars = WTemplated.getVars(self) wvars['standalone'] = self._standalone room = wvars['room'] wvars['attrs'] = {attr.attribute.name: attr for attr in room.attributes if not attr.attribute.is_hidden or rb_is_admin(session.user)} wvars['owner_name'] = room.owner.full_name wvars['bookable_hours'] = room.bookable_hours.all() wvars['nonbookable_periods'] = room.nonbookable_periods.all() # URLs wvars['stats_url'] = UH.UHRoomBookingRoomStats.getURL(room) wvars['delete_room_url'] = url_for('rooms_admin.delete_room', room) wvars['modify_room_url'] = url_for('rooms_admin.modify_room', room) if not self._standalone: wvars['conference'] = self._rh._conf room_mapper = RoomMapperHolder().match({'placeName': self._rh._location.name}, exact=True) if room_mapper: wvars['show_on_map'] = room_mapper[0].getMapURL(self._rh._room.name) else: wvars['show_on_map'] = UH.UHRoomBookingMapOfRooms.getURL(roomID=self._rh._room.id) return wvars
def _process(self): if self._getUser() is not None and self._getUser().isRegisteredInConf(self._conf): if ( not self._conf.getRegistrationForm().inRegistrationPeriod() and not self._conf.getRegistrationForm().inModificationPeriod() ): flash(_("Your modification could not be recorded since the modification period is over."), "error") return redirect(url_for("event.confRegistrationFormDisplay", self._conf)) else: rp = self._getUser().getRegistrantById(self._conf.getId()) # Check if the email matches an existing user params = self._getRequestParams() email = self._regForm.getPersonalData().getValueFromParams(params, "email") or "" user = get_user_by_email(email) if user: if not session.user: flash( _( "The provided email ({email}) is linked to an Indico account. Please sign in with it " "first." ).format(email=email), "error", ) return redirect(url_for("event.confRegistrationFormDisplay-modify", self._conf)) elif session.user != user: flash( _( "The provided email ({email}) is linked to another Indico account. Please sign in with " "it first." ).format(email=email), "error", ) return redirect(url_for("event.confRegistrationFormDisplay-modify", self._conf)) # check if the email is being changed by another one that already exists if email != rp.getEmail() and self._conf.hasRegistrantByEmail(email): raise FormValuesError( _('There is already a user with the email "{email}". ' "Please choose another one.").format( email or "--no email--" ) ) rp.setValues(self._getRequestParams(), self._getUser()) log_msg = u"User modified his registration data: {}" self._conf.log( EventLogRealm.participants, EventLogKind.positive, u"Registration", log_msg.format(to_unicode(rp.getFullName(title=False, firstNameFirst=True))), session.user, data={u"Indico user": u"{} ({})".format(user.full_name, user.id) if user else u"None"}, ) notify_registration_modification(self._conf, rp) flash(_(u"Your registration has been modified successfully."), "success") if rp.doPay(): self._redirect(urlHandlers.UHConfRegistrationFormCreationDone.getURL(rp)) else: self._redirect(urlHandlers.UHConfRegistrationForm.getURL(self._conf)) else: self._redirect(urlHandlers.UHConfRegistrationForm.getURL(self._conf))
def notify_payment_confirmation(registrant, amount): event = registrant.getConference() reg_form = registrant.getRegistrationForm() from_address = reg_form.getNotificationSender() currency = payment_event_settings.get(event, 'currency') # Send email to organizers notification = reg_form.getNotification() to_list = notification.getToList() cc_list = notification.getCCList() if to_list or cc_list: reg_page = url_for('event_mgmt.confModifRegistrants-modification', registrant, _external=True, _secure=True) tpl = get_template_module('payment/emails/payment_confirmation_organizers.txt', event=event, registrant=registrant, amount=amount, currency=currency, reg_page=reg_page) yield make_email(to_list, cc_list, from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body()) # Send email to the registrant if reg_form.isSendPaidEmail(): success_email_msg = payment_event_settings.get(event, 'success_email') params = {} if not registrant.getAvatar(): params = {'registrantId': registrant.getId(), 'authkey': registrant.getRandomId()} reg_page = url_for('event.confRegistrationFormDisplay', event, _external=True, _secure=True, **params) tpl = get_template_module('payment/emails/payment_confirmation_registrant.txt', event=event, registrant=registrant, amount=amount, currency=currency, success_email_msg=success_email_msg, reg_page=reg_page) yield make_email(registrant.getEmail(), from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body())
def _sidemenu_items(sender, event, **kwargs): # Some legacy handling of menu items # Once those parts are modularized, we will be able to include them # conditionally from their respective modules. can_modify = event.can_manage(session.user, allow_key=True) rb_active = Config.getInstance().getIsRoomBookingActive() cfa_enabled = event.as_legacy.hasEnabledSection("cfa") event_type = event.as_legacy.getType() is_lecture = event_type == "simple_event" is_conference = event_type == "conference" paper_review = event.as_legacy.getConfPaperReview() is_review_staff = paper_review.isInReviewingTeam(session.avatar) is_review_manager = paper_review.isPaperReviewManager(session.avatar) if can_modify: yield SideMenuItem( "general", _("General settings"), url_for("event_mgmt.conferenceModification", event), 90, icon="settings" ) if not is_lecture: yield SideMenuItem( "timetable", _("Timetable"), url_for("event_mgmt.confModifSchedule", event), 80, icon="calendar" ) if rb_active: yield SideMenuItem( "room_booking", _("Room Booking"), url_for("event_mgmt.rooms_booking_list", event), 50, icon="location" ) if is_conference: if can_modify: yield SideMenuItem( "program", _("Programme"), url_for("event_mgmt.confModifProgram", event), section="organization" ) if can_modify and cfa_enabled: yield SideMenuItem( "abstracts", _("Abstracts"), url_for("event_mgmt.confModifCFA", event), section="organization" ) if can_modify or is_review_manager: yield SideMenuItem( "contributions", _("Contributions"), url_for("event_mgmt.confModifContribList", event), section="organization", ) if can_modify or is_review_staff: yield SideMenuItem( "paper_reviewing", _("Paper Reviewing"), url_for("event_mgmt.confModifReviewing-access", event), section="organization", ) if can_modify: if not is_lecture: yield SideMenuItem( "lists", _("Lists"), url_for("event_mgmt.confModifListings-allSpeakers", event), section="reports" ) yield SideMenuItem("utilities", _("Utilities"), url_for("event_mgmt.confModifTools", event), section="advanced") yield SideMenuItem("protection", _("Protection"), url_for("event_mgmt.confModifAC", event), 60, icon="shield")
def _sidemenu_items(sender, category, **kwargs): yield SideMenuItem('content', _('Content'), url_for('categories.manage_content', category), 100, icon='eye') yield SideMenuItem('settings', _('Settings'), url_for('categories.manage_settings', category), 90, icon='settings') yield SideMenuItem('protection', _('Protection'), url_for('categories.manage_protection', category), 70, icon='shield')
def _createTabCtrl(self): self._tabCtrl = TabControl() if session.user.is_admin: self._subTabRoomBooking = self._tabCtrl.newTab( 'booking', _('Room Booking'), url_for('rooms_admin.settings') ) self._subTabMain = self._subTabRoomBooking.newSubTab( 'settings', _('Settings'), url_for('rooms_admin.settings') ) else: self._subTabRoomBooking = self._tabCtrl.newTab( 'booking', _('Room Booking'), urlHandlers.UHRoomBookingAdmin.getURL() ) self._subTabConfig = self._subTabRoomBooking.newSubTab( 'management', _('Management'), urlHandlers.UHRoomBookingAdmin.getURL() ) self._subTabRoomMappers = self._tabCtrl.newTab( 'mappers', _('Room Mappers'), urlHandlers.UHRoomMappers.getURL() )
def notify_registration_modification(event, registrant): reg_form = registrant.getRegistrationForm() from_address = reg_form.getNotificationSender() reg_details = _get_reg_details(reg_form, registrant) # Send email to organizers notification = reg_form.getNotification() to_list = notification.getToList() cc_list = notification.getCCList() if to_list or cc_list: reg_page = url_for('event_mgmt.confModifRegistrants-modification', registrant, _external=True, _secure=True) tpl = get_template_module('events/registration/emails/registration_modification_organizers.html', event=event, registrant=registrant, reg_page=reg_page, reg_details=reg_details) yield make_email(to_list, cc_list, from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body(), html=True) # Send email to the registrant if reg_form.isSendRegEmail(): needs_to_pay = registrant.doPay() and payment_event_settings.get(event, 'enabled') params = {} if not registrant.getAvatar(): params = {'registrantId': registrant.getId(), 'authkey': registrant.getRandomId()} reg_page = url_for('event.confRegistrationFormDisplay', event, _external=True, _secure=True, **params) tpl = get_template_module('events/registration/emails/registration_modification_registrant.html', event=event, registrant=registrant, payment_enabled=payment_event_settings.get(event, 'enabled'), reg_page=reg_page, needs_to_pay=needs_to_pay, reg_details=reg_details) yield make_email(registrant.getEmail(), from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body(), html=True)
def url(self): # explicit _external=False since offline site creation forces # _external=True if not specified and we want to be able to mangle # the generated urls into something suitable as filenames if self.is_user_link: return self.link_url elif self.is_internal_link: data = self.default_data if data.static_site and isinstance(data.static_site, basestring) and ContextManager.get('offlineMode'): return data.static_site kwargs = {} if self.name == 'timetable': from indico.modules.events. layout import layout_settings if layout_settings.get(self.event, 'timetable_by_room'): kwargs['ttLyt'] = 'room' if layout_settings.get(self.event, 'timetable_detailed'): start_date = self.event.getSchedule().getAdjustedStartDate() kwargs['_anchor'] = start_date.strftime('%Y%m%d.detailed') return url_for(data.endpoint, self.event, _external=False, **kwargs) elif self.is_plugin_link: from indico.core.plugins import url_for_plugin return url_for_plugin(self.default_data.endpoint, self.event, _external=False) elif self.is_page: return url_for('event_pages.page_display', self.event, page_id=self.page_id, slug=slugify(self.title), _external=False) else: return None
def _process(self): if session.user: return redirect(url_for('misc.index')) handler = MultipassRegistrationHandler(self) if self.identity_info else LocalRegistrationHandler(self) verified_email = self._get_verified_email() if verified_email is not None: handler.email_verified(verified_email) flash(_('You have successfully validated your email address and can now proceeed with the registration.'), 'success') # Check whether there is already an existing pending user with this e-mail pending = User.find_first(User.all_emails.contains(verified_email), is_pending=True) if pending: session['register_pending_user'] = pending.id flash(_("There is already some information in Indico that concerns you. " "We are going to link it automatically."), 'info') return redirect(url_for('.register', provider=self.provider_name)) form = handler.create_form() if form.validate_on_submit(): if handler.must_verify_email: return self._send_confirmation(form.email.data) else: return self._create_user(form, handler) return WPAuth.render_template('register.html', form=form, local=(not self.identity_info), must_verify_email=handler.must_verify_email, widget_attrs=handler.widget_attrs, email_sent=session.pop('register_verification_email_sent', False))
def _processIfActive(self): if not self._registrant: return redirect(url_for('event.confRegistrationFormDisplay-display', self._conf)) if not self._regForm.inModificationPeriod(): flash(_("The modification period is over."), 'error') return redirect(url_for('event.confRegistrationFormDisplay', self._conf)) return registrationForm.WPRegistrationFormModify(self, self._conf).display()
def process_form(self): form = self.manager_form if self.request.state == RequestState.withdrawn: return elif not form.validate_on_submit(): # very unlikely, unless the definition uses a custom form return if 'action_accept' in form and form.action_accept.data: action = 'accept' elif 'action_reject' in form and form.action_reject.data: action = 'reject' elif 'action_save' in form and form.action_save.data: action = 'save' else: # This happens when the request was already processed, e.g. in another # tab or if you simply click the submit button twice. No nee to fail; # just don't do anything. return redirect(url_for('.event_requests_details', self.request)) if action == 'accept': self.definition.accept(self.request, self.manager_form.data, session.user) flash(_('You have accepted this request.'), 'info') elif action == 'reject': self.definition.reject(self.request, self.manager_form.data, session.user) flash(_('You have rejected this request.'), 'info') elif action == 'save': self.definition.manager_save(self.request, self.manager_form.data) flash(_("You have updated the request (only management-specific data)."), 'info') return redirect(url_for('.event_requests_details', self.request))
def _process(self): if session.user: return redirect(url_for('misc.index')) handler = MultipassRegistrationHandler(self) if self.identity_info else LocalRegistrationHandler(self) verified_email = self._get_verified_email() if verified_email is not None: handler.email_verified(verified_email) flash(_('You have successfully validated your email address and can now proceeed with the registration.'), 'success') return redirect(url_for('.register', provider=self.provider_name)) form = handler.create_form() # Check for pending users if we have verified emails pending = None if not handler.must_verify_email: pending = User.find_first(~User.is_deleted, User.is_pending, User.all_emails.contains(db.func.any(list(handler.get_all_emails(form))))) if form.validate_on_submit(): if handler.must_verify_email: return self._send_confirmation(form.email.data) else: return self._create_user(form, handler, pending) elif not form.is_submitted() and pending: # If we have a pending user, populate empty fields with data from that user for field in form: value = getattr(pending, field.short_name, '') if value and not field.data: field.data = value if pending: flash(_("There is already some information in Indico that concerns you. " "We are going to link it automatically."), 'info') return WPAuth.render_template('register.html', form=form, local=(not self.identity_info), must_verify_email=handler.must_verify_email, widget_attrs=handler.widget_attrs, email_sent=session.pop('register_verification_email_sent', False))
def _process_POST(self): if User.has_rows(): return redirect(url_for('misc.index')) setup_form = BootstrapForm(request.form) if not setup_form.validate(): flash(_("Some fields are invalid. Please, correct them and submit the form again."), 'error') return redirect(url_for('bootstrap.index')) # Creating new user user = User() user.first_name = to_unicode(setup_form.first_name.data) user.last_name = to_unicode(setup_form.last_name.data) user.affiliation = to_unicode(setup_form.affiliation.data) user.email = to_unicode(setup_form.email.data) user.is_admin = True identity = Identity(provider='indico', identifier=setup_form.username.data, password=setup_form.password.data) user.identities.add(identity) db.session.add(user) db.session.flush() user.settings.set('timezone', Config.getInstance().getDefaultTimezone()) user.settings.set('lang', to_unicode(setup_form.language.data)) login_user(user, identity) full_name = user.full_name # needed after the session closes transaction.commit() # Configuring server's settings minfo = HelperMaKaCInfo.getMaKaCInfoInstance() minfo.setOrganisation(setup_form.affiliation.data) minfo.setLang(setup_form.language.data) message = get_template_module('bootstrap/flash_messages.html').bootstrap_success(name=full_name) flash(Markup(message), 'success') # Activate instance tracking if setup_form.enable_tracking.data: contact_name = setup_form.contact_name.data contact_email = setup_form.contact_email.data try: register_instance(contact_name, contact_email) except (HTTPError, ValueError) as err: message = get_template_module('bootstrap/flash_messages.html').community_error(err=err) category = 'error' except Timeout: message = get_template_module('bootstrap/flash_messages.html').community_timeout() category = 'error' except RequestException as exc: message = get_template_module('bootstrap/flash_messages.html').community_exception(exc=exc) category = 'error' else: message = get_template_module('bootstrap/flash_messages.html').community_success() category = 'success' flash(Markup(message), category) return redirect(url_for('misc.index'))
def _process(self): # QRCode (Version 6 with error correction L can contain up to 106 bytes) qr = qrcode.QRCode( version=6, error_correction=qrcode.constants.ERROR_CORRECT_M, box_size=4, border=1 ) checkin_app = OAuthApplication.find_one(system_app_type=SystemAppType.checkin) qr_data = { "event_id": self.event.id, "title": self.event.title, "date": self.event.start_dt.isoformat(), "version": 1, "server": { "base_url": config.BASE_URL, "consumer_key": checkin_app.client_id, "auth_url": url_for('oauth.oauth_authorize', _external=True), "token_url": url_for('oauth.oauth_token', _external=True) } } json_qr_data = json.dumps(qr_data) qr.add_data(json_qr_data) qr.make(fit=True) qr_img = qr.make_image() output = BytesIO() qr_img.save(output) output.seek(0) return send_file('config.png', output, 'image/png')
def render_breadcrumbs(*titles, **kwargs): """Render the breadcrumb navigation :param titles: A list of plain text titles. If present, these will simply create a unlinked trail of breadcrumbs. A 'Home' element is inserted automatically. :param event: Generate the event/category breadcrumb trail starting at the specified event. :param category: Generate the category breadcrumb trail starting at the specified category. :param management: Whether the event/category breadcrumb trail should link to management pages. """ category = kwargs.get('category', None) event = kwargs.get('event', None) management = kwargs.get('management', False) assert bool(titles) + bool(event) + bool(category) == 1 if not category and not event: items = [(_('Home'), url_for_index())] + [(x, None) for x in titles] else: items = [] if event: items.append((event.title, url_for('event_management.settings', event) if management else event.url)) category = event.category for cat in category.chain_query[::-1]: items.append((cat.title, url_for('categories.manage_content', cat) if management else cat.url)) items.reverse() return render_template('breadcrumbs.html', items=items, management=management)
def serialize_session_block_entry(self, entry, load_children=True): block = entry.session_block data = {} if not load_children: entries = defaultdict(dict) else: entries = {self._get_entry_key(x): self.serialize_timetable_entry(x) for x in entry.children} data.update(self._get_entry_data(entry)) data.update(self._get_color_data(block.session)) data.update(self._get_location_data(block)) data.update({'entryType': 'Session', 'sessionSlotId': block.id, 'sessionId': block.session_id, 'sessionCode': block.session.code, 'title': block.session.title, 'slotTitle': block.title, 'attachments': self._get_attachment_data(block.session), 'code': block.session.code, 'contribDuration': block.session.default_contribution_duration.seconds / 60, 'conveners': [self._get_person_data(x) for x in block.person_links], 'description': block.session.description, 'duration': block.duration.seconds / 60, 'isPoster': block.session.is_poster, 'entries': entries, 'pdf': url_for('sessions.export_session_timetable', block.session), 'url': url_for('sessions.display_session', block.session), 'friendlyId': block.session.friendly_id}) return data
def _process(self): if not self.plugin.can_manage_vc_rooms(session.user, self.event_new): flash( _("You are not allowed to refresh {plugin_name} rooms for this event.").format( plugin_name=self.plugin.friendly_name ), "error", ) return redirect(url_for(".manage_vc_rooms", self.event_new)) Logger.get("modules.vc").info("Refreshing VC room {} from event {}".format(self.vc_room, self._conf)) try: self.plugin.refresh_room(self.vc_room, self.event_new) except VCRoomNotFoundError as err: Logger.get("modules.vc").warning("VC room '{}' not found. Setting it as deleted.".format(self.vc_room)) self.vc_room.status = VCRoomStatus.deleted flash(err.message, "error") return redirect(url_for(".manage_vc_rooms", self.event_new)) flash( _("{plugin_name} room '{room.name}' refreshed").format( plugin_name=self.plugin.friendly_name, room=self.vc_room ), "success", ) return redirect(url_for(".manage_vc_rooms", self.event_new))
def process_form(self): form = self.form if not form.validate_on_submit(): return if not self.request or not self.request.can_be_modified: req = Request(event=self.event, definition=self.definition, created_by_user=session.user) new = True else: req = self.request new = False try: with db.session.no_autoflush: self.definition.send(req, form.data) except RequestModuleError: self.commit = False flash_msg = _('There was a problem sending your request ({0}). Please contact support.') flash(flash_msg.format(self.definition.title), 'error') else: if new: flash_msg = (_("Your request ({0}) has been accepted.") if req.state == RequestState.accepted else _("Your request ({0}) has been sent.")) else: flash_msg = _("Your request ({0}) has been modified.") flash(flash_msg.format(self.definition.title), 'success') if self.is_manager: return redirect(url_for('.event_requests_details', self.event, type=self.definition.name)) else: return redirect(url_for('.event_requests', self.event))
def getVars(self): wvars = WTemplated.getVars(self) wvars["standalone"] = self._standalone room = wvars["room"] wvars["attrs"] = { attr.attribute.name: attr for attr in room.attributes if not attr.attribute.is_hidden or rb_is_admin(session.user) } wvars["owner_name"] = room.owner.full_name wvars["bookable_hours"] = room.bookable_hours.all() wvars["nonbookable_periods"] = room.nonbookable_periods.all() # URLs wvars["stats_url"] = UH.UHRoomBookingRoomStats.getURL(room) wvars["delete_room_url"] = url_for("rooms_admin.delete_room", room) wvars["modify_room_url"] = url_for("rooms_admin.modify_room", room) if not self._standalone: wvars["conference"] = self._rh._conf wvars["show_on_map"] = room.map_url if room.map_url else url_for("rooms.roomBooking-mapOfRooms", room) return wvars
def serialize_contribution_entry(self, entry): from indico.modules.events.api import SerializerBase block = entry.parent.session_block if entry.parent else None contribution = entry.contribution data = {} data.update(self._get_entry_data(entry)) if contribution.session: data.update(self._get_color_data(contribution.session)) data.update(self._get_location_data(contribution)) data.update({'entryType': 'Contribution', '_type': 'ContribSchEntry', '_fossil': 'contribSchEntryDisplay', 'contributionId': contribution.id, 'attachments': self._get_attachment_data(contribution), 'description': contribution.description, 'duration': contribution.duration.seconds / 60, 'pdf': url_for('contributions.export_pdf', entry.contribution), 'presenters': map(self._get_person_data, sorted([p for p in contribution.person_links if p.is_speaker], key=lambda x: (x.author_type != AuthorType.primary, x.author_type != AuthorType.secondary, x.display_order_key))), 'sessionCode': block.session.code if block else None, 'sessionId': block.session_id if block else None, 'sessionSlotId': block.id if block else None, 'sessionSlotEntryId': entry.parent.id if entry.parent else None, 'title': contribution.title, 'url': url_for('contributions.display_contribution', contribution), 'friendlyId': contribution.friendly_id, 'references': map(SerializerBase.serialize_reference, contribution.references), 'board_number': contribution.board_number}) return data
def _process(self): canManageRegistration = self._conf.canManageRegistration(self._getUser()) if not canManageRegistration and not self._regForm.isActivated(): p = registrationForm.WPRegFormInactive(self, self._conf) return p.display() params = self._getRequestParams() email = self._regForm.getPersonalData().getValueFromParams(params, 'email') if email is None: raise FormValuesError(_("An email address has to be set in order to make the registration in the event.")) elif not validMail(email, False): raise FormValuesError(_("The given email address is not valid.")) # Check if the email matches an existing user user = get_user_by_email(email) avatar = user.as_avatar if user else None # Check if the user can register if not canManageRegistration: # normal user registering. Managers can. if self._conf.getRegistrationForm().isFull(): self._redirect(urlHandlers.UHConfRegistrationFormDisplay.getURL(self._conf)) return elif not self._conf.getRegistrationForm().inRegistrationPeriod(): flash(_("Your registration couldn't be recorded."), 'error') return redirect(url_for('event.confRegistrationFormDisplay', self._conf)) if user is None: if self._conf.hasRegistrantByEmail(email): raise FormValuesError("There is already a user with the email \"%s\". Please choose another one" % email) else: if avatar.isRegisteredInConf(self._conf) or self._conf.hasRegistrantByEmail(email): if canManageRegistration: raise FormValuesError("There is already a user with the email \"%s\". Please choose another one" % email) else: raise FormValuesError("You have already registered with the email address \"%s\". If you need to modify your registration, please contact the managers of the conference." % email) rp = registration.Registrant() self._conf.addRegistrant(rp, avatar) rp.setValues(self._getRequestParams(), avatar) if avatar is not None: rp.setAvatar(avatar) notify_registration_confirmation(self._conf, rp) self._conf.log(EventLogRealm.management if self.is_manager else EventLogRealm.participants, EventLogKind.positive, u'Registration', u'User registered: {}'.format(to_unicode(rp.getFullName(title=False, firstNameFirst=True))), session.user, data={u'Indico user': u'{} ({})'.format(user.full_name, user.id) if user else u'None'}) if self.is_manager: self._redirect(RHRegistrantListModif._uh.getURL(self._conf)) else: params = {} if not rp.doPay() or not payment_event_settings.get(self._conf, 'enabled'): flash(_(u"Your registration has been recorded successfully."), 'success') if not session.user or session.user != user: params.update(rp.getLocator(), **{'authkey': rp.getRandomId()}) else: params.update(self._conf.getLocator()) return redirect(url_for('event.confRegistrationFormDisplay', **params))
def _process(self): session_key = "reglist_config_{}".format(self.regform.id) configuration = {"regform_id": self.regform.id, "data": session.get(session_key)} url = url_for(".manage_reglist", self.regform, _external=True) if configuration["data"]: link = ReportLink.create(self.event_new, REPORT_LINK_TYPE, configuration) url = url_for(".manage_reglist", self.regform, config=link.uuid, _external=True) return jsonify(url=url)
def _extend_event_management_menu_layout(sender, event, **kwargs): if not event.can_manage(session.user, allow_key=True): return if event.as_legacy.getType() == 'conference': yield SideMenuItem('layout', _('Layout'), url_for('event_layout.index', event), section='customization') yield SideMenuItem('menu', _('Menu'), url_for('event_layout.menu', event), section='customization') if event.has_feature('images'): yield SideMenuItem('images', _('Images'), url_for('event_layout.images', event), section='customization')
def _extend_event_management_menu_layout(sender, event, **kwargs): if not event.can_manage(session.user): return yield SideMenuItem('layout', _('Layout'), url_for('event_layout.index', event), section='customization') if event.type_ == EventType.conference: yield SideMenuItem('menu', _('Menu'), url_for('event_layout.menu', event), section='customization') if event.has_feature('images'): yield SideMenuItem('images', _('Images'), url_for('event_layout.images', event), section='customization')
def _process(self): if self._room.has_live_reservations(): flash(_(u'Cannot delete room with live bookings'), 'error') return redirect(url_for('rooms.roomBooking-roomDetails', self._room)) else: db.session.delete(self._room) flash(_(u'Room deleted'), 'success') return redirect(url_for('rooms_admin.roomBooking-adminLocation', self._room.location))
def _extend_event_management_menu_layout(sender, event, **kwargs): if not event.can_manage(session.user): return if event.as_legacy.getType() == "conference": yield SideMenuItem("layout", _("Layout"), url_for("event_layout.index", event), section="customization") yield SideMenuItem("menu", _("Menu"), url_for("event_layout.menu", event), section="customization") if event.has_feature("images"): yield SideMenuItem("images", _("Images"), url_for("event_layout.images", event), section="customization")
def _sidemenu_items(sender, category, **kwargs): yield SideMenuItem('view', _('View category'), url_for('category.categoryDisplay', category), 100, icon='eye') yield SideMenuItem('general', _('General Settings'), url_for('category_mgmt.categoryModification', category), 90, icon='settings') yield SideMenuItem('protection', _('Protection'), url_for('category_mgmt.categoryAC', category), 70, icon='shield') yield SideMenuItem('tools', _('Tools'), url_for('category_mgmt.categoryTools', category), 60, icon='wrench')
def _createTabCtrl(self): self._tabCtrl = TabControl() self._tabExistBookings = self._tabCtrl.newTab('existing', 'Existing Bookings', url_for('event_mgmt.rooms_booking_list', self._conf)) self._tabNewBooking = self._tabCtrl.newTab('new', 'New Booking', url_for('event_mgmt.rooms_choose_event', self._conf)) if not Reservation.find(event_id=self._conf.getId()).count(): self._tabExistBookings.setEnabled(False) self._setActiveTab()
def _createTabCtrl(self): self._tabCtrl = TabControl() self._tabExistBookings = self._tabCtrl.newTab('existing', 'Existing Bookings', url_for('event_mgmt.rooms_booking_list', self.event)) self._tabNewBooking = self._tabCtrl.newTab('new', 'New Booking', url_for('event_mgmt.rooms_choose_event', self.event)) if not Reservation.query.with_parent(self.event).has_rows(): self._tabExistBookings.setEnabled(False) self._setActiveTab()
def _process(self): if not self.plugin.can_manage_vc_rooms(session.user, self.event_new): flash( _("You are not allowed to modify {} rooms for this event.").format(self.plugin.friendly_name), "error" ) return redirect(url_for(".manage_vc_rooms", self.event_new)) form = self.plugin.create_form( self.event_new, existing_vc_room=self.vc_room, existing_event_vc_room=self.event_vc_room ) if form.validate_on_submit(): self.plugin.update_data_vc_room(self.vc_room, form.data) event_vc_room = process_vc_room_association( self.plugin, self.event_new, self.vc_room, form, event_vc_room=self.event_vc_room, allow_same_room=True ) if not event_vc_room: return redirect(url_for(".manage_vc_rooms", self.event_new)) self.vc_room.modified_dt = now_utc() try: self.plugin.update_room(self.vc_room, self.event_new) except VCRoomNotFoundError as err: Logger.get("modules.vc").warning("VC room {} not found. Setting it as deleted.".format(self.vc_room)) self.vc_room.status = VCRoomStatus.deleted flash(err.message, "error") return redirect(url_for(".manage_vc_rooms", self.event_new)) except VCRoomError as err: if err.field is None: raise field = getattr(form, err.field) field.errors.append(err.message) transaction.abort() else: # TODO # notify_modified(self.vc_room, self.event_new, session.user) flash( _("{plugin_name} room '{room.name}' updated").format( plugin_name=self.plugin.friendly_name, room=self.vc_room ), "success", ) return jsonify_data(flash=False) form_html = self.plugin.render_form( plugin=self.plugin, event=self.event_new, form=form, existing_vc_room=self.vc_room, skip_fields=form.skip_fields | {"name"}, ) return jsonify(html=form_html, js=_pop_injected_js())
def _process(self): self.application.reset_client_secret() logger.info("Client secret of %s reset by %s", self.application, session.user) flash(_("New client secret generated for the application"), 'success') return redirect(url_for('.app_details', self.application))
def url_for_logout(next_url=None): return url_for('auth.logout', next=next_url)
def booking_url(self): if self.id is None: return None return url_for('rooms.room_book', self)
def large_photo_url(self): if self.id is None: return None return url_for('rooms.photo', self, size='large')
def small_photo_url(self): if self.id is None: return None return url_for('rooms.photo', self, size='small')
def _process(self): self._conf.setClosed(False) flash(_('The event is now unlocked.'), 'success') return redirect( url_for('event_mgmt.conferenceModification', self._conf))
def _get_url(self, uh_or_endpoint, target, **params): if isinstance(uh_or_endpoint, basestring): return url_for(uh_or_endpoint, target, **params) else: return str(uh_or_endpoint.getStaticURL(target, **params))
def success_url(self): return url_for('.display_regform', self.registration.locator.registrant)
def get_ajax_url(self, **url_args): kwargs = request.view_args | request.args.to_dict(False) kwargs.update(url_args) kwargs['__wtf_ajax'] = self.id return url_for(request.endpoint, **kwargs)
def external_url(self): return url_for('events.display', self, _external=True)
def _sidemenu_items(sender, **kwargs): if session.user.is_admin: yield SideMenuItem('announcement', _('Announcement'), url_for('announcement.manage'), section='homepage')
def url(self): return url_for('categories.display', self)
def _process(self): db.session.delete(self.application) logger.info("Application %s deleted by %s", self.application, session.user) flash(_("Application deleted successfully"), 'success') return redirect(url_for('.apps'))
def _category_sidemenu_items(sender, category, **kwargs): if category.can_manage(session.user): return SideMenuItem('designer', _('Posters/Badges'), url_for('designer.template_list', category), icon='palette')
def _sidemenu_items(sender, **kwargs): if session.user.is_admin: yield SideMenuItem('settings', _('General Settings'), url_for('core.settings'), 100, icon='settings')
def _event_sidemenu_items(sender, event, **kwargs): if event.can_manage(session.user): return SideMenuItem('designer', _('Posters/Badges'), url_for('designer.template_list', event), section='customization')
def _process_POST(self): self._conf.setClosed(True) flash(_('The event is now locked.'), 'success') return jsonify_data(url=url_for('event_mgmt.conferenceModification', self._conf), flash=False)
def effective_icon_url(self): """Get the HTTP URL of the icon (possibly inherited).""" data = self.effective_icon_data return url_for('categories.display_icon', category_id=data['source_id'], slug=data['metadata']['hash'])
def logo_url(self): """Get the HTTP URL of the logo.""" return url_for('categories.display_logo', self, slug=self.logo_metadata['hash'])
def _process(self): db.session.delete(self.group) flash( _("The group '{name}' has been deleted.").format( name=self.group.name), 'success') return redirect(url_for('.groups'))
def details_url(self): if self.id is None: return None return url_for('rooms.roomBooking-roomDetails', self)
def _process_POST(self): if User.query.filter_by(is_system=False).has_rows(): return redirect(url_for_index()) setup_form = BootstrapForm(request.form) if not setup_form.validate(): flash( _("Some fields are invalid. Please, correct them and submit the form again." ), 'error') return redirect(url_for('bootstrap.index')) # Creating new user user = User() user.first_name = setup_form.first_name.data user.last_name = setup_form.last_name.data user.affiliation = setup_form.affiliation.data user.email = setup_form.email.data user.is_admin = True identity = Identity(provider='indico', identifier=setup_form.username.data, password=setup_form.password.data) user.identities.add(identity) db.session.add(user) db.session.flush() user.settings.set('timezone', config.DEFAULT_TIMEZONE) user.settings.set('lang', session.lang or config.DEFAULT_LOCALE) login_user(user, identity) full_name = user.full_name # needed after the session closes db.session.commit() # Configuring server's settings core_settings.set('site_organization', setup_form.affiliation.data) message = get_template_module( 'bootstrap/flash_messages.html').bootstrap_success(name=full_name) flash(Markup(message), 'success') # Activate instance tracking if setup_form.enable_tracking.data: contact_name = setup_form.contact_name.data contact_email = setup_form.contact_email.data try: register_instance(contact_name, contact_email) except (HTTPError, ValueError) as err: message = get_template_module('bootstrap/flash_messages.html' ).community_error(err=str(err)) category = 'error' except Timeout: message = get_template_module( 'bootstrap/flash_messages.html').community_timeout() category = 'error' except RequestException as exc: message = get_template_module( 'bootstrap/flash_messages.html').community_exception( err=str(exc)) category = 'error' else: message = get_template_module( 'bootstrap/flash_messages.html').community_success() category = 'success' flash(Markup(message), category) return redirect(url_for_index())
def _extend_event_management_menu(sender, event, **kwargs): if not event.can_manage(session.user) or not EditingFeature.is_allowed_for_event(event): return return SideMenuItem('editing', _('Editing'), url_for('event_editing.dashboard', event), section='organization')
def _process_args(self): self.agent = LiveSyncAgent.get_one(request.view_args['agent_id']) if self.agent.backend is None: flash(_('Cannot edit an agent that is not loaded'), 'error') return redirect(url_for('plugins.details', plugin='livesync'))
def _checkParams(self, params): RHRegistrationFormRegistrationBase._checkParams(self, params) InvitationMixin._checkParams(self) if self.invitation and self.invitation.state == InvitationState.accepted and self.invitation.registration: return redirect(url_for('.display_regform', self.invitation.registration.locator.registrant))
def url_for_login(next_url=None): if next_url == '/': next_url = None return url_for('auth.login', next=next_url, _external=True)
def url(self): return url_for('events.display', self)
def icon_url(self): """Get the HTTP URL of the icon.""" return url_for('categories.display_icon', self, slug=self.icon_metadata['hash'])
def logo_url(self): return url_for('event_images.logo_display', self, slug=self.logo_metadata['hash'])
def _get_event_management_url(event, **kwargs): if event.cfp.is_manager(session.user): return url_for('papers.management', event)