diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index acf4a9b..0ea0d25 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -2,12 +2,12 @@ name: pull-request on: pull_request: branches: - - main + - production jobs: lint-and-test: runs-on: ubuntu-latest container: - image: ghcr.io/commonknowledge/do-app-baseimage-django-node:364385f9d196a2bbe2d5faea025520cc0316501f + image: ghcr.io/commonknowledge/do-app-baseimage-django-node:6afc34140c9df175f6df73e9d7450dae48050eaf # Workaround for: https://github.com/actions/checkout/issues/211 options: --user 1001 volumes: diff --git a/app/middleware.py b/app/middleware.py index b9d0154..40ca520 100644 --- a/app/middleware.py +++ b/app/middleware.py @@ -28,22 +28,14 @@ def update_stripe_customer_subscription(get_response): # One-time configuration and initialization. def middleware(request): - stripeless_request = ( - request.path.startswith(settings.STATIC_URL) - or request.path.startswith(settings.MEDIA_URL) - or request.path.startswith("/anonymous/") - or settings.SHOPIFY_WEBHOOK_PATH in request.path - or settings.SHOPIFY_WEBHOOK_PATH == request.path - or request.path.startswith("/admin/") - or request.path.startswith("/django/") - or request.path.startswith("/oauth/") - or request.path.startswith("/documents/") - or request.path.startswith("/silk/") - or request.path.startswith("/__debug__/") - or "favicon.ico" in request.path + membership_request = ( + "checkout/success" in request.path + or "accounts/cancel" in request.path + or "gift/redeemed" in request.path + or "update-membership/success" in request.path ) - if not stripeless_request: + if membership_request: # Code to be executed for each request before # the view (and later middleware) are called. if request.user.is_authenticated: diff --git a/app/migrations/0065_alter_upsellplansettings_options_and_more.py b/app/migrations/0065_alter_upsellplansettings_options_and_more.py index 1b73deb..b611e4f 100644 --- a/app/migrations/0065_alter_upsellplansettings_options_and_more.py +++ b/app/migrations/0065_alter_upsellplansettings_options_and_more.py @@ -1,34 +1,40 @@ # Generated by Django 4.0.8 on 2023-03-21 12:49 import django.core.validators -from django.db import migrations, models import wagtail.fields +from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('app', '0064_reviewfeesettings_donation_text_and_more'), + ("app", "0064_reviewfeesettings_donation_text_and_more"), ] operations = [ migrations.AlterModelOptions( - name='upsellplansettings', - options={'verbose_name': 'Review Fee Settings'}, + name="upsellplansettings", + options={"verbose_name": "Review Fee Settings"}, ), migrations.AddField( - model_name='upsellplansettings', - name='upgrade_membership_text', - field=wagtail.fields.RichTextField(default='\n

Here is some text that can be edited blah blah blah

\n '), + model_name="upsellplansettings", + name="upgrade_membership_text", + field=wagtail.fields.RichTextField( + default="\n

Here is some text that can be edited blah blah blah

\n " + ), ), migrations.AlterField( - model_name='membershipplanpage', - name='deliveries_per_year', - field=models.PositiveIntegerField(default=0, validators=[django.core.validators.MinValueValidator(0)]), + model_name="membershipplanpage", + name="deliveries_per_year", + field=models.PositiveIntegerField( + default=0, validators=[django.core.validators.MinValueValidator(0)] + ), ), migrations.AlterField( - model_name='upsellplansettings', - name='intro_text', - field=wagtail.fields.RichTextField(default='\n

Review your fee

\n

Since you signed up, our operating costs have increased dramatically due to the economic times we’re all living through.

\n

We’ve increased the price of new memberships and protected your fee, but we are beginning to struggle. Can you afford to increase your membership fee?

\n '), + model_name="upsellplansettings", + name="intro_text", + field=wagtail.fields.RichTextField( + default="\n

Review your fee

\n

Since you signed up, our operating costs have increased dramatically due to the economic times we’re all living through.

\n

We’ve increased the price of new memberships and protected your fee, but we are beginning to struggle. Can you afford to increase your membership fee?

\n " + ), ), ] diff --git a/app/migrations/0066_alter_upsellplansettings_upgrade_membership_text.py b/app/migrations/0066_alter_upsellplansettings_upgrade_membership_text.py index 482200f..66b448e 100644 --- a/app/migrations/0066_alter_upsellplansettings_upgrade_membership_text.py +++ b/app/migrations/0066_alter_upsellplansettings_upgrade_membership_text.py @@ -1,19 +1,21 @@ # Generated by Django 4.0.8 on 2023-07-18 14:33 -from django.db import migrations import wagtail.fields +from django.db import migrations class Migration(migrations.Migration): dependencies = [ - ('app', '0065_alter_upsellplansettings_options_and_more'), + ("app", "0065_alter_upsellplansettings_options_and_more"), ] operations = [ migrations.AlterField( - model_name='upsellplansettings', - name='upgrade_membership_text', - field=wagtail.fields.RichTextField(default='\n

You’re currently paying {{ old_price }}. Select this option if it’s all you can afford right now — that is totally OK.

\n

Other members paying solidarity rates will make it possible for us to continue offering this, so please consider if you can afford to increase your rate or if you genuinely need to stay here.

\n '), + model_name="upsellplansettings", + name="upgrade_membership_text", + field=wagtail.fields.RichTextField( + default="\n

You’re currently paying {{ old_price }}. Select this option if it’s all you can afford right now — that is totally OK.

\n

Other members paying solidarity rates will make it possible for us to continue offering this, so please consider if you can afford to increase your rate or if you genuinely need to stay here.

