コード例 #1
0
ファイル: ticket.py プロジェクト: VoteIT/voteit.core
 def ticket_claim(self):
     """ After login or registration, redirect back here, where information about the ticket will be displayed,
         and a confirmation that you want to use the ticket for the current user.
         
         While we use a regular deform form, it's not ment to be displayed or handle any validation.
     """
     if not self.request.authenticated_userid:
         raise HTTPForbidden("Direct access to this view for unauthorized users not allowed.")
     email = self.request.GET.get('email', '')
     ticket = self.context.invite_tickets.get(email, None)
     if ticket and ticket.closed != None:
         msg = _("This ticket has already been used.")
         self.flash_messages.add(msg, type = 'danger', auto_destruct = True, require_commit = False)
         return HTTPFound(location = self.request.resource_url(self.context))
     schema = get_content_schemas(self.request.registry)['Meeting']['claim_ticket']()
     schema = schema.bind(context = self.context, request = self.request, view = self)
     form = deform.Form(schema, buttons = (button_add, button_cancel,))
     if self.request.GET.get('claim'):
         controls = self.request.params.items()
         try:
             appstruct = form.validate(controls)
         except deform.ValidationFailure, e:
             msg = _("ticket_validation_fail",
                     default = "Ticket validation failed. Either the "
                     "ticket doesn't exist, was already used or the url used improperly. "
                     "If you need help, please contact the moderator that invited you to this meeting.")
             self.flash_messages.add(msg, type = 'danger', auto_destruct = False, require_commit = False)
             url = self.request.resource_url(self.root)
             return HTTPFound(location = url)
         #Everything in order, claim ticket
         ticket = self.context.invite_tickets[appstruct['email']]
         claim_ticket(ticket, self.request, self.request.authenticated_userid)
         self.flash_messages.add(_(u"You've been granted access to the meeting. Welcome!"))
         url = self.request.resource_url(self.context)
         return HTTPFound(location=url)
コード例 #2
0
ファイル: base.py プロジェクト: ArcheProject/Arche
 def get_schema_factory(self, type_name, schema_name):
     """ Return a schema registered with the add_schema configuratior.
         Use either this or get_schema to create a form.
     """
     try:
         return get_content_schemas(self.request.registry)[type_name][schema_name]
     except KeyError:
         pass
コード例 #3
0
ファイル: system.py プロジェクト: Jickelsen/Arche
def content_types_panel(context, request, va, **kw):
    response = {
        'content_factories': get_content_factories(request.registry),
        'addable_content': get_addable_content(request.registry),
        'content_views': get_content_views(request.registry),
        'content_schemas': get_content_schemas(request.registry),
        'workflows': get_workflows(request.registry),
        'acl_iface': IContextACL,
        'local_roles_iface': ILocalRoles,
        }
    return render('arche:templates/sysinfo/content_types.pt', response, request = request)
コード例 #4
0
 def ticket_claim(self):
     """ After login or registration, redirect back here, where information about the ticket will be displayed,
         and a confirmation that you want to use the ticket for the current user.
         
         While we use a regular deform form, it's not ment to be displayed or handle any validation.
     """
     if not self.request.authenticated_userid:
         raise HTTPForbidden(
             "Direct access to this view for unauthorized users not allowed."
         )
     email = self.request.GET.get('email', '')
     ticket = self.context.invite_tickets.get(email, None)
     if ticket and ticket.closed != None:
         msg = _("This ticket has already been used.")
         self.flash_messages.add(msg,
                                 type='danger',
                                 auto_destruct=True,
                                 require_commit=False)
         return HTTPFound(location=self.request.resource_url(self.context))
     schema = get_content_schemas(
         self.request.registry)['Meeting']['claim_ticket']()
     schema = schema.bind(context=self.context,
                          request=self.request,
                          view=self)
     form = deform.Form(schema, buttons=(
         button_add,
         button_cancel,
     ))
     if self.request.GET.get('claim'):
         controls = self.request.params.items()
         try:
             appstruct = form.validate(controls)
         except deform.ValidationFailure, e:
             msg = _(
                 "ticket_validation_fail",
                 default="Ticket validation failed. Either the "
                 "ticket doesn't exist, was already used or the url used improperly. "
                 "If you need help, please contact the moderator that invited you to this meeting."
             )
             self.flash_messages.add(msg,
                                     type='danger',
                                     auto_destruct=False,
                                     require_commit=False)
             url = self.request.resource_url(self.root)
             return HTTPFound(location=url)
         #Everything in order, claim ticket
         ticket = self.context.invite_tickets[appstruct['email']]
         claim_ticket(ticket, self.request,
                      self.request.authenticated_userid)
         self.flash_messages.add(
             _(u"You've been granted access to the meeting. Welcome!"))
         url = self.request.resource_url(self.context)
         return HTTPFound(location=url)
コード例 #5
0
ファイル: base.py プロジェクト: ArcheProject/Arche
 def get_schema_factory(self, type_name, schema_name):
     """ Allow custom delete schemas here, otherwise just use the default one. """
     schema = get_content_schemas(self.request.registry).get(type_name, {}).get(schema_name)
     if not schema:
         return colander.Schema
コード例 #6
0
ファイル: base.py プロジェクト: Jickelsen/Arche
 def get_schema_factory(self, type_name, schema_name):
     try:
         return get_content_schemas(self.request.registry)[type_name][schema_name]
     except KeyError:
         pass
コード例 #7
0
ファイル: actions.py プロジェクト: ArcheProject/Arche
def edit_actionbar(context, request, va, **kw):
    try:
        get_content_schemas(request.registry)[getattr(context, 'type_name', None)]['edit']
    except KeyError:
        return
    return actionbar_main_generic(context, request, va, **kw)
コード例 #8
0
ファイル: views.py プロジェクト: ArcheProject/arche_pas
 def get_schema(self):
     schema = get_content_schemas(self.request.registry)[self.type_name][self.schema_name]()
     for k in ('email', 'password'):
         if k in schema:
             del schema[k]
     return schema