示例#1
0
 def post(self, request, *args, **kwargs):
     if 'check_number' in request.POST:
         # See how many registrations are left for the phone number
         phone_number = request.POST['check_number']
         remaining = remaining_registrations(phone_number)
         if remaining <= 0:
             msg = _("The phone number {phone_number} cannot be used for any more "
                     "registrations.").format(phone_number=phone_number)
         else:
             msg = ungettext(
                 "The phone number {phone_number} can be used for {number} more registration.",
                 "The phone number {phone_number} can be used for {number} more registrations.",
                 remaining
             ).format(phone_number=phone_number, number=remaining)
         messages.info(request, msg)
         return redirect(request.path)
     return super(ChangePeriodStartedView, self).post(request, *args, **kwargs)
示例#2
0
 def post(self, request, *args, **kwargs):
     if 'check_number' in request.POST:
         # See how many registrations are left for the phone number
         phone_number = request.POST['check_number']
         remaining = remaining_registrations(phone_number)
         if remaining <= 0:
             msg = _(
                 "The phone number {phone_number} cannot be used for any more "
                 "registrations.").format(phone_number=phone_number)
         else:
             msg = ungettext(
                 "The phone number {phone_number} can be used for {number} more registration.",
                 "The phone number {phone_number} can be used for {number} more registrations.",
                 remaining).format(phone_number=phone_number,
                                   number=remaining)
         messages.info(request, msg)
         return redirect(request.path)
     return super(ChangePeriodStartedView,
                  self).post(request, *args, **kwargs)
示例#3
0
 def phone_has_maximum_registrations(self):
     """Return True if the phone used for this registration is at or over the
     maximum registrations per phone"""
     # For convenience from templates
     from register.utils import remaining_registrations
     return remaining_registrations(self.sms.from_number) == 0