parameters: (cls, user)
return_statement: return confirm
docstring: Check for an existing UserConfirmation object, or make a new one. Generate
          a random token in either case. This is limited to once every RESET_RATE_LIMIT per
          user. The object is updated in the database.
docstring_summary: Check for an existing UserConfirmation object, or make a new one. Generate
          a random token in either case. This is limited to once every RESET_RATE_LIMIT per
          user. The object is updated in the database.
docstring_tokens: Check for an existing UserConfirmation object or make a new one . Generate a random token in either case . This is limited to once every RESET_RATE_LIMIT per user . The object is updated in the database .
function: def make_confirm(cls, user):
          """Check for an existing UserConfirmation object, or make a new one. Generate
          a random token in either case. This is limited to once every RESET_RATE_LIMIT per
          user. The object is updated in the database."""
  
          now = pytz.UTC.localize(datetime.datetime.now())
  
          try:
              confirm = cls.objects.get(user=user)
              # Limit how often passwords can be reset, and confirmation
              if now - confirm.sent < cls.RESET_RATE_LIMIT:
                  return "Reset limit reached. Wait at least {:d} minutes." \
                      .format(int(cls.RESET_RATE_LIMIT/60))
          except cls.DoesNotExist:
              confirm = cls(user=user, created=now)
  
          # dev/random would be better, but we probably don't have a good source of randomness.
          # This is admin initiated, so it should be random enough.
          urandom = open('/dev/urandom', 'rb')
          confirm.token = binascii.hexlify(urandom.read(cls.TOKEN_BYTES))
  
          confirm.save()
          return confirm
function_tokens: def make_confirm ( cls , user ) : now = pytz . UTC . localize ( datetime . datetime . now ( ) ) try : confirm = cls . objects . get ( user = user ) # Limit how often passwords can be reset, and confirmation if now - confirm . sent < cls . RESET_RATE_LIMIT : return "Reset limit reached. Wait at least {:d} minutes." . format ( int ( cls . RESET_RATE_LIMIT / 60 ) ) except cls . DoesNotExist : confirm = cls ( user = user , created = now ) # dev/random would be better, but we probably don't have a good source of randomness. # This is admin initiated, so it should be random enough. urandom = open ( '/dev/urandom' , 'rb' ) confirm . token = binascii . hexlify ( urandom . read ( cls . TOKEN_BYTES ) ) confirm . save ( ) return confirm