def _process_conference(self): form = ConferenceLayoutForm(obj=self._get_form_defaults(), event=self.event) css_form = CSSForm() logo_form = LogoForm() tt_theme_settings_form = _make_theme_settings_form(self.event, form.timetable_theme.data) tt_form_valid = tt_theme_settings_form.validate_on_submit() if tt_theme_settings_form else True if form.validate_on_submit() and tt_form_valid: if tt_theme_settings_form: layout_settings.set(self.event, 'timetable_theme_settings', tt_theme_settings_form.data) else: layout_settings.delete(self.event, 'timetable_theme_settings') data = {unicode(key): value for key, value in form.data.iteritems() if key in layout_settings.defaults} layout_settings.set_multi(self.event, data) if form.theme.data == '_custom': layout_settings.set(self.event, 'use_custom_css', True) flash(_('Settings saved'), 'success') return redirect(url_for('.index', self.event)) else: if self.event.logo_metadata: logo_form.logo.data = self.event if self.event.has_stylesheet: css_form.css_file.data = self.event return WPLayoutEdit.render_template('layout_conference.html', self.event, form=form, logo_form=logo_form, css_form=css_form, timetable_theme_settings_form=tt_theme_settings_form)
def _handleSet(self): curType = self._target.getType() newType = self._value if newType != "" and newType != curType: import MaKaC.webinterface.webFactoryRegistry as webFactoryRegistry wr = webFactoryRegistry.WebFactoryRegistry() factory = wr.getFactoryById(newType) wr.registerFactory(self._target, factory) # revert to the default theme for the event type layout_settings.delete(self._conf, 'timetable_theme') signals.event.data_changed.send(self._target, attr=None, old=None, new=None)
def _process_lecture_meeting(self): form = LectureMeetingLayoutForm(obj=self._get_form_defaults(), event=self.event) tt_theme_settings_form = _make_theme_settings_form(self.event, form.timetable_theme.data) tt_form_valid = tt_theme_settings_form.validate_on_submit() if tt_theme_settings_form else True if form.validate_on_submit() and tt_form_valid: if tt_theme_settings_form: layout_settings.set(self.event, 'timetable_theme_settings', tt_theme_settings_form.data) else: layout_settings.delete(self.event, 'timetable_theme_settings') layout_settings.set_multi(self.event, form.data) flash(_('Settings saved'), 'success') return redirect(url_for('.index', self.event)) return WPLayoutEdit.render_template('layout_meeting_lecture.html', self.event, form=form, timetable_theme_settings_form=tt_theme_settings_form)
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)
def _handleSet(self): if self._value == theme_settings.defaults[self._conf.getType()]: layout_settings.delete(self._conf, 'timetable_theme') else: layout_settings.set(self._conf, 'timetable_theme', self._value)
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")) if c.getVisibility() != confData.get("visibility",999): c.setVisibility( confData.get("visibility",999) ) styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() theme = confData.get('defaultStyle', '') curType = c.getType() newType = confData.get('eventType', '') if newType != "" and newType != curType: wr = webFactoryRegistry.WebFactoryRegistry() factory = wr.getFactoryById(newType) wr.registerFactory(c,factory) # type changed. always revert to the default theme layout_settings.delete(c, 'timetable_theme') elif not theme or theme == styleMgr.getDefaultStyleForEventType(newType): # 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) @staticmethod def validateShortURL(tag, target): if tag.isdigit(): raise ValueError(_("Short URL tag is a number: '%s'. Please add at least one non-digit.") % tag) if not re.match(r'^[a-zA-Z0-9/._-]+$', tag) or '//' in tag: raise ValueError( _("Short URL tag contains invalid chars: '%s'. Please select another one.") % tag) if tag[0] == '/' or tag[-1] == '/':
def _handleSet(self): styleMgr = HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager() if self._value == styleMgr.getDefaultStyleForEventType(self._conf.getType()): layout_settings.delete(self._conf, 'timetable_theme') else: layout_settings.set(self._conf, 'timetable_theme', self._value)
c.getSupportInfo().setEmail(emailstr) c.getSupportInfo().setCaption(confData.get("supportCaption", "Support")) if c.getVisibility() != confData.get("visibility", 999): c.setVisibility(confData.get("visibility", 999)) styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager( ) theme = confData.get('defaultStyle', '') curType = c.getType() newType = confData.get('eventType', '') if newType != "" and newType != curType: wr = webFactoryRegistry.WebFactoryRegistry() factory = wr.getFactoryById(newType) wr.registerFactory(c, factory) # type changed. always revert to the default theme layout_settings.delete(c, 'timetable_theme') elif not theme or theme == styleMgr.getDefaultStyleForEventType( newType): # 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) @staticmethod def validateShortURL(tag, target): if tag.isdigit(): raise ValueError( _("Short URL tag is a number: '%s'. Please add at least one non-digit." ) % tag) if not re.match(r'^[a-zA-Z0-9/._-]+$', tag) or '//' in tag: