Ejemplo n.º 1
0
    def _process(self):
        defaults = FormDefaults(get_default_values(MenuEntry))
        entry_type = request.args['type']

        if entry_type == MenuEntryType.separator.name:
            entry = MenuEntry(event=self.event, type=MenuEntryType.separator)
            db.session.add(entry)
            db.session.flush()
            return jsonify_data(flash=False, entry=_render_menu_entry(entry))

        elif entry_type == MenuEntryType.user_link.name:
            form_cls = MenuLinkForm
        elif entry_type == MenuEntryType.page.name:
            form_cls = MenuPageForm
        else:
            raise BadRequest

        form = form_cls(obj=defaults)
        if form.validate_on_submit():
            entry = MenuEntry(event=self.event, type=MenuEntryType[entry_type])
            form.populate_obj(entry, skip={'html'})

            if entry.is_page:
                page = EventPage(html=form.html.data)
                self.event.custom_pages.append(page)
                entry.page = page

            db.session.add(entry)
            db.session.flush()
            return jsonify_data(entry=_render_menu_entry(entry))
        return jsonify_form(form)
Ejemplo n.º 2
0
 def _process(self):
     form = PaperTemplateForm()
     if form.validate_on_submit():
         template = create_paper_template(self.event, form.data)
         flash(_('Paper template "{}" added.').format(template.name), 'success')
         return _render_teplate_list(self.event)
     return jsonify_form(form, form_header_kwargs={'action': request.relative_url})
Ejemplo n.º 3
0
    def _process(self):
        item = self.entry.object
        entry_dt = self.entry.start_dt.astimezone(self.event_new.tzinfo)
        form = BaseEntryForm(obj=FormDefaults(item, time=entry_dt.time()), day=entry_dt.date(),
                             event=self.event_new, entry=self.entry,
                             session_block=self.entry.parent.object if self.entry.parent else None)
        data = form.data
        shift_later = data.pop('shift_later')
        updated_entries = []

        if form.validate_on_submit():
            with track_time_changes(auto_extend=True, user=session.user) as changes:
                if shift_later:
                    new_end_dt = form.start_dt.data + form.duration.data
                    shift = new_end_dt - self.entry.end_dt
                    updated_entries += shift_following_entries(self.entry, shift, session_=self.session)
                if self.entry.contribution:
                    update_timetable_entry(self.entry, {'start_dt': form.start_dt.data})
                    update_contribution(item, {'duration': form.duration.data})
                elif self.entry.break_:
                    update_break_entry(item, data)
                elif self.entry.session_block:
                    update_session_block(item, data)
            notifications = get_time_changes_notifications(changes, tzinfo=self.event_new.tzinfo, entry=self.entry)
            updated_entries.append(item.timetable_entry)
            return jsonify_data(entries=[serialize_entry_update(entry) for entry in updated_entries], flash=False,
                                shift_later=shift_later, notifications=notifications)
        self.commit = False
        return jsonify_form(form, back_button=False, disabled_until_change=True)
Ejemplo n.º 4
0
 def _process(self):
     form = ReferenceTypeForm()
     if form.validate_on_submit():
         reference_type = create_reference_type(form.data)
         flash(_("External ID type '{}' created successfully").format(reference_type.name), 'success')
         return jsonify_data(html=_render_reference_type_list())
     return jsonify_form(form)
Ejemplo n.º 5
0
 def _process(self):
     form = ReferenceTypeForm(obj=FormDefaults(self.reference_type), reference_type=self.reference_type)
     if form.validate_on_submit():
         update_reference_type(self.reference_type, form.data)
         flash(_("External ID type '{}' successfully updated").format(self.reference_type.name), 'success')
         return jsonify_data(html=_render_reference_type_list())
     return jsonify_form(form)
Ejemplo n.º 6
0
 def _process(self):
     form = EventKeywordsForm(obj=self.event_new)
     if form.validate_on_submit():
         update_event(self.event_new, form.data)
         flash(_('The keywords for the event have been updated'))
         return jsonify_data(html=Markup('<br>').join(self.event_new.keywords))
     return jsonify_form(form)
Ejemplo n.º 7
0
 def _process(self):
     description_settings = abstracts_settings.get(self.event, 'description_settings')
     form = AbstractContentSettingsForm(obj=FormDefaults(description_settings))
     if form.validate_on_submit():
         abstracts_settings.set(self.event, 'description_settings', form.data)
         return jsonify_data(flash=False)
     return jsonify_form(form)
