Ejemplo n.º 1
0
 def _event_updated(self, event, changes, **kwargs):
     req = Request.find_latest_for_event(event, VCAssistanceRequest.name)
     if not req or req.state != RequestState.accepted:
         return
     if 'start_dt' in changes and not start_time_within_working_hours(
             event):
         flash(
             _("The new event start time is out of working hours so videoconference assistance cannot be "
               "provided."), 'warning')
     if 'location_data' in changes and not has_vc_rooms_attached_to_capable(
             event):
         flash(
             _("The new event location doesn't have videoconference capabilities so videoconference "
               "assistance cannot be provided."), 'warning')
Ejemplo n.º 2
0
 def _extend_top_menu(self, sender, **kwargs):
     if not session.user or not is_vc_support(session.user):
         return
     return TopMenuItem('services-cern-vc-assistance',
                        _('Videoconference assistance'),
                        url_for_plugin('vc_assistance.request_list'),
                        section='services')
Ejemplo n.º 3
0
class VCAssistanceRequest(RequestDefinitionBase):
    name = 'vc-assistance'
    title = _('Videoconference assistance')
    form = VCAssistanceRequestForm

    @classmethod
    def can_be_managed(cls, user):
        return False

    @classmethod
    def render_form(cls, event, **kwargs):
        from indico_vc_assistance.plugin import VCAssistanceRequestPlugin
        req = kwargs['req']
        kwargs['user_authorized'] = can_request_assistance(session.user)
        kwargs['has_vc_capable_rooms'] = has_vc_capable_rooms(event)
        kwargs['has_vc_rooms'] = has_vc_rooms(event)
        kwargs[
            'has_vc_rooms_attached_to_capable'] = has_vc_rooms_attached_to_capable(
                event)
        kwargs[
            'request_accepted'] = req is not None and req.state == RequestState.accepted
        kwargs['within_working_hours'] = start_time_within_working_hours(event)
        kwargs['support_email'] = VCAssistanceRequestPlugin.settings.get(
            'support_email')
        return super(VCAssistanceRequest, cls).render_form(event, **kwargs)

    @classmethod
    def send(cls, req, data):
        if not can_request_assistance(session.user):
            raise Forbidden
        super(VCAssistanceRequest, cls).send(req, data)
        req.state = RequestState.accepted
Ejemplo n.º 4
0
class RequestListFilterForm(IndicoForm):
    direction = SelectField(_('Sort direction'), [DataRequired()],
                            choices=[('asc', _('Ascending')),
                                     ('desc', _('Descending'))])
    abs_start_date = IndicoDateField(
        _('Start Date'), [Optional(), Exclusive('rel_start_date')])
    abs_end_date = IndicoDateField(
        _('End Date'), [Optional(), Exclusive('rel_end_date')])
    rel_start_date = IntegerField(
        _('Days in the past'),
        [Optional(),
         Exclusive('abs_start_date'),
         NumberRange(min=0)])
    rel_end_date = IntegerField(
        _('Days in the future'),
        [Optional(), Exclusive('abs_end_date'),
         NumberRange(min=0)])

    def is_submitted(self):
        return bool(request.args)

    @generated_data
    def start_date(self):
        if self.abs_start_date.data is None and self.rel_start_date.data is None:
            return None
        return self.abs_start_date.data or (
            date.today() - timedelta(days=self.rel_start_date.data))

    @generated_data
    def end_date(self):
        if self.abs_end_date.data is None and self.rel_end_date.data is None:
            return None
        return self.abs_end_date.data or (
            date.today() + timedelta(days=self.rel_end_date.data))
Ejemplo n.º 5
0
class PluginSettingsForm(IndicoForm):
    authorized = PrincipalListField(
        _('Authorized users'),
        groups=True,
        description=_(
            'List of users who can request videoconference assistance.'))
    vc_support = PrincipalListField(
        _('Videoconference support'),
        groups=True,
        description=_(
            'List of users who can view the list of events with videoconference '
            'assistance.'))
    support_email = EmailField(
        _('Support email'), [DataRequired()],
        description=_('Videoconference email support address'))
    room_feature = QuerySelectField(
        _("Room feature"), [DataRequired()],
        allow_blank=True,
        query_factory=lambda: RoomFeature.query,
        get_label='title',
        description=_(
            "The feature indicating that a room supports videoconference."))
Ejemplo n.º 6
0
class VCAssistanceRequestForm(RequestFormBase):
    comment = TextAreaField(
        _('Comment'),
        description=_('If you have any additional comments or instructions, '
                      'please write them down here.'))