From e9ed141b5019e12848e4cc3543ff36601810fc29 Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Mon, 23 Jan 2023 18:38:51 -0700 Subject: [PATCH 1/4] Fix mobile display of products on subscription form --- static/styles/main.css | 10 +++++++++- .../templates/storefront/subscription/form.html | 12 +++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/static/styles/main.css b/static/styles/main.css index d8d8b12..ad56e52 100644 --- a/static/styles/main.css +++ b/static/styles/main.css @@ -779,13 +779,21 @@ article + article { } .subscription-coffee div { - text-align: center; + min-width: 12rem; + display: flex; + flex-direction: column; + align-items: center; + gap: 1rem; } .subscription-coffee img { max-height: 300px; } +.subscription-coffee input[type=number] { + width: 100%; +} + .subscription-products { display: flex; gap: 2rem; diff --git a/storefront/templates/storefront/subscription/form.html b/storefront/templates/storefront/subscription/form.html index 17b1e18..0ac2452 100644 --- a/storefront/templates/storefront/subscription/form.html +++ b/storefront/templates/storefront/subscription/form.html @@ -18,13 +18,11 @@
{% for product in product_list %}
- - - +
+ +
+ {{ product }} +
{% endfor %}
From f878717c1dd5538ab9addd11313a64888add3e36 Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Mon, 23 Jan 2023 18:39:35 -0700 Subject: [PATCH 2/4] Remove obsolete page --- .../templates/storefront/subscriptions.html | 68 ------------------- 1 file changed, 68 deletions(-) delete mode 100644 storefront/templates/storefront/subscriptions.html diff --git a/storefront/templates/storefront/subscriptions.html b/storefront/templates/storefront/subscriptions.html deleted file mode 100644 index 73ffb92..0000000 --- a/storefront/templates/storefront/subscriptions.html +++ /dev/null @@ -1,68 +0,0 @@ -{% extends 'base.html' %} -{% load static %} - -{% block head %} - - - -{% endblock %} - -{% block content %} -
-

Subscriptions

-

SUBSCRIBE AND SAVE

-
-
-
-
- {% csrf_token %} -
-

Pick your coffee

-
- {% for product in product_list %} -
- - - - - -
- {% endfor %} -
-
-
-

Pick your options

- {{ form.as_p }} -
- - - - - - - - - - - - - -
Retail total
Save10%
Subscription total
-
-

-

- -

-
-
-
-
-{% endblock %} From b806160e9da29c58a08284f76b4369e2e50fb29a Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Mon, 23 Jan 2023 20:48:07 -0700 Subject: [PATCH 3/4] Update allowed hosts default setting --- ptcoffee/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ptcoffee/settings.py b/ptcoffee/settings.py index af8c72b..f38cd99 100644 --- a/ptcoffee/settings.py +++ b/ptcoffee/settings.py @@ -40,7 +40,7 @@ SECRET_KEY = env( # SECURITY WARNING: don't run with debug turned on in production! DEBUG = env.bool('DEBUG', True) -ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', ['localhost']) +ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', ['*']) INTERNAL_IPS = ['127.0.0.1', '10.0.2.2' '172.27.0.4'] From c7f256c5bce76bb1eca702095fabc8666c179f4e Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Tue, 24 Jan 2023 17:24:24 -0700 Subject: [PATCH 4/4] Add unique constraint to address --- .../0002_address_accounts_address_all_key.py | 17 +++++++++++++++++ accounts/models.py | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 accounts/migrations/0002_address_accounts_address_all_key.py diff --git a/accounts/migrations/0002_address_accounts_address_all_key.py b/accounts/migrations/0002_address_accounts_address_all_key.py new file mode 100644 index 0000000..b8ef7b4 --- /dev/null +++ b/accounts/migrations/0002_address_accounts_address_all_key.py @@ -0,0 +1,17 @@ +# Generated by Django 4.1.5 on 2023-01-25 00:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0001_initial'), + ] + + operations = [ + migrations.AddConstraint( + model_name='address', + constraint=models.UniqueConstraint(fields=('first_name', 'last_name', 'street_address_1', 'street_address_2', 'city', 'state', 'postal_code'), name='accounts_address_all_key', violation_error_message='Duplicate: Address already exists.'), + ), + ] diff --git a/accounts/models.py b/accounts/models.py index f800495..63ef944 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -46,6 +46,23 @@ class Address(models.Model): yield ('postal_code', self.postal_code), yield ('country_code', 'US') + class Meta: + constraints = [ + models.UniqueConstraint( + name='accounts_address_all_key', + fields=[ + 'first_name', + 'last_name', + 'street_address_1', + 'street_address_2', + 'city', + 'state', + 'postal_code' + ], + violation_error_message='Duplicate: Address already exists.' + ) + ] + class User(AbstractUser): addresses = models.ManyToManyField(