Ejemplo n.º 8
0
 def _process(self):
     form = TrackForm(event=self.event, obj=self.track)
     if form.validate_on_submit():
         update_track(self.track, form.data)
         flash(_('Track "{}" has been modified.').format(self.track.title), 'success')
         return jsonify_data(html=_render_track_list(self.event))
     return jsonify_form(form)
Ejemplo n.º 9
0
 def _process(self):
     form = ContributionStartDateForm(obj=FormDefaults(start_dt=self.contrib.start_dt), contrib=self.contrib)
     if form.validate_on_submit():
         with track_time_changes():
             update_timetable_entry(self.contrib.timetable_entry, {'start_dt': form.start_dt.data})
         return jsonify_data(new_value=format_datetime(self.contrib.start_dt, 'short'))
     return jsonify_form(form, back_button=False, disabled_until_change=True)
Ejemplo n.º 10
0
 def _process(self):
     defaults = FormDefaults(obj=self.question, **self.question.field_data)
     form = self.question.field.create_config_form(obj=defaults)
     if form.validate_on_submit():
         update_reviewing_question(self.question, form)
         return jsonify_data(flash=False)
     return jsonify_form(form, fields=getattr(form, '_order', None))
Ejemplo n.º 11
0
 def _process(self):
     form = ContributionDurationForm(obj=FormDefaults(self.contrib), contrib=self.contrib)
     if form.validate_on_submit():
         with track_time_changes():
             update_contribution(self.contrib, {'duration': form.duration.data})
         return jsonify_data(new_value=format_human_timedelta(self.contrib.duration))
     return jsonify_form(form, back_button=False, disabled_until_change=True)
Ejemplo n.º 12
0
 def _process(self):
     form = CreateCategoryForm()
     if form.validate_on_submit():
         new_category = create_category(self.category, form.data)
         flash(_('Category "{}" has been created.').format(new_category.title), 'success')
         return jsonify_data(flash=False, redirect=url_for('.manage_settings', new_category))
     return jsonify_form(form)
Ejemplo n.º 13
0
 def _process(self):
     form = ContributionDefaultDurationForm(duration=contribution_settings.get(self.event, 'default_duration'))
     if form.validate_on_submit():
         contribution_settings.set(self.event, 'default_duration', form.duration.data)
         flash(_("Default contribution duration was changed successfully"))
         return jsonify_data()
     return jsonify_form(form)
Ejemplo n.º 14
0
 def _process(self):
     form = IPNetworkGroupForm(obj=self.network_group)
     if form.validate_on_submit():
         form.populate_obj(self.network_group)
         logger.info('Network group %s edited by %s', self.network_group, session.user)
         return jsonify_data(flash=False)
     return jsonify_form(form)
Ejemplo n.º 15
0
 def _process(self):
     form = EventPersonForm(obj=FormDefaults(self.person, skip_attrs={'title'}, title=self.person._title))
     if form.validate_on_submit():
         update_person(self.person, form.data)
         person_data = self.get_persons()[self.person.email or self.person.id]
         tpl = get_template_module('events/persons/management/_person_list_row.html')
         return jsonify_data(html=tpl.render_person_row(person_data))
     return jsonify_form(form)
Ejemplo n.º 16
0
 def _process(self):
     form = PaperTemplateForm(template=self.template, obj=FormDefaults(self.template, template=self.template))
     if form.validate_on_submit():
         old_name = self.template.name
         update_paper_template(self.template, form.data)
         flash(_('Paper template "{}" updated.').format(old_name), 'success')
         return _render_teplate_list(self.event)
     return jsonify_form(form, form_header_kwargs={'action': request.relative_url})
Ejemplo n.º 17
0
 def _process(self):
     form = ReportErrorForm(email=(session.user.email if session.user else ''))
     if form.validate_on_submit():
         self._send_email(form.email.data, form.comment.data)
         if config.SENTRY_DSN and self.error_data['sentry_event_id'] is not None:
             self._send_sentry(form.email.data, form.comment.data)
         return jsonify_data(flash=False)
     return jsonify_form(form)
