Skip to content

Commit

Permalink
Merge pull request #779 from uktrade/XOT-1275-expose-madb-link
Browse files Browse the repository at this point in the history
Add MADB link field to country guide
  • Loading branch information
richtier authored Feb 5, 2020
2 parents 75f53e7 + 14b0f47 commit ad14756
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Pre-release

### Implemented enhancements
- XOT-1275 - Add MADB link field to country guide

### Fixed bugs

Expand Down
50 changes: 50 additions & 0 deletions export_readiness/migrations/0073_auto_20200203_1333.py
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)
]
5 changes: 3 additions & 2 deletions export_readiness/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,9 @@ class Meta:
)

# need help
help_market_guide_cta_link = models.CharField(
max_length=255, blank=True, verbose_name='GOV.UK country guide URL')
duties_and_custom_procedures_cta_link = models.URLField(
blank=True, null=True, verbose_name='Check duties and customs procedures for exporting goods'
)

# related pages
related_page_one = models.ForeignKey(
Expand Down
2 changes: 1 addition & 1 deletion export_readiness/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ class CountryGuidePagePanels:
heading='Need help',
classname='collapsible',
children=[
FieldPanel('help_market_guide_cta_link')
FieldPanel('duties_and_custom_procedures_cta_link')
]
),
MultiFieldPanel(
Expand Down
2 changes: 1 addition & 1 deletion export_readiness/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class CountryGuidePageSerializer(PageWithRelatedPagesSerializer, HeroSerializer)
accordions = serializers.SerializerMethodField()
fact_sheet = serializers.SerializerMethodField()

help_market_guide_cta_link = serializers.CharField(max_length=255)
duties_and_custom_procedures_cta_link = serializers.CharField(max_length=255)

tags = core_fields.TagsListField()
region = serializers.CharField(allow_null=True, source='country.region.name')
Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ w3lib>=1.19.0<2.0.0
django-admin-ip-restrictor==2.1.0
notifications-python-client==5.3.*
pillow>=6.2.0 # for security fix. check compatibility on next wagtail upgrade
pycountry==19.8.18
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ notifications-python-client==5.3.0
oauthlib==3.1.0 # via requests-oauthlib
pillow==6.2.1
psycopg2==2.7.3.2
pycountry==19.8.18
pyjwt==1.7.1 # via notifications-python-client
pyrsistent==0.15.6 # via jsonschema
python-dateutil==2.6.1 # via botocore
Expand Down
1 change: 1 addition & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pluggy==0.12.0 # via pytest
psycopg2==2.7.3.2
py==1.7.0 # via pytest
pycodestyle==2.4.0 # via flake8
pycountry==19.8.18
pyflakes==2.0.0 # via flake8
pyjwt==1.7.1 # via notifications-python-client
pyparsing==2.3.0 # via packaging
Expand Down
2 changes: 1 addition & 1 deletion tests/export_readiness/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class Meta:
fact_sheet_column_2_teaser = factory.fuzzy.FuzzyText(length=10)
fact_sheet_column_2_body = factory.fuzzy.FuzzyText(length=10)

help_market_guide_cta_link = factory.fuzzy.FuzzyText(length=10)
duties_and_custom_procedures_cta_link = 'http://www.example.com'

related_page_one = factory.SubFactory(ArticlePageFactory)
related_page_two = factory.SubFactory(CampaignPageFactory)
Expand Down

0 comments on commit ad14756

Please sign in to comment.