Esempio n. 1
0
    def _process(self):
        self.is_manager = self.definition.can_be_managed(session.user)
        self.form = self.definition.create_form(self.event_new, self.request)
        self.manager_form = None
        if self.request and self.is_manager:
            self.manager_form = self.definition.create_manager_form(
                self.request)
            if self.request.state not in {
                    RequestState.accepted, RequestState.rejected
            }:
                del self.manager_form.action_save
            if self.request.state == RequestState.accepted:
                del self.manager_form.action_accept
            if self.request.state == RequestState.rejected:
                del self.manager_form.action_reject

        rv = self.process_form()
        if rv:
            return rv

        form_html = self.definition.render_form(
            event=self.event_new,
            definition=self.definition,
            req=self.request,
            form=self.form,
            manager_form=self.manager_form,
            is_manager=self.is_manager,
            protection_overridden=self.protection_overridden)
        return WPRequestsEventManagement.render_string(form_html, self._conf)
Esempio n. 2
0
    def render_form(cls, event, **kwargs):
        """Render the request form.

        :param event: the event the request is for
        :param kwargs: arguments passed to the template
        """
        tpl = get_overridable_template_name('event_request_details.html', cls.plugin, 'events/requests/')
        return WPRequestsEventManagement.render_template(tpl, event, **kwargs)
Esempio n. 3
0
    def render_form(cls, event, **kwargs):
        """Renders the request form

        :param event: the event the request is for
        :param kwargs: arguments passed to the template
        """
        tpl = get_overridable_template_name('event_request_details.html', cls.plugin, 'events/requests/')
        return WPRequestsEventManagement.render_template(tpl, event, **kwargs)
Esempio n. 4
0
 def _process(self):
     definitions = get_request_definitions()
     if not definitions:
         raise NotFound
     requests = Request.find_latest_for_event(self.event)
     if self.protection_overridden:
         definitions = {name: def_ for name, def_ in definitions.iteritems() if def_.can_be_managed(session.user)}
         requests = {name: req for name, req in requests.iteritems()
                     if req.definition and req.definition.can_be_managed(session.user)}
     return WPRequestsEventManagement.render_template('events/requests/event_requests.html', self.event,
                                                      definitions=definitions, requests=requests)
Esempio n. 5
0
 def _process(self):
     definitions = get_request_definitions()
     if not definitions:
         raise NotFound
     requests = Request.find_latest_for_event(self.event)
     if self.protection_overridden:
         definitions = {name: def_ for name, def_ in definitions.iteritems() if def_.can_be_managed(session.user)}
         requests = {name: req for name, req in requests.iteritems()
                     if req.definition and req.definition.can_be_managed(session.user)}
     return WPRequestsEventManagement.render_template('events/requests/event_requests.html', self.event,
                                                      definitions=definitions, requests=requests)
Esempio n. 6
0
    def _process(self):
        self.is_manager = self.definition.can_be_managed(session.user)
        self.form = self.definition.create_form(self.event, self.request)
        self.manager_form = None
        if self.request and self.is_manager:
            self.manager_form = self.definition.create_manager_form(self.request)
            if self.request.state not in {RequestState.accepted, RequestState.rejected}:
                del self.manager_form.action_save
            if self.request.state == RequestState.accepted:
                del self.manager_form.action_accept
            if self.request.state == RequestState.rejected:
                del self.manager_form.action_reject

        rv = self.process_form()
        if rv:
            return rv

        form_html = self.definition.render_form(event=self.event, definition=self.definition, req=self.request,
                                                form=self.form, manager_form=self.manager_form,
                                                is_manager=self.is_manager)
        return WPRequestsEventManagement.render_string(form_html, self.event)