Skip to content

Commit

Permalink
Merge pull request #235 from datamade/source-url
Browse files Browse the repository at this point in the history
Import API and/or web source url for bill
  • Loading branch information
reginafcompton authored Feb 11, 2019
2 parents 2648452 + c98c6f9 commit 7ceb67b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion councilmatic_core/management/commands/import_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,10 +964,19 @@ def insert_raw_bills(self, delete=False):
with open(os.path.join(self.bills_folder, bill_json)) as f:
bill_info = json.loads(f.read())


# Add the web source, if available.
# Otherwise, assume that the 'api' source is available and add that.
source_url = None
source_note = None
for source in bill_info['sources']:
if source['note'] == 'web':
source_url = source['url']
source_note = source['note']
break
else:
source_url = source['url']
source_note = source['note']

full_text = None
if 'rtf_text' in bill_info['extras']:
Expand Down Expand Up @@ -1008,7 +1017,7 @@ def insert_raw_bills(self, delete=False):
'identifier': bill_info['identifier'],
'classification': bill_info['classification'][0],
'source_url': source_url,
'source_note': bill_info['sources'][0]['note'],
'source_note': source_note,
'from_organization_id': bill_info['from_organization']['id'],
'full_text': full_text,
'ocr_full_text': ocr_full_text,
Expand Down

0 comments on commit 7ceb67b

Please sign in to comment.