-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #779 from uktrade/XOT-1275-expose-madb-link
Add MADB link field to country guide
- Loading branch information
Showing
9 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Generated by Django 2.2.6 on 2020-02-03 13:33 | ||
|
||
import logging | ||
|
||
|
||
import core.model_fields | ||
from django.db import migrations, models | ||
|
||
import pycountry | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def set_duties_and_custom_procedures_cta_link(apps, schema_editor): | ||
url = 'https://www.check-duties-customs-exporting-goods.service.gov.uk/searchproduct?d=' | ||
CountryGuidePage = apps.get_model('export_readiness', 'CountryGuidePage') | ||
for guide in CountryGuidePage.objects.all(): | ||
try: | ||
matches = pycountry.countries.search_fuzzy(guide.country.name) | ||
except LookupError: | ||
logger.warn(f'no country match for {guide.country.name}') | ||
else: | ||
guide.duties_and_custom_procedures_cta_link = f'{url}{matches[0].alpha_2}' | ||
guide.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('export_readiness', '0072_auto_20191212_1403'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='countryguidepage', | ||
name='help_market_guide_cta_link', | ||
), | ||
migrations.AddField( | ||
model_name='countryguidepage', | ||
name='duties_and_custom_procedures_cta_link', | ||
field=models.URLField(blank=True, null=True, verbose_name='Check duties and customs procedures for exporting goods'), | ||
), | ||
migrations.AlterField( | ||
model_name='homepage', | ||
name='madb_content', | ||
field=core.model_fields.MarkdownField(blank=True, null=True, verbose_name='Content'), | ||
), | ||
migrations.RunPython(set_duties_and_custom_procedures_cta_link, reverse_code=migrations.RunPython.noop) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters