def store_contract(self, params, account): tos = params.get('tos', None) sign_date = params.get('sign_date', None) start_date = params.get('start_date', None) end_date_string = params.get('end_date', None) if not tos or not sign_date or not start_date or not account: return None start_date = format_date(start_date) sign_date = format_date(sign_date) if not start_date or not sign_date: return None end_date = format_date(end_date_string) if end_date_string and not end_date: return None contract = OptIn(account=account, tos=tos, start_date=start_date, end_date=end_date, sign_date=sign_date) contract.save() return contract
def _validate_params(self, account_id, start, end): try: start_date = format_date(start) end_date = format_date(end) except: return (None, None, None) account = self.customer_manager.get_account(account_id) if not account: return (None, None, None) return (account, start_date, end_date)