コード例 #1
0
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")
コード例 #2
0
ファイル: util.py プロジェクト: qroques/indico
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())
コード例 #3
0
ファイル: sessions.py プロジェクト: DirkHoffmann/indico
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()}
コード例 #4
0
ファイル: forms.py プロジェクト: vintas/indico
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
コード例 #5
0
ファイル: forms.py プロジェクト: ipaste/indico
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
コード例 #6
0
ファイル: sessions.py プロジェクト: ipaste/indico
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()}
コード例 #7
0
ファイル: sessions.py プロジェクト: OmeGak/indico
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()}
コード例 #8
0
ファイル: sessions.py プロジェクト: wasm-network/indico
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}
コード例 #9
0
ファイル: sessions.py プロジェクト: indico/indico
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}
コード例 #10
0
ファイル: manage.py プロジェクト: DirkHoffmann/indico
 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
コード例 #11
0
ファイル: forms.py プロジェクト: uniteddiversity/indico
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())
コード例 #12
0
ファイル: manage.py プロジェクト: ipaste/indico
 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
コード例 #13
0
 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()
コード例 #14
0
ファイル: sessions.py プロジェクト: OmeGak/indico
 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()
コード例 #15
0
ファイル: sessions.py プロジェクト: DirkHoffmann/indico
 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()
コード例 #16
0
ファイル: sessions.py プロジェクト: indico/indico
 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()
コード例 #17
0
ファイル: sessions.py プロジェクト: weLoser/indico
 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()
コード例 #18
0
ファイル: util.py プロジェクト: OmeGak/indico
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")
コード例 #19
0
ファイル: util.py プロジェクト: indico/indico
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())