def register(): is_open = mdl.Setting.get(g.session, 'registration_open', default=False) if not is_open: return render_template('registration_closed.html') if request.method == 'POST': data = { "group_name": request.form.get('group_name'), "contact_name": request.form.get('contact_name'), "email": request.form.get('email'), "tel": request.form.get('tel'), "time": request.form.get('time'), "comments": request.form.get('comments'), } confirmation_link = url_for('confirm_registration', _external=True) try: loco.store_registration(g.session, data, confirmation_link) except ValueError as exc: return 'Error: ' + str(exc), 400 return render_template( 'notice.html', message=gettext( 'The registration has been recorded. However it is not yet ' 'activated. You will receive a confirmation e-mail any ' 'second now. You must click on the link in that e-mail to ' 'activate the registrtion! Once this step is done, the ' 'registration will be processed by the lost team, and you ' 'will receive another e-mail with the final confirmation once ' 'that is done.')) return render_template('register.html', stats=loco.stats())
def slot_editor(): groups = mdl.Group.all() slots = mdl.TimeSlot.all(current_app.localconf) groups_a = {} groups_b = {} for group in groups: try: if group.start_time and group.direction == mdl.DIR_A: groups_a[mdl.TimeSlot(group.start_time)] = group elif group.start_time and group.direction == mdl.DIR_B: groups_b[mdl.TimeSlot(group.start_time)] = group except ValueError as exc: current_app.logger.warning(exc) group.start_time = None groups_none = sorted([_ for _ in groups if not _.start_time or _.direction not in ( mdl.DIR_A, mdl.DIR_B)], key=lambda x: x.name) return render_template('slot_editor.html', slots=slots, dir_a=mdl.DIR_A, dir_b=mdl.DIR_B, groups_a=groups_a, groups_b=groups_b, groups_none=groups_none, stats=loco.stats(current_app.localconf))
def new(): is_open = mdl.Setting.get('registration_open', default=False) if not is_open and not current_user.has_role(mdl.Role.ADMIN): return render_template('registration_closed.html') if request.method == 'POST': data = { "group_name": request.form.get('group_name'), "contact_name": request.form.get('contact_name'), "email": request.form.get('email'), "tel": request.form.get('tel'), "time": request.form.get('time'), "comments": request.form.get('comments'), "user_id": current_user.id, "num_vegetarians": request.form.get('num_vegetarians'), "num_participants": request.form.get('num_participants'), } try: key = loco.store_registration( current_app.mailer, mdl.DB.session, data) except ValueError as exc: return 'Error: ' + str(exc), 400 # We'll auto-confirm the registration. This is not possible due to the # social login. However, this step could be removed altogether. Leaving # it in right now to avoid making too many changes all at once. loco.confirm_registration( current_app.mailer, key, activation_url=url_for('.accept', key=key, _external=True)) return render_template( 'notice.html', message=gettext( 'The registration has been recorded. You will receive an ' 'e-mail once the registartion has been successfully ' 'processed! You can see all your registered groups on <a ' 'href="{}">your profile</a>.').format(url_for('root.profile'))) return render_template('register.html', stats=loco.stats(current_app.localconf))
def manage(): if current_user.is_anonymous() or not current_user.admin: return "Access denied", 401 groups = loco.get_grps() slots = loco.slots() groups_a = {mdl.TimeSlot(_.start_time): _ for _ in groups if _.start_time and _.direction == mdl.DIR_A} groups_b = {mdl.TimeSlot(_.start_time): _ for _ in groups if _.start_time and _.direction == mdl.DIR_B} groups_none = sorted([_ for _ in groups if not _.start_time or _.direction not in ( mdl.DIR_A, mdl.DIR_B)], key=lambda x: x.name) return render_template('manage.html', slots=slots, dir_a=mdl.DIR_A, dir_b=mdl.DIR_B, groups_a=groups_a, groups_b=groups_b, groups_none=groups_none, stats=loco.stats())