\n " + ), ), ] diff --git a/app/migrations/0067_remove_bookpage_authors_remove_bookpage_forward_by_and_more.py b/app/migrations/0067_remove_bookpage_authors_remove_bookpage_forward_by_and_more.py index 57c9215..c0c0fe5 100644 --- a/app/migrations/0067_remove_bookpage_authors_remove_bookpage_forward_by_and_more.py +++ b/app/migrations/0067_remove_bookpage_authors_remove_bookpage_forward_by_and_more.py @@ -6,24 +6,24 @@ class Migration(migrations.Migration): dependencies = [ - ('app', '0066_alter_upsellplansettings_upgrade_membership_text'), + ("app", "0066_alter_upsellplansettings_upgrade_membership_text"), ] operations = [ migrations.RemoveField( - model_name='bookpage', - name='authors', + model_name="bookpage", + name="authors", ), migrations.RemoveField( - model_name='bookpage', - name='forward_by', + model_name="bookpage", + name="forward_by", ), migrations.RemoveField( - model_name='bookpage', - name='image_urls', + model_name="bookpage", + name="image_urls", ), migrations.RemoveField( - model_name='merchandisepage', - name='image_urls', + model_name="merchandisepage", + name="image_urls", ), ] diff --git a/app/migrations/0068_bookpage_authors_bookpage_forward_by_and_more.py b/app/migrations/0068_bookpage_authors_bookpage_forward_by_and_more.py index b753e61..66c8115 100644 --- a/app/migrations/0068_bookpage_authors_bookpage_forward_by_and_more.py +++ b/app/migrations/0068_bookpage_authors_bookpage_forward_by_and_more.py @@ -7,28 +7,48 @@ class Migration(migrations.Migration): dependencies = [ - ('app', '0067_remove_bookpage_authors_remove_bookpage_forward_by_and_more'), + ("app", "0067_remove_bookpage_authors_remove_bookpage_forward_by_and_more"), ] operations = [ migrations.AddField( - model_name='bookpage', - name='authors', - field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=300), blank=True, null=True, size=None), + model_name="bookpage", + name="authors", + field=django.contrib.postgres.fields.ArrayField( + base_field=models.CharField(blank=True, max_length=300), + blank=True, + null=True, + size=None, + ), ), migrations.AddField( - model_name='bookpage', - name='forward_by', - field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=300), blank=True, null=True, size=None), + model_name="bookpage", + name="forward_by", + field=django.contrib.postgres.fields.ArrayField( + base_field=models.CharField(blank=True, max_length=300), + blank=True, + null=True, + size=None, + ), ), migrations.AddField( - model_name='bookpage', - name='image_urls', - field=django.contrib.postgres.fields.ArrayField(base_field=models.URLField(blank=True, max_length=500), blank=True, null=True, size=None), + model_name="bookpage", + name="image_urls", + field=django.contrib.postgres.fields.ArrayField( + base_field=models.URLField(blank=True, max_length=500), + blank=True, + null=True, + size=None, + ), ), migrations.AddField( - model_name='merchandisepage', - name='image_urls', - field=django.contrib.postgres.fields.ArrayField(base_field=models.URLField(blank=True, max_length=500), blank=True, null=True, size=None), + model_name="merchandisepage", + name="image_urls", + field=django.contrib.postgres.fields.ArrayField( + base_field=models.URLField(blank=True, max_length=500), + blank=True, + null=True, + size=None, + ), ), ] diff --git a/app/migrations/0082_alter_membershipplanprice_default_donation_amount_currency_and_more.py b/app/migrations/0082_alter_membershipplanprice_default_donation_amount_currency_and_more.py index 0a0c8f8..b52a330 100644 --- a/app/migrations/0082_alter_membershipplanprice_default_donation_amount_currency_and_more.py +++ b/app/migrations/0082_alter_membershipplanprice_default_donation_amount_currency_and_more.py @@ -1,7 +1,7 @@ # Generated by Django 4.2 on 2024-05-16 11:59 -from django.db import migrations import djmoney.models.fields +from django.db import migrations class Migration(migrations.Migration): diff --git a/app/models/wagtail.py b/app/models/wagtail.py index 65378af..ba11cb1 100644 --- a/app/models/wagtail.py +++ b/app/models/wagtail.py @@ -740,7 +740,7 @@ def sync_from_shopify_product_id(cls, shopify_product_id): product = shopify.Product.find(shopify_product_id) metafields = product.metafields() metafields = metafields_to_dict(metafields) - + if cls.objects.filter(shopify_product_id=shopify_product_id).exists(): return cls.update_instance_for_product(product, metafields) else: diff --git a/app/settings/base.py b/app/settings/base.py index 04f274f..1c45100 100644 --- a/app/settings/base.py +++ b/app/settings/base.py @@ -19,8 +19,8 @@ "mathfilters", "djmoney", "anymail", - 'wagtail_rangefilter', - 'rangefilter', + "wagtail_rangefilter", + "rangefilter", "rest_framework", "groundwork.core", "groundwork.geo", @@ -87,8 +87,8 @@ ] MIDDLEWARE += [ - 'django.middleware.security.SecurityMiddleware', - 'whitenoise.middleware.WhiteNoiseMiddleware', + "django.middleware.security.SecurityMiddleware", + "whitenoise.middleware.WhiteNoiseMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", diff --git a/app/templates/account/email.html b/app/templates/account/email.html index 7059c24..58dd706 100644 --- a/app/templates/account/email.html +++ b/app/templates/account/email.html @@ -23,8 +23,8 @@ {% for emailaddress in user.emailaddress_set.all %} -