Skip to content

Commit

Permalink
more linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Moggach committed Sep 4, 2024
1 parent cb65dbd commit 1909e02
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 63 deletions.
8 changes: 4 additions & 4 deletions app/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def update_stripe_customer_subscription(get_response):

def middleware(request):
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
"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 membership_request:
Expand Down
30 changes: 18 additions & 12 deletions app/migrations/0065_alter_upsellplansettings_options_and_more.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,33 @@
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 <p>Here is some text that can be edited blah blah blah</p>\n '),
model_name="upsellplansettings",
name="upgrade_membership_text",
field=wagtail.fields.RichTextField(
default="\n <p>Here is some text that can be edited blah blah blah</p>\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 <h1>Review your fee</h1>\n <p>Since you signed up, our operating costs have increased dramatically due to the economic times we’re all living through.</p>\n <p>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?</p>\n '),
model_name="upsellplansettings",
name="intro_text",
field=wagtail.fields.RichTextField(
default="\n <h1>Review your fee</h1>\n <p>Since you signed up, our operating costs have increased dramatically due to the economic times we’re all living through.</p>\n <p>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?</p>\n "
),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
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 <p>You’re currently paying {{ old_price }}. Select this option if it’s all you can afford right now — that is totally OK.</p>\n <p>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.</p>\n '),
model_name="upsellplansettings",
name="upgrade_membership_text",
field=wagtail.fields.RichTextField(
default="\n <p>You’re currently paying {{ old_price }}. Select this option if it’s all you can afford right now — that is totally OK.</p>\n <p>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.</p>\n "
),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
]
2 changes: 1 addition & 1 deletion app/models/wagtail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions app/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"mathfilters",
"djmoney",
"anymail",
'wagtail_rangefilter',
'rangefilter',
"wagtail_rangefilter",
"rangefilter",
"rest_framework",
"groundwork.core",
"groundwork.geo",
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions app/templatetags/books.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def get_books(since=None, types=None, limit=None):
def get_merch():
return MerchandisePage.objects.live().public()

@register.filter(name='strikethrough')

@register.filter(name="strikethrough")
def strikethrough(text):
"""Convert text to strikethrough using Unicode characters."""
return ''.join(char + '\u0336' for char in str(text))
return "".join(char + "\u0336" for char in str(text))
10 changes: 8 additions & 2 deletions app/utils/books.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ def get_current_book(book_types: Union[None, str, List[str]]):

if len(book_types) > 0 and "all-books" not in book_types:
return (
BookPage.objects.filter(type__in=book_types, published_date__isnull=False)
BookPage.objects.filter(
type__in=book_types, published_date__isnull=False
)
.order_by("-published_date")
.first()
)
return BookPage.objects.filter(published_date__isnull=False).order_by("-published_date").first()
return (
BookPage.objects.filter(published_date__isnull=False)
.order_by("-published_date")
.first()
)
4 changes: 3 additions & 1 deletion app/utils/mailchimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def mailchimp_contact_for_user(user: User, list_id=settings.MAILCHIMP_LIST_ID):
{
"email_address": user.primary_email,
"merge_fields": {"FNAME": user.first_name, "LNAME": user.last_name},
"status": "subscribed" if user.gdpr_email_consent else "unsubscribed",
"status": "subscribed"
if user.gdpr_email_consent
else "unsubscribed",
},
)
member = apply_gdpr_consent(member)
Expand Down
14 changes: 7 additions & 7 deletions app/utils/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,15 @@ def create_gift_recipient_subscription(
promo_code_id, expand=["coupon.applies_to"]
)
if (
hasattr(promo_code.coupon, 'applies_to') and
hasattr(promo_code.coupon.applies_to, 'products') and
product_id in promo_code.coupon.applies_to.products
): # the gift card is fit for purpose
hasattr(promo_code.coupon, "applies_to")
and hasattr(promo_code.coupon.applies_to, "products")
and product_id in promo_code.coupon.applies_to.products
): # the gift card is fit for purpose
discount_args = {"promotion_code": promo_code_id}

else:
# if they're in this situation of the gift card being for an old product
# get the right coupon for the target product
# if they're in this situation of the gift card being for an old product
# get the right coupon for the target product
coupon = get_gift_card_coupon(product_id)
# invalidate the gift card's promo code so it can't be used again
promo_code = stripe.PromotionCode.modify(promo_code_id, active=False)
Expand Down
3 changes: 0 additions & 3 deletions app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@ def get_context_data(self, price_id, product_id, country_id="GB", **kwargs):
}

return context



class SubscriptionCheckoutView(TemplateView):
Expand Down Expand Up @@ -632,7 +631,6 @@ def create_checkout_context(

checkout_args["shipping_address_collection"] = {
"allowed_countries": ShippingZone.all_country_codes

}
next = reverse_lazy("completed_gift_purchase")
else:
Expand Down Expand Up @@ -1298,7 +1296,6 @@ def create_checkout_context(
checkout_args["metadata"]["gift_mode"] = True
checkout_args["shipping_address_collection"] = {
"allowed_countries": ShippingZone.all_country_codes

}
next = reverse_lazy("completed_gift_purchase")
else:
Expand Down
3 changes: 2 additions & 1 deletion app/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class CustomerAdmin(ModelAdmin):
export_filename = "lbc_members"

def get_list_filter(self, request):
if request.GET.get('status') == 'expired':
if request.GET.get("status") == "expired":
return (("ended_at", DateTimeRangeFilter),)
return ()

Expand All @@ -162,6 +162,7 @@ def get_queryset(self, request):
.select_related("plan__product", "customer__subscriber")
)


# Now you just need to register your customised ModelAdmin class with Wagtail
modeladmin_register(CustomerAdmin)

Expand Down

0 comments on commit 1909e02

Please sign in to comment.