def render_entry_info_balloon(entry, editable=False, sess=None): if entry.break_: return render_template('events/timetable/balloons/break.html', break_=entry.break_, editable=editable, can_manage_event=entry.event_new.can_manage( session.user), color_list=get_colors(), event_locked=entry.event_new.is_locked) elif entry.contribution: return render_template( 'events/timetable/balloons/contribution.html', contrib=entry.contribution, editable=editable, can_manage_event=entry.event_new.can_manage(session.user), can_manage_contributions=sess.can_manage_contributions( session.user) if sess else True, event_locked=entry.event_new.is_locked) elif entry.session_block: return render_template( 'events/timetable/balloons/block.html', block=entry.session_block, editable=editable, can_manage_session=sess.can_manage(session.user) if sess else True, can_manage_blocks=sess.can_manage_blocks(session.user) if sess else True, color_list=get_colors(), event_locked=entry.event_new.is_locked) else: raise ValueError("Invalid entry")
def get_random_color(event): breaks = Break.query.filter(Break.timetable_entry.has(event=event)) used_colors = {s.colors for s in event.sessions} | {b.colors for b in breaks} unused_colors = set(get_colors()) - used_colors return random.choice(tuple(unused_colors) or get_colors())
def _get_session_list_args(event): sessions = (Session.query.with_parent(event) .options(undefer('attachment_count'), subqueryload('blocks').undefer('contribution_count')) .order_by(db.func.lower(Session.title)) .all()) return {'sessions': sessions, 'default_colors': get_colors()}
class SessionForm(IndicoForm): title = StringField(_('Title'), [DataRequired()]) code = StringField( _('Session code'), description=_('The code that will identify the session in the Book of ' 'Abstracts.')) description = TextAreaField(_('Description')) default_contribution_duration = TimeDeltaField( _('Default contribution duration'), units=('minutes', 'hours'), description=_('Duration that a contribution created within this ' 'session will have by default.'), default=timedelta(minutes=20)) type = QuerySelectField(_("Type"), get_label='name', allow_blank=True, blank_text=_("No type selected")) location_data = IndicoLocationField( _("Default location"), description=_("Default location for blocks inside the session.")) colors = IndicoPalettePickerField(_('Colours'), color_list=get_colors()) def __init__(self, *args, **kwargs): event = kwargs.pop('event') super(SessionForm, self).__init__(*args, **kwargs) if event.type != 'conference': del self.code del self.type else: self.type.query = SessionType.query.with_parent(event) if not self.type.query.has_rows(): del self.type
class SessionForm(IndicoForm): title = StringField(_('Title'), [DataRequired()]) code = StringField( _('Session code'), description=_('The code that will identify the session in the Book of ' 'Abstracts.')) description = TextAreaField(_('Description')) default_contribution_duration = TimeDeltaField( _('Default contribution duration'), units=('minutes', 'hours'), description=_('Duration that a contribution created within this ' 'session will have by default.'), default=timedelta(minutes=20)) location_data = IndicoLocationField( _("Default location"), description=_("Default location for blocks inside the session.")) colors = IndicoPalettePickerField(_('Colours'), color_list=get_colors()) is_poster = BooleanField( _('Poster session'), widget=SwitchWidget(), description= _('Whether the session is a poster session or contains normal presentations.' )) def __init__(self, *args, **kwargs): event = kwargs.pop('event') super(SessionForm, self).__init__(*args, **kwargs) if event.type != 'conference': del self.is_poster del self.code
def _get_session_list_args(event): sessions = ( Session.query.with_parent(event) .options(undefer("attachment_count"), subqueryload("blocks").undefer("contribution_count")) .order_by(db.func.lower(Session.title)) .all() ) return {"sessions": sessions, "default_colors": get_colors()}
def _get_session_list_args(event): sessions = (Session.query.with_parent(event) .options(undefer('attachment_count'), subqueryload('blocks').undefer('contribution_count')) .order_by(db.func.lower(Session.title)) .all()) types = [{'id': t.id, 'title': t.name} for t in event.session_types] return {'sessions': sessions, 'default_colors': get_colors(), 'types': types}
def _process_PATCH(self): data = request.json if set(data.viewkeys()) > {'colors'}: raise BadRequest if 'colors' in data: colors = ColorTuple(**data['colors']) if colors not in get_colors(): raise BadRequest self.break_.colors = colors
class BreakEntryForm(EntryFormMixin, IndicoForm): _entry_type = TimetableEntryType.BREAK _default_duration = timedelta(minutes=20) _display_fields = ('title', 'description', 'time', 'duration', 'location_data', 'colors') title = StringField(_("Title"), [DataRequired()]) description = TextAreaField(_("Description")) location_data = IndicoLocationField(_("Location")) colors = IndicoPalettePickerField(_('Colours'), color_list=get_colors())
def _process_PATCH(self): data = request.json updates = {} if set(data.viewkeys()) > {'colors'}: raise BadRequest if 'colors' in data: colors = ColorTuple(**data['colors']) if colors not in get_colors(): raise BadRequest updates['colors'] = colors update_session(self.session, updates) return jsonify()
def _process_PATCH(self): data = request.json updates = {} if data.viewkeys() > {"colors"}: raise BadRequest if "colors" in data: colors = ColorTuple(**data["colors"]) if colors not in get_colors(): raise BadRequest updates["colors"] = colors update_session(self.session, updates) return jsonify()
def _process_PATCH(self): data = request.json updates = {} if set(data) - {'colors', 'type_id'}: raise BadRequest if 'colors' in data: colors = ColorTuple(**data['colors']) if colors not in get_colors(): raise BadRequest updates['colors'] = colors if 'type_id' in data: updates.update(self._get_session_type_updates(data['type_id'])) update_session(self.session, updates) return jsonify()
def render_entry_info_balloon(entry, editable=False, sess=None): if entry.break_: return render_template('events/timetable/balloons/break.html', break_=entry.break_, editable=editable, can_manage_event=entry.event_new.can_manage(session.user), color_list=get_colors()) elif entry.contribution: return render_template('events/timetable/balloons/contribution.html', contrib=entry.contribution, editable=editable, can_manage_event=entry.event_new.can_manage(session.user), can_manage_contributions=sess.can_manage_contributions(session.user) if sess else True) elif entry.session_block: return render_template('events/timetable/balloons/block.html', block=entry.session_block, editable=editable, can_manage_session=sess.can_manage(session.user) if sess else True, can_manage_blocks=sess.can_manage_blocks(session.user) if sess else True, color_list=get_colors()) else: raise ValueError("Invalid entry")