Example #1
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)
Example #2
0
    def _createEvent(self, params):
        kwargs = UtilsConference.get_new_conference_kwargs(self._params)
        if kwargs['start_dt'] >= kwargs['end_dt']:
            raise FormValuesError(_('The start date cannot be after the end date.'))
        c = self._target.newConference(self._getUser(), **kwargs)

        UtilsConference.setValues(c, self._params)

        if self._wf:
            self._wfReg.registerFactory( c, self._wf )

        eventAccessProtection = params.get("eventProtection", "inherit")
        if eventAccessProtection == "private" :
            c.getAccessController().setProtection(1)
        elif eventAccessProtection == "public" :
            c.getAccessController().setProtection(-1)

        allowedAvatars = self._getPersons()
        UtilPersons.addToConf(allowedAvatars, c)

        # Add EventPersonLinks to the Event
        person_links = self.get_event_person_links_data(c.as_event)
        update_event(c.as_event, {'person_link_data': person_links})

        return c
Example #3
0
 def _process(self):
     form = EventProtectionForm(obj=FormDefaults(**self._get_defaults()),
                                event=self.event_new)
     if form.validate_on_submit():
         update_event(
             self.event_new, {
                 'protection_mode': form.protection_mode.data,
                 'own_no_access_contact': form.own_no_access_contact.data,
                 'access_key': form.access_key.data
             })
         update_object_principals(self.event_new,
                                  form.acl.data,
                                  read_access=True)
         update_object_principals(self.event_new,
                                  form.managers.data,
                                  full_access=True)
         update_object_principals(self.event_new,
                                  form.submitters.data,
                                  role='submit')
         self._update_session_coordinator_privs(form)
         flash(_('Protection settings have been updated'), 'success')
         return redirect(url_for('.protection', self.event_new))
     return WPEventManagement.render_template('event_protection.html',
                                              self._conf,
                                              form=form,
                                              event=self.event_new)
Example #4
0
    def _createEvent(self, params):
        kwargs = UtilsConference.get_new_conference_kwargs(self._params)
        if kwargs['start_dt'] >= kwargs['end_dt']:
            raise FormValuesError(
                _('The start date cannot be after the end date.'))
        c = self._target.newConference(self._getUser(), **kwargs)

        UtilsConference.setValues(c, self._params)

        if self._wf:
            self._wfReg.registerFactory(c, self._wf)

        eventAccessProtection = params.get("eventProtection", "inherit")
        if eventAccessProtection == "private":
            c.getAccessController().setProtection(1)
        elif eventAccessProtection == "public":
            c.getAccessController().setProtection(-1)

        allowedAvatars = self._getPersons()
        UtilPersons.addToConf(allowedAvatars, c)

        # Add EventPersonLinks to the Event
        person_links = self.get_event_person_links_data(c.as_event)
        update_event(c.as_event, {'person_link_data': person_links})

        return c
Example #5
0
 def _process(self):
     form = self.form_class(obj=self.event, event=self.event)
     if form.validate_on_submit():
         with flash_if_unregistered(self.event, lambda: self.event.person_links):
             update_event(self.event, **form.data)
         return self.jsonify_success()
     self.commit = False
     return self.render_form(form)
Example #6
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)
Example #7
0
 def _process(self):
     form = self.form_class(obj=self.event, event=self.event)
     if form.validate_on_submit():
         with flash_if_unregistered(self.event, lambda: self.event.person_links):
             update_event(self.event, **form.data)
         return self.jsonify_success()
     self.commit = False
     return self.render_form(form)
Example #8
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)
Example #9
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)
Example #10
0
 def _process(self):
     defaults = FormDefaults(self.event, update_timetable=True)
     form = EventDatesForm(obj=defaults, event=self.event)
     if form.validate_on_submit():
         with track_time_changes():
             update_event(self.event, **form.data)
         return self.jsonify_success()
     show_screen_dates = form.has_displayed_dates and (form.start_dt_override.data or form.end_dt_override.data)
     return jsonify_template('events/management/event_dates.html', form=form, show_screen_dates=show_screen_dates)
Example #11
0
 def _process(self):
     defaults = FormDefaults(self.event, update_timetable=True)
     form = EventDatesForm(obj=defaults, event=self.event)
     if form.validate_on_submit():
         with track_time_changes():
             update_event(self.event, **form.data)
         return self.jsonify_success()
     show_screen_dates = form.has_displayed_dates and (form.start_dt_override.data or form.end_dt_override.data)
     return jsonify_template('events/management/event_dates.html', form=form, show_screen_dates=show_screen_dates)
Example #12
0
 def _process(self):
     form = EventProtectionForm(obj=FormDefaults(**self._get_defaults()), event=self.event_new)
     if form.validate_on_submit():
         update_event(self.event_new, {'protection_mode': form.protection_mode.data,
                                       'own_no_access_contact': form.own_no_access_contact.data,
                                       'access_key': form.access_key.data})
         update_object_principals(self.event_new, form.acl.data, read_access=True)
         update_object_principals(self.event_new, form.managers.data, full_access=True)
         update_object_principals(self.event_new, form.submitters.data, role='submit')
         self._update_session_coordinator_privs(form)
         flash(_('Protection settings have been updated'), 'success')
         return redirect(url_for('.protection', self.event_new))
     return WPEventManagement.render_template('event_protection.html', self._conf, form=form, event=self.event_new)
Example #13
0
 def _process(self):
     form = EventProtectionForm(obj=FormDefaults(**self._get_defaults()), event=self.event_new)
     if form.validate_on_submit():
         update_event(
             self.event_new,
             {
                 "protection_mode": form.protection_mode.data,
                 "own_no_access_contact": form.own_no_access_contact.data,
                 "access_key": form.access_key.data,
             },
         )
         update_object_principals(self.event_new, form.acl.data, read_access=True)
         update_object_principals(self.event_new, form.managers.data, full_access=True)
         update_object_principals(self.event_new, form.submitters.data, role="submit")
         self._update_session_coordinator_privs(form)
         flash(_("Protection settings have been updated"), "success")
         return redirect(url_for(".protection", self.event_new))
     return WPEventManagement.render_template("event_protection.html", self._conf, form=form, event=self.event_new)
Example #14
0
class UtilsConference:
    @staticmethod
    def get_start_dt(params):
        tz = params['Timezone']
        try:
            return timezone(tz).localize(
                datetime(int(params['sYear']), int(params['sMonth']),
                         int(params['sDay']), int(params['sHour']),
                         int(params['sMinute'])))
        except ValueError as e:
            raise FormValuesError(
                'The start date you have entered is not correct: {}'.format(e),
                'Event')

    @staticmethod
    def get_end_dt(params, start_dt):
        tz = params['Timezone']
        if params.get('duration'):
            end_dt = start_dt + timedelta(minutes=params['duration'])
        else:
            try:
                end_dt = timezone(tz).localize(
                    datetime(int(params['eYear']), int(params['eMonth']),
                             int(params['eDay']), int(params['eHour']),
                             int(params['eMinute'])))
            except ValueError as e:
                raise FormValuesError(
                    'The end date you have entered is not correct: {}'.format(
                        e), 'Event')
        return end_dt

    @staticmethod
    def get_location_data(params):
        location_data = json.loads(params['location_data'])
        if location_data.get('room_id'):
            location_data['room'] = Room.get_one(location_data['room_id'])
        if location_data.get('venue_id'):
            location_data['venue'] = Location.get_one(
                location_data['venue_id'])
        return location_data

    @classmethod
    def setValues(cls, c, confData, notify=False):
        c.setTitle(confData["title"])
        c.setDescription(confData["description"])
        c.setOrgText(confData.get("orgText", ""))
        c.setComments(confData.get("comments", ""))
        c.as_event.keywords = confData["keywords"]
        c.setChairmanText(confData.get("chairText", ""))
        if "shortURLTag" in confData.keys():
            tag = confData["shortURLTag"].strip()
            if tag:
                try:
                    UtilsConference.validateShortURL(tag, c)
                except ValueError, e:
                    raise FormValuesError(e.message)
            if c.getUrlTag() != tag:
                mapper = ShortURLMapper()
                mapper.remove(c)
                c.setUrlTag(tag)
                if tag:
                    mapper.add(tag, c)
        c.setContactInfo(confData.get("contactInfo", ""))
        #################################
        # Fermi timezone awareness      #
        #################################
        c.setTimezone(confData["Timezone"])
        sDate = cls.get_start_dt(confData)
        eDate = cls.get_end_dt(confData, sDate)
        moveEntries = int(confData.get("move", 0))
        with track_time_changes():
            c.setDates(sDate.astimezone(timezone('UTC')),
                       eDate.astimezone(timezone('UTC')),
                       moveEntries=moveEntries)

        #################################
        # Fermi timezone awareness(end) #
        #################################

        old_location_data = c.as_event.location_data
        location_data = cls.get_location_data(confData)
        update_event(c.as_event, {'location_data': location_data})

        if old_location_data != location_data:
            signals.event.data_changed.send(c,
                                            attr='location',
                                            old=old_location_data,
                                            new=location_data)

        emailstr = setValidEmailSeparators(confData.get("supportEmail", ""))

        if (emailstr != "") and not validMail(emailstr):
            raise FormValuesError(
                "One of the emails specified or one of the separators is invalid"
            )

        c.getSupportInfo().setEmail(emailstr)
        c.getSupportInfo().setCaption(confData.get("supportCaption",
                                                   "Support"))
        # TODO: remove TODO once visibility has been updated
        if c.getVisibility() != confData.get(
                "visibility", 999) and confData.get('visibility') != 'TODO':
            c.setVisibility(confData.get("visibility", 999))
        theme = confData.get('defaultStyle', '')
        new_type = EventType.legacy_map[confData[
            'eventType']] if 'eventType' in confData else c.as_event.type_
        if new_type != c.as_event.type_:
            c.as_event.type_ = new_type
        elif not theme or theme == theme_settings.defaults.get(
                new_type.legacy_name):
            # if it's the default theme or nothing was set (does this ever happen?!), we don't store it
            layout_settings.delete(c, 'timetable_theme')
        else:
            # set the new theme
            layout_settings.set(c, 'timetable_theme', theme)
Example #15
0
 def _update(self, form_data):
     update_event(self.event, **form_data)