当前位置: 首页>>代码示例>>Python>>正文


Python irl._函数代码示例

本文整理汇总了Python中voteit.irl._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pronoun_in_site_settings

def pronoun_in_site_settings(schema, event):
    schema.add(colander.SchemaNode(
        colander.Boolean(),
        name="pronoun_active",
        title=_("Let users select pronoun"),
        description=_("Pronoun might be shown in different contexts like the speaker list."),
        missing=False))
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:7,代码来源:gender.py

示例2: __call__

 def __call__(self, form, values):
     exc = colander.Invalid(form)  # Raised if trouble
     pns = self.request.registry.getAdapter(self.request.meeting, IParticipantNumbers)
     numbers = tuple(pns.tickets.keys())
     start_at = values['start_at']
     if start_at not in numbers and not values['create_new']:
         exc['start_at'] = _("Not an existing participant number")
         raise exc
     existing_emails = tuple([x.email for x in pns.tickets.values()])
     found = []
     i = start_at
     emails = values['emails'].splitlines()
     for email in emails:
         if email in existing_emails:
             found.append(email)
         if not values['create_new']:
             # Check if numbers exist
             if i not in numbers:
                 exc['emails'] = _("attach_emails_pn_dont_exist_error",
                                   default="There are more email addresses than "
                                           "existing participant numbers. "
                                           "Number ${num} not found. Total emails: ${emails_count}",
                                   mapping={'num': i, 'emails_count': len(emails)})
                 raise exc
             i += 1
     if found:
         exc['emails'] = _("The following emails are already assigned to numbers: ${emails}",
                           mapping={'emails': ", ".join(found)})
         raise exc
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:29,代码来源:schemas.py

示例3: claim_participant_number_menu

def claim_participant_number_menu(context, request, va, **kw):
    if request.meeting:
        translate = request.localizer.translate
        participant_numbers = request.registry.getAdapter(request.meeting, IParticipantNumbers)
        if request.authenticated_userid not in participant_numbers.userid_to_number:
            self_assignment = request.registry.getAdapter(request.meeting, ISelfAssignmentSettings)
            if self_assignment.enabled:
                if self_assignment.user_has_required_role(request):
                    url = request.resource_url(request.meeting, 'self_claim_participant_number')
                else:
                    # The current user don't have the required role
                    role = request.registry.roles.get(self_assignment.required_role, None)
                    if role:
                        role_title = translate(role.title)
                    else:
                        role_title = self_assignment.required_role
                    return """<li class="disabled"><a>%s<br/>%s</a></li>""" % (
                           translate(
                               _("You lack the role '${role}'",
                                 mapping={'role': role_title})
                           ),
                           translate(
                               _("which is required to request a participant number.")
                           ),
                    )

            else:
                url = request.resource_url(request.meeting, 'claim_participant_number')
            return """<li><a href="%s">%s</a></li>""" % (url,
                                                         translate(_("Claim participant number")))
        else:
            return """<li class="disabled"><a>%s: %s</a></li>""" % (
                translate(_("Your participant number")),
                participant_numbers.userid_to_number[request.authenticated_userid]
            )
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:35,代码来源:participant_numbers.py

示例4: adjust_voters

 def adjust_voters(self, method_name):
     method = self.request.registry.getAdapter(self.context, IElegibleVotersMethod, name = method_name)
     new_voters = method.get_voters(request = self.request)
     if not isinstance(new_voters, frozenset):
         new_voters = frozenset(new_voters)
     electoral_register = self.request.registry.getAdapter(self.context, IElectoralRegister)
     current_voters = electoral_register.currently_set_voters()
     if current_voters == new_voters:
         msg = _(u"no_update_of_perms_needed_notice",
                 default = u"Method '${method_title}' applied but it reports no change needed.",
                 mapping = {'method_title': self.request.localizer.translate(method.title)})
         self.flash_messages.add(msg)
         return
     removed_voters = current_voters - new_voters
     added_voters = new_voters - current_voters
     for userid in removed_voters:
         self.context.del_groups(userid, (ROLE_VOTER,))
     for userid in added_voters:
         self.context.add_groups(userid, (ROLE_VOTER,))
     msg = _("updated_voter_permissions_notice",
             default = "Method '${method_title}' added ${added_count} and removed ${removed_count}.",
             mapping = {'method_title': self.request.localizer.translate(method.title),
                        'added_count': len(added_voters),
                        'removed_count': len(removed_voters)})
     self.flash_messages.add(msg)
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:25,代码来源:eligible_voters.py