Ejemplo n.º 18
0
 def _process(self):
     reg_managers = {p.principal for p in self.event.acl_entries
                     if p.has_management_role('registration', explicit=True)}
     form = RegistrationManagersForm(obj=FormDefaults(managers=reg_managers))
     if form.validate_on_submit():
         update_object_principals(self.event, form.managers.data, role='registration')
         return jsonify_data(flash=False)
     return jsonify_form(form)
Ejemplo n.º 19
0
 def _process(self):
     form = TrackForm(event=self.event)
     if form.validate_on_submit():
         track = create_track(self.event, form.data)
         flash(_('Track "{}" has been created.').format(track.title), 'success')
         return jsonify_data(html=_render_track_list(self.event), new_track_id=track.id,
                             tracks=[{'id': t.id, 'title': t.title} for t in self.event.tracks])
     return jsonify_form(form)
Ejemplo n.º 20
0
 def _process(self):
     form = EventPersonLinkForm(obj=self.event_new, event=self.event_new, event_type=self.event_new.type)
     if form.validate_on_submit():
         update_event(self.event_new, form.data)
         tpl = get_template_module('events/management/_event_person_links.html')
         return jsonify_data(html=tpl.render_event_person_links(self.event_new.type, self.event_new.person_links))
     self.commit = False
     return jsonify_form(form)
Ejemplo n.º 21
0
 def _process(self):
     form = self.field_cls.create_config_form()
     if form.validate_on_submit():
         new_question = create_reviewing_question(self.event, AbstractReviewQuestion, self.field_cls, form)
         self.event.abstract_review_questions.append(new_question)
         logger.info("Abstract reviewing question %r created by %r", new_question, session.user)
         return jsonify_data(flash=False)
     return jsonify_form(form, fields=getattr(form, '_order', None))
Ejemplo n.º 22
0
 def _process(self):
     form = NewsSettingsForm(obj=FormDefaults(**news_settings.get_all()))
     if form.validate_on_submit():
         news_settings.set_multi(form.data)
         get_recent_news.clear_cached()
         flash(_('Settings have been saved'), 'success')
         return jsonify_data()
     return jsonify_form(form)
Ejemplo n.º 23
0
 def _process(self):
     form = EventLocationForm(obj=self.event_new)
     if form.validate_on_submit():
         update_event(self.event_new, form.data)
         flash(_('The location for the event has been updated'))
         tpl = get_template_module('events/management/_event_location.html')
         return jsonify_data(html=tpl.render_event_location_info(self.event_new.location_data))
     return jsonify_form(form)
Ejemplo n.º 24
0
 def _process(self):
     form = BOASettingsForm(obj=FormDefaults(**boa_settings.get_all(self.event)))
     if form.validate_on_submit():
         boa_settings.set_multi(self.event, form.data)
         clear_boa_cache(self.event)
         flash(_('Book of Abstract settings have been saved'), 'success')
         return jsonify_data()
     return jsonify_form(form)
Ejemplo n.º 25
0
 def _process(self):
     form = EventReferencesForm(obj=FormDefaults(references=self.event_new.references))
     if form.validate_on_submit():
         create_event_references(event=self.event_new, data=form.data)
         flash(_('External IDs saved'), 'success')
         tpl = get_template_module('events/management/_reference_list.html')
         return jsonify_data(html=tpl.render_event_references_list(self.event_new.references))
     return jsonify_form(form)
Ejemplo n.º 26
0
 def _process(self):
     tpl = get_template_module('events/surveys/emails/survey_link_email.html', event=self.event)
     form = InvitationForm(body=tpl.get_html_body(), subject=tpl.get_subject(), event=self.event)
     if form.validate_on_submit():
         self._send_emails(form, form.recipients.data)
         num = len(form.recipients.data)
         flash(ngettext('Your email has been sent.', '{} emails have been sent.', num).format(num))
         return jsonify_data(flash=True)
     return jsonify_form(form)
Ejemplo n.º 27
0
 def _process(self):
     current_event_settings = event_settings.get_all(self.event_new)
     defaults = FormDefaults(current_event_settings, **settings.get_all())
     form = EventSettingsForm(prefix="payment-", obj=defaults)
     if form.validate_on_submit():
         event_settings.set_multi(self.event_new, form.data)
         flash(_("Settings saved"), "success")
         return jsonify_data()
     return jsonify_form(form)
