diff --git a/core/migrations/0160_countrytaggedsectorandmarketpromo_and_more.py b/core/migrations/0161_countrytaggedsectorandmarketcard_sectorandmarketcard_and_more.py similarity index 73% rename from core/migrations/0160_countrytaggedsectorandmarketpromo_and_more.py rename to core/migrations/0161_countrytaggedsectorandmarketcard_sectorandmarketcard_and_more.py index 439fd784ca..1b655494b7 100644 --- a/core/migrations/0160_countrytaggedsectorandmarketpromo_and_more.py +++ b/core/migrations/0161_countrytaggedsectorandmarketcard_sectorandmarketcard_and_more.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.15 on 2024-10-02 11:45 +# Generated by Django 4.2.15 on 2024-10-02 14:20 from django.db import migrations, models import django.db.models.deletion @@ -10,12 +10,12 @@ class Migration(migrations.Migration): dependencies = [ - ('core', '0159_remove_regiontagged_content_type_and_more'), + ('core', '0160_alter_herosnippet_slug'), ] operations = [ migrations.CreateModel( - name='CountryTaggedSectorAndMarketPromo', + name='CountryTaggedSectorAndMarketCard', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ], @@ -24,19 +24,31 @@ class Migration(migrations.Migration): }, ), migrations.CreateModel( - name='SectorAndMarketPromo', + name='SectorAndMarketCard', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField()), ('description', models.TextField()), ('link_text', models.CharField(blank=True)), ('link_url', models.CharField(blank=True)), + ( + 'meta_label', + models.CharField( + choices=[ + ('guidance_great', 'Guidance on great.gov.uk'), + ('service_great', 'Service on great.gov.uk'), + ('guidance_gov', 'Guidance on GOV.UK'), + ('service_gov', 'Service on GOV.UK'), + ], + max_length=255, + ), + ), ( 'country_tags', taggit.managers.TaggableManager( blank=True, help_text='A comma-separated list of tags.', - through='core.CountryTaggedSectorAndMarketPromo', + through='core.CountryTaggedSectorAndMarketCard', to='core.CountryTag', verbose_name='Country tag', ), @@ -48,13 +60,13 @@ class Migration(migrations.Migration): bases=(wagtail.search.index.Indexed, models.Model), ), migrations.CreateModel( - name='SectorTaggedTaggedSectorAndMarketPromo', + name='SectorTaggedTaggedSectorAndMarketCard', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ( 'content_object', modelcluster.fields.ParentalKey( - on_delete=django.db.models.deletion.CASCADE, to='core.sectorandmarketpromo' + on_delete=django.db.models.deletion.CASCADE, to='core.sectorandmarketcard' ), ), ( @@ -69,25 +81,25 @@ class Migration(migrations.Migration): }, ), migrations.AddField( - model_name='sectorandmarketpromo', + model_name='sectorandmarketcard', name='sector_tags', field=taggit.managers.TaggableManager( blank=True, help_text='A comma-separated list of tags.', - through='core.SectorTaggedTaggedSectorAndMarketPromo', + through='core.SectorTaggedTaggedSectorAndMarketCard', to='core.SectorTag', verbose_name='Sector tag', ), ), migrations.AddField( - model_name='countrytaggedsectorandmarketpromo', + model_name='countrytaggedsectorandmarketcard', name='content_object', field=modelcluster.fields.ParentalKey( - on_delete=django.db.models.deletion.CASCADE, to='core.sectorandmarketpromo' + on_delete=django.db.models.deletion.CASCADE, to='core.sectorandmarketcard' ), ), migrations.AddField( - model_name='countrytaggedsectorandmarketpromo', + model_name='countrytaggedsectorandmarketcard', name='tag', field=models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, related_name='+', to='core.countrytag' diff --git a/core/migrations/0162_alter_sectorandmarketcard_meta_label.py b/core/migrations/0162_alter_sectorandmarketcard_meta_label.py new file mode 100644 index 0000000000..5572ae1f6e --- /dev/null +++ b/core/migrations/0162_alter_sectorandmarketcard_meta_label.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2.15 on 2024-10-02 14:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0161_countrytaggedsectorandmarketcard_sectorandmarketcard_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='sectorandmarketcard', + name='meta_label', + field=models.CharField( + blank=True, + choices=[ + ('guidance_great', 'Guidance on great.gov.uk'), + ('service_great', 'Service on great.gov.uk'), + ('guidance_gov', 'Guidance on GOV.UK'), + ('service_gov', 'Service on GOV.UK'), + ], + max_length=255, + ), + ), + ] diff --git a/core/models.py b/core/models.py index 528ffecdf4..6c05b5dadd 100644 --- a/core/models.py +++ b/core/models.py @@ -2531,34 +2531,44 @@ def __str__(self): return self.title -class CountryTaggedSectorAndMarketPromo(ItemBase): +class CountryTaggedSectorAndMarketCard(ItemBase): tag = models.ForeignKey(CountryTag, related_name='+', on_delete=models.CASCADE) - content_object = ParentalKey(to='SectorAndMarketPromo', on_delete=models.CASCADE) + content_object = ParentalKey(to='SectorAndMarketCard', on_delete=models.CASCADE) -class SectorTaggedTaggedSectorAndMarketPromo(ItemBase): +class SectorTaggedTaggedSectorAndMarketCard(ItemBase): tag = models.ForeignKey(SectorTag, related_name='+', on_delete=models.CASCADE) - content_object = ParentalKey(to='SectorAndMarketPromo', on_delete=models.CASCADE) + content_object = ParentalKey(to='SectorAndMarketCard', on_delete=models.CASCADE) @register_snippet -class SectorAndMarketPromo(index.Indexed, ClusterableModel): +class SectorAndMarketCard(index.Indexed, ClusterableModel): title = models.CharField() description = models.TextField() link_text = models.CharField(blank=True) link_url = models.CharField(blank=True) country_tags = TaggableManager( - through=CountryTaggedSectorAndMarketPromo, + through=CountryTaggedSectorAndMarketCard, blank=True, verbose_name='Country tag', related_name='sector_and_market_promo_country_tags', ) sector_tags = TaggableManager( - through=SectorTaggedTaggedSectorAndMarketPromo, + through=SectorTaggedTaggedSectorAndMarketCard, blank=True, verbose_name='Sector tag', related_name='sector_and_market_promo_sector_tags', ) + meta_label = models.CharField( + max_length=255, + choices=( + ('guidance_great', 'Guidance on great.gov.uk'), + ('service_great', 'Service on great.gov.uk'), + ('guidance_gov', 'Guidance on GOV.UK'), + ('service_gov', 'Service on GOV.UK'), + ), + blank=True, + ) panels = [ FieldPanel('title'), @@ -2567,6 +2577,7 @@ class SectorAndMarketPromo(index.Indexed, ClusterableModel): FieldPanel('link_url'), FieldPanel('country_tags'), FieldPanel('sector_tags'), + FieldPanel('meta_label'), ] search_fields = [ diff --git a/domestic/helpers.py b/domestic/helpers.py index 534de0b43b..b721f40c06 100644 --- a/domestic/helpers.py +++ b/domestic/helpers.py @@ -3,7 +3,7 @@ from directory_forms_api_client import actions from django.conf import settings -from core.models import CuratedListPage, DetailPage, SectorAndMarketPromo +from core.models import CuratedListPage, DetailPage, SectorAndMarketCard from domestic import models as domestic_models from sso import helpers as sso_helpers @@ -162,10 +162,10 @@ def get_sector_widget_data_helper(sector): def get_sector_and_market_promo_data_helper(sector, market): return { - 'market_matches': SectorAndMarketPromo.objects.filter( + 'market_matches': SectorAndMarketCard.objects.filter( country_tags__name__contains=market, ), - 'sector_and_market_matches': SectorAndMarketPromo.objects.filter( + 'sector_and_market_matches': SectorAndMarketCard.objects.filter( country_tags__name__contains=market, sector_tags__name__contains=sector, ),