示例5: save_success

 def save_success(self, appstruct):
     # Since this is a bit backwards, we need to fetch the token.
     pn = appstruct['pn']
     userid = appstruct['userid']
     found = False
     for (token, num) in self.participant_numbers.token_to_number.items():
         if num == pn:
             found = True
             break
     if not found:
         raise HTTPForbidden(_(u"Participant number not found"))
     # Clear old number?
     if userid in self.participant_numbers.userid_to_number:
         number = self.participant_numbers.userid_to_number[userid]
         msg = _("participant_number_moved_warning",
                 default = u"This user was already assigned number ${number} so that number was cleared.",
                 mapping = {'number': number})
         self.flash_messages.add(msg, type = 'warning')
         self.participant_numbers.clear_number(number)
     # Assign
     number = self.participant_numbers.claim_ticket(userid, token)
     msg = _("number_now_assigned_notice",
             default = "You're now assigned number ${number}.",
             mapping = {'number': number})
     self.flash_messages.add(msg)
     return HTTPFound(location = self.request.resource_url(self.context, "manage_participant_numbers"))
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:26,代码来源:participant_numbers.py

示例6: manage_participant_numbers

 def manage_participant_numbers(self):
     if 'back' in self.request.POST:
         return HTTPFound(location = self.request.resource_url(self.context))
     response = {}
     add = 'add' in self.request.POST
     remove = 'remove' in self.request.POST
     here_url = self.request.resource_url(self.context, 'manage_participant_numbers')
     if add or remove:
         #Basic validation
         try:
             start = self.request.POST.get('start', None)
             start = int(start)
             end = self.request.POST.get('end', None)
             if not end:
                 end = None
             else:
                 end = int(end)
                 if start > end:
                     raise HTTPForbidden(_(u"End must be higher than start"))
         except TypeError:
             raise HTTPForbidden(_(u"Must be an integer value"))
         if add:
             res = self.participant_numbers.new_tickets(self.request.authenticated_userid, start, end)
             msg = _(u"Added ${count} new numbers",
                     mapping = {'count': len(res)})
             self.flash_messages.add(msg)
         if remove:
             res = self.participant_numbers.clear_numbers(start, end)
             msg = _(u"Removed ${count} numbers",
                     mapping = {'count': len(res)})
             self.flash_messages.add(msg, type = "warning")
         return HTTPFound(location = here_url)
     response['participant_numbers'] = self.participant_numbers
     return response
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:34,代码来源:participant_numbers.py

示例7: __call__

 def __call__(self, node, value):
     if not principal_has_permisson(self.request, value, security.VIEW, context=self.context):
         raise colander.Invalid(node, _("${userid} doesn't exist in this meeting.",
                                        mapping={'userid': value}))
     if security.ROLE_VOTER in self.context.get_groups(value):
         raise colander.Invalid(node, _("${userid} is already a voter.",
                                        mapping={'userid': value}))
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:7,代码来源:transfer_vote.py

示例8: includeme

def includeme(config):
    config.add_portlet(MeetingPresencePortlet)
    config.scan(__name__)
    config.add_view_action(
        control_panel_category,
        'control_panel', 'meeting_presence',
        panel_group = 'control_panel_meeting_presence',
        title=_("Meeting presence"),
        description=_("meeting_presence_cp_description",
                      default="Check who's present. "
                              "Can be used as base to distribute voting rights."),
        permission = MODERATE_MEETING,
        check_active=meeting_presence_enabled,
    )
    config.add_view_action(
        control_panel_link,
        'control_panel_meeting_presence', 'check',
        title=_("Check presence"),
        view_name='check_meeting_presence',
        priority=10,
    )
    config.add_view_action(
        control_panel_link,
        'control_panel_meeting_presence', 'settings',
        title=_("Settings"),
        view_name='meeting_presence_settings',
        priority=20,
    )
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:28,代码来源:meeting_presence.py

示例9: get_schema

 def get_schema(self):
     schema = colander.Schema(title = _(u"Select discussion posts to print"),
                              description = _(u"print_discussion_description",
                                              default = u"Each post will be on its own page"))
     for post in self.context.get_content(content_type = 'DiscussionPost'):
         schema.add(colander.SchemaNode(colander.Bool(),
                                        name = post.__name__,
                                        title = strip_and_truncate(post.text, symbol = '[...]'),))
     return schema
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:9,代码来源:print.py

示例10: __call__

 def __call__(self, node, value):
     parts = value.split('-')
     err = _("Must be written as 'NN-XX' where N is low nr and X high.")
     if len(parts) != 2:
         raise colander.Invalid(node, err)
     try:
         parts = [int(x) for x in parts]
     except:
         raise colander.Invalid(node, err)
     if parts[0] >= parts[1]:
         raise colander.Invalid(node, _("First value must be higher than second"))
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:11,代码来源:present_users_voters.py

