Skip to content

Commit

Permalink
nwpta data contained datetime elements that were not jsonfiable
Browse files Browse the repository at this point in the history
  • Loading branch information
bolyachevets committed Apr 4, 2024
1 parent bc7e19c commit ee3cf07
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion api/namex/resources/name_requests/report_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _get_report(nr_model):

@staticmethod
def _get_report_filename(nr_model):
return 'NR {}.pdf'.format(nr_model.nrNum).replace(' ', '_')
return '{}.pdf'.format(nr_model.nrNum).replace(' ', '_')

@staticmethod
def _get_template():
Expand Down Expand Up @@ -268,6 +268,14 @@ def _get_template_data(nr_model):
tz_aware_date = nr_model.submittedDate.replace(tzinfo=timezone('UTC'))
localized_date = tz_aware_date.astimezone(timezone('US/Pacific'))
nr_report_json['submittedDate'] = localized_date.strftime(DATE_FORMAT)
if nr_report_json['lastUpdate']:
tz_aware_date = nr_model.submittedDate.replace(tzinfo=timezone('UTC'))
localized_date = tz_aware_date.astimezone(timezone('US/Pacific'))
nr_report_json['lastUpdate'] = localized_date.strftime(DATE_FORMAT)
if nr_report_json['priorityDate']:
tz_aware_date = nr_model.submittedDate.replace(tzinfo=timezone('UTC'))
localized_date = tz_aware_date.astimezone(timezone('US/Pacific'))
nr_report_json['priorityDate'] = localized_date.strftime(DATE_FORMAT)
if nr_report_json['applicants']['countryTypeCd']:
nr_report_json['applicants']['countryName'] = \
pycountry.countries.search_fuzzy(nr_report_json['applicants']['countryTypeCd'])[0].name
Expand All @@ -281,6 +289,7 @@ def _get_template_data(nr_model):
nr_report_json['retrievalDateTime'] = datetime.now().astimezone(timezone('US/Pacific')).strftime(DATE_FORMAT)

nr_report_json['hasUnreviewedNames'] = ReportResource._hasUnReviewedNames(nr_report_json['names'])
nr_report_json['nwpta'] = []
return nr_report_json


Expand Down

0 comments on commit ee3cf07

Please sign in to comment.