def validate(cls, item):
     # If there's no input in the item, it's valid
     if not isinstance(item, str) or item == "":
         return True
     else:
         # Otherwise it needs to be a date on or before today and after the year 1000.
         # We ourselves create this format if the user gives valid info.
         matches_date_pattern = re.search(r"^\d{1,2}\/\d{1,2}\/\d{4}$", item)
         try:
             date = as_datetime(item)
         except Exception as error:
             msg = f"{ item } {word('is not a valid date')}"
             raise DAValidationError(msg)
         if matches_date_pattern:
             date_diff = date_difference(starting=date, ending=today())
             if date_diff.days >= 0.0:
                 return True
             else:
                 raise DAValidationError(
                     word("Answer with a <strong>date of birth</strong>")
                 )
         else:
             msg = (
                 f"{ item } {word('is not a valid <strong>date of birth</strong>')}"
             )
             raise DAValidationError(msg)
def store_signature_data( signer ):
  """Try to update signature values in the data store.
  
  These include:
  * `signature`
  * `signature_date`
  * `has_signed`
  
  Paramaters
  ----------
  signer: Individual
    An obj of the Individual class that will be given the attributes if keys are valid.
    
  Returns
  ----------
  Returns True if the data got set. Otherwise returns False.
  """
  ## These first two are a bit weird and hidden. What's the clearest/most traceable choice?
  #signer.signature_date = today()
  #signer.has_signed = True
  # TODO: Set persistance and privacy of signature? Seems to funciton without, or is that in other code somewhere?
  store_signer_attribute( signer.signature_data_id, signer.id, 'signature', signer.signature )
  store_signer_attribute( signer.signature_data_id, signer.id, 'signature_date', today() )
  return store_signer_attribute( signer.signature_data_id, signer.id, 'has_signed', True )
  
Example #3
0
 def validate_signature(self, code):
     if code not in self.info_by_code:
         raise Exception("Invalid code")
     self.info_by_code[code]['signed'] = True
     self.info_by_code[code]['date'] = today()
     self.info_by_code[code]['datetime'] = current_datetime()
     self.info_by_code[code]['ip'] = device(
         ip=True) or word("Unable to determine IP address")
     self.check_if_final()
Example #4
0
def is_more_than_one_month_ago(date):
    if date < today() - one_month:
        return True
    else:
        return False
Example #5
0
def is_more_than_one_year_ago(date):
    if date < today() - one_year:
        return True
    else:
        return False
Example #6
0
def is_more_than_three_years_ago(date):
    if date < today() - three_years:
        return True
    else:
        return False
Example #7
0
def is_after_birth_and_more_than_month_ago(date, birth_date):
    if date > birth_date and date < today() - one_month:
        return True
    else:
        return False
 def __init__(self, variable, name, requested=False, accepted=True, date_of_evaluation=today()):
         super(Evaluation, self).init(self, variable, name, requested=False, accepted=True, date_of_evaluation=today())