Ejemplo n.º 28
0
 def _process(self):
     form = self.field_cls.create_config_form()
     if form.validate_on_submit():
         new_question = create_reviewing_question(self.event, PaperReviewQuestion, self.field_cls, form,
                                                  {'type': PaperReviewType[self.review_type]})
         self.event.paper_review_questions.append(new_question)
         logger.info("Reviewing question %r created by %r", new_question, session.user)
         return jsonify_data(flash=False)
     return jsonify_form(form, fields=getattr(form, '_order', None))
Ejemplo n.º 29
0
 def _process(self):
     form = RegistrationFormScheduleForm(obj=FormDefaults(self.regform), regform=self.regform)
     if form.validate_on_submit():
         self.regform.start_dt = form.start_dt.data
         self.regform.end_dt = form.end_dt.data
         flash(_("Registrations for {} have been scheduled").format(self.regform.title), 'success')
         logger.info("Registrations for %s scheduled by %s", self.regform, session.user)
         return jsonify_data(flash=False)
     return jsonify_form(form, submit=_('Schedule'))
Ejemplo n.º 30
0
 def _process(self):
     inherited_location = self.event.location_data
     inherited_location['inheriting'] = True
     form = SessionForm(obj=FormDefaults(colors=get_random_color(self.event), location_data=inherited_location),
                        event=self.event)
     if form.validate_on_submit():
         new_session = create_session(self.event, form.data)
         return self._get_response(new_session)
     return jsonify_form(form)
Ejemplo n.º 31
0
 def _process(self):
     form = SessionForm(obj=self.session, event=self.event)
     if form.validate_on_submit():
         update_session(self.session, form.data)
         return jsonify_data(html=_render_session_list(self.event))
     return jsonify_form(form)
Ejemplo n.º 32
0
 def _process(self):
     form = None
     parent_session_block = self.entry.parent.object if self.entry.parent else None
     if self.entry.contribution:
         contrib = self.entry.contribution
         tt_entry_dt = self.entry.start_dt.astimezone(self.event.tzinfo)
         form = ContributionEntryForm(obj=FormDefaults(
             contrib, time=tt_entry_dt.time()),
                                      event=self.event,
                                      contrib=contrib,
                                      to_schedule=False,
                                      day=tt_entry_dt.date(),
                                      session_block=parent_session_block)
         if form.validate_on_submit():
             with track_time_changes(auto_extend=True,
                                     user=session.user) as changes:
                 with flash_if_unregistered(self.event,
                                            lambda: contrib.person_links):
                     update_contribution(contrib,
                                         *get_field_values(form.data))
             notifications = get_time_changes_notifications(
                 changes, tzinfo=self.event.tzinfo, entry=self.entry)
             return jsonify_data(update=serialize_entry_update(
                 self.entry, session_=self.session),
                                 notifications=notifications)
         elif not form.is_submitted():
             handle_legacy_description(form.description, contrib)
         return jsonify_template(
             'events/contributions/forms/contribution.html',
             form=form,
             fields=form._display_fields)
     elif self.entry.break_:
         break_ = self.entry.break_
         tt_entry_dt = self.entry.start_dt.astimezone(self.event.tzinfo)
         form = BreakEntryForm(obj=FormDefaults(break_,
                                                time=tt_entry_dt.time()),
                               event=self.event,
                               day=tt_entry_dt.date(),
                               session_block=parent_session_block)
         if form.validate_on_submit():
             with track_time_changes(auto_extend=True,
                                     user=session.user) as changes:
                 update_break_entry(break_, form.data)
             notifications = get_time_changes_notifications(
                 changes, tzinfo=self.event.tzinfo, entry=self.entry)
             return jsonify_data(update=serialize_entry_update(
                 self.entry, session_=self.session),
                                 notifications=notifications,
                                 flash=False)
     elif self.entry.session_block:
         if self.edit_session:
             session_ = self.entry.session_block.session
             form = SessionForm(obj=FormDefaults(session_),
                                event=self.event)
             if form.validate_on_submit():
                 update_session(session_, form.data)
                 return jsonify_data(update=serialize_entry_update(
                     self.entry, session_=self.session),
                                     flash=False)
         else:
             block = self.entry.session_block
             tt_entry_dt = self.entry.start_dt.astimezone(self.event.tzinfo)
             form = SessionBlockEntryForm(obj=FormDefaults(
                 block, time=tt_entry_dt.time()),
                                          event=self.event,
                                          session_block=block,
                                          to_schedule=False,
                                          day=tt_entry_dt.date())
             if form.validate_on_submit():
                 with track_time_changes(auto_extend=True,
                                         user=session.user) as changes:
                     update_session_block(block, form.data)
                 notifications = get_time_changes_notifications(
                     changes, tzinfo=self.event.tzinfo, entry=self.entry)
                 return jsonify_data(update=serialize_entry_update(
                     self.entry, session_=self.session),
                                     notifications=notifications,
                                     flash=False)
     self.commit = False
     return jsonify_form(form,
                         fields=getattr(form, '_display_fields', None))
Ejemplo n.º 33
0
 def render_form(self, form):
     return jsonify_form(form, footer_align_right=True)
Ejemplo n.º 34
0
 def _process(self):
     form = AdminUserSettingsForm(obj=FormDefaults(**user_management_settings.get_all()))
     if form.validate_on_submit():
         user_management_settings.set_multi(form.data)
         return jsonify_data(flash=False)
     return jsonify_form(form)
Ejemplo n.º 35
0
 def _process(self):
     form = TrackGroupForm()
     if form.validate_on_submit():
         create_track_group(self.event, form.data)
         return jsonify_data(html=_render_track_list(self.event))
     return jsonify_form(form)
Ejemplo n.º 36
0
    def _process(self):
        roles = {}
        event_permissions = event_permissions_schema.dump(self.event).get(
            'acl_entries', {})
        roles['global'] = self._map_event_to_track_permissions(
            event_permissions)
        tracks = Track.query.with_parent(self.event).options(
            subqueryload('acl_entries'))
        tracks_by_id = {str(track.id): track for track in tracks}
        for track in tracks:
            roles[str(track.id)] = track_permissions_schema.dump(track).get(
                'acl_entries', {})
        form = AbstractReviewingRolesForm(event=self.event,
                                          obj=FormDefaults(roles=roles))

        if form.validate_on_submit():
            role_data = form.data['roles']

            # Update global permissions
            global_conveners = []
            global_reviewers = []
            global_roles = role_data.pop('global')
            for identifier, permissions in global_roles:
                principal = principal_from_identifier(
                    identifier,
                    allow_groups=True,
                    allow_event_roles=True,
                    allow_category_roles=True,
                    event_id=self.event.id)
                if 'convene' in permissions:
                    global_conveners.append(principal)
                if 'review' in permissions:
                    global_reviewers.append(principal)
            update_object_principals(self.event,
                                     global_conveners,
                                     permission='convene_all_abstracts')
            update_object_principals(self.event,
                                     global_reviewers,
                                     permission='review_all_abstracts')

            # Update track specific permissions
            track_conveners = []
            track_reviewers = []
            for (track_id, track_roles) in role_data.items():
                acl_entries = {}
                for identifier, permissions in track_roles:
                    principal = principal_from_identifier(
                        identifier,
                        allow_groups=True,
                        allow_event_roles=True,
                        allow_category_roles=True,
                        event_id=self.event.id)
                    acl_entries[principal] = set(permissions)
                    if 'convene' in permissions:
                        track_conveners.append(principal)
                    if 'review' in permissions:
                        track_reviewers.append(principal)
                track = tracks_by_id[track_id]
                current = {
                    e.principal: get_unified_permissions(e)
                    for e in track.acl_entries
                }
                update_principals_permissions(track, current, acl_entries)

            # Update event ACL for track and global permissions
            all_conveners = set(global_conveners + track_conveners)
            all_reviewers = set(global_reviewers + track_reviewers)
            update_object_principals(self.event,
                                     all_conveners,
                                     permission='track_convener')
            update_object_principals(self.event,
                                     all_reviewers,
                                     permission='abstract_reviewer')

            flash(_("Abstract reviewing roles have been updated."), 'success')
            logger.info(
                "Abstract reviewing roles of %s have been updated by %s",
                self.event, session.user)
            return jsonify_data()
        return jsonify_form(form,
                            skip_labels=True,
                            form_header_kwargs={'id': 'reviewing-role-form'},
                            disabled_until_change=False)