示例11: assign_success

 def assign_success(self, appstruct):
     start_number = self.self_assignment_settings.get('start_number', None)
     if not isinstance(start_number, int):
         self.flash_messages.add(_("Meeting has bad configurartion for participant numbers, contact the moderator.",
                                   type='danger'))
         return HTTPFound(location=self.request.resource_url(self.context))
     new_pn = assign_next_free_pn(self.participant_numbers, self.request.authenticated_userid, start_number)
     if not new_pn:
         raise HTTPBadRequest("No number can be assigned.")
     msg = _("You've been assigned number ${num}", mapping={'num': new_pn})
     self.flash_messages.add(msg, type='success')
     return HTTPFound(location = self.request.resource_url(self.context))
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:12,代码来源:participant_numbers.py

示例12: manage_participant_callbacks

 def manage_participant_callbacks(self):
     if 'back' in self.request.POST:
         return HTTPFound(location = self.request.resource_url(self.context))
     add = 'add' in self.request.POST
     remove = 'remove' in self.request.POST
     if add or remove:
         #Basic validation
         try:
             start = self.request.POST.get('start', None)
             start = int(start)
             end = self.request.POST.get('end', None)
             if not end:
                 end = None
             else:
                 end = int(end)
                 if start > end:
                     raise HTTPForbidden(_("End must be higher than start"))
         except TypeError:
             raise HTTPForbidden(_("Must be an integer value"))
         
         callback = self.request.POST['callback']
         if add:
             added, existed = self.participant_callbacks.add(callback, start, end)
             msg = _(u"Added ${added} new callbacks and skipped ${existed} that already existed.",
                     mapping = {'added': len(added), 'existed': len(existed)})
             self.flash_messages.add(msg)
             if self.request.POST.get('execute_for_existing', True):
                 executed = 0
                 if end == None:
                     end = start
                 for i in range(start, end + 1): #Range  stops before end otherwise
                     if i in self.participant_numbers.number_to_userid:
                         #The method execute_callbacks_for is fault tolerant for missing callbacks, but not for
                         #failures within the actual callback.
                         self.participant_callbacks.execute_callbacks_for(i, self.participant_numbers.number_to_userid[i],
                                                                          limit = callback, request = self.request)
                         executed += 1
                 msg = _(u"Executed callback for ${num} users that had already claimed a participant number.",
                         mapping = {'num': executed})
                 self.flash_messages.add(msg)
         if remove:
             removed, nonexistent = self.participant_callbacks.remove(callback, start, end)
             msg = _(u"Removed ${removed} callbacks and skipped ${nonexistent} that wasn't registered.",
                     mapping = {'removed': len(removed), 'nonexistent': len(nonexistent)})
             self.flash_messages.add(msg)
         here_url = self.request.resource_url(self.context, 'manage_participant_callbacks')
         return HTTPFound(location = here_url)
     response = {}
     response['participant_numbers'] = self.participant_numbers
     response['participant_callbacks'] = self.participant_callbacks
     response['callback_adapters'] = [adapter for (name, adapter) in self.request.registry.getAdapters([self.request.meeting], IParticipantCallback)]
     return response
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:52,代码来源:participant_callbacks.py

示例13: includeme

def includeme(config):
    config.scan(__name__)
    config.add_view_action(
        control_panel_category,
        'control_panel', 'print_',
             panel_group='control_panel_print_btn_settings',
             title=_("Print button"),
    )
    config.add_view_action(
        control_panel_link,
        'control_panel_print_btn_settings', 'settings',
        title=_("Settings"),
        view_name='print_btn_settings',
    )
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:14,代码来源:print.py

示例14: inject_in_settings

def inject_in_settings(schema, event):
    schema.add(
        colander.SchemaNode(
            colander.String(),
            title = _("Voter participant number range"),
            description=_("voter_pn_range_desc",
                          default="Write number as 'NN-NN', i.e. 10-20 means that "
                                  "10 to and including 20 will be voters if they're "
                                  "marked as present."),
            name = 'elegible_voter_pn',
            missing = "",
            validator = ElegibleVoterPNRangeValidator(),
        )
    )
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:14,代码来源:present_users_voters.py

示例15: presence_check_ctrl

 def presence_check_ctrl(self):
     action = self.request.GET.get('action', '')
     if action == 'start':
         self.flash_messages.add(_("Started"), type = 'success')
         self.mp_util.start_check()
     elif action == 'end':
         if self.mp_util.open:
             self.flash_messages.add(_("Closed"), type = 'warning')
             self.mp_util.end_check()
         else:
             raise HTTPForbidden("No check ongoing")
     else:
         raise HTTPForbidden("No such action %r" % action)
     came_from = self.request.GET.get('came_from', self.request.resource_url(self.request.meeting))
     return HTTPFound(location = came_from)
开发者ID:VoteIT,项目名称:voteit.irl,代码行数:15,代码来源:meeting_presence.py


注:本文中的voteit.irl._函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。