From c980479d6c3a1763dbe875c7a9995b15b59505f3 Mon Sep 17 00:00:00 2001 From: Matthew Northcott Date: Wed, 29 Mar 2023 16:37:39 +1300 Subject: [PATCH] Small fixes and updates --- backend/.dockerignore | 1 + backend/requirements.txt | 2 +- backend/right_tree/api/__init__.py | 3 +++ backend/right_tree/api/celery.py | 7 ++++++- .../0016_alter_activationkey_key_set.py | 19 +++++++++++++++++++ backend/right_tree/api/models.py | 2 +- backend/right_tree/api/views.py | 2 +- backend/right_tree/settings.py | 1 - 8 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 backend/right_tree/api/migrations/0016_alter_activationkey_key_set.py diff --git a/backend/.dockerignore b/backend/.dockerignore index 04a9a55..a6e6b58 100644 --- a/backend/.dockerignore +++ b/backend/.dockerignore @@ -1,3 +1,4 @@ __pycache__/ staticfiles/ +media/ *.pyc diff --git a/backend/requirements.txt b/backend/requirements.txt index 665e255..2817ef1 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -8,6 +8,6 @@ gunicorn==20.1.0 pandas==1.5.3 pdfkit==1.0.0 PyPDF2==1.28.6 -redis==4.5.1 +redis==4.5.3 celery[redis]==5.2.7 stripe==5.2.0 diff --git a/backend/right_tree/api/__init__.py b/backend/right_tree/api/__init__.py index e69de29..53f4ccb 100644 --- a/backend/right_tree/api/__init__.py +++ b/backend/right_tree/api/__init__.py @@ -0,0 +1,3 @@ +from .celery import app as celery_app + +__all__ = ("celery_app",) diff --git a/backend/right_tree/api/celery.py b/backend/right_tree/api/celery.py index 8007ec8..b4e7f42 100644 --- a/backend/right_tree/api/celery.py +++ b/backend/right_tree/api/celery.py @@ -1,5 +1,10 @@ +import os + from celery import Celery -app = Celery('righttree') + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'right_tree.settings') + +app = Celery('right_tree') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() diff --git a/backend/right_tree/api/migrations/0016_alter_activationkey_key_set.py b/backend/right_tree/api/migrations/0016_alter_activationkey_key_set.py new file mode 100644 index 0000000..258b50b --- /dev/null +++ b/backend/right_tree/api/migrations/0016_alter_activationkey_key_set.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.17 on 2023-03-29 03:36 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0015_auto_20230306_1620'), + ] + + operations = [ + migrations.AlterField( + model_name='activationkey', + name='key_set', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='api.activationkeyset'), + ), + ] diff --git a/backend/right_tree/api/models.py b/backend/right_tree/api/models.py index 8814c35..281a348 100644 --- a/backend/right_tree/api/models.py +++ b/backend/right_tree/api/models.py @@ -222,7 +222,7 @@ class ActivationKey(models.Model): ) key = models.CharField(max_length=20, unique=True, default=key_default) - key_set = models.ForeignKey(ActivationKeySet, on_delete=models.CASCADE, null=True) + key_set = models.ForeignKey(ActivationKeySet, on_delete=models.PROTECT, null=True) remaining_activations = models.SmallIntegerField(default=1) creation_date = models.DateTimeField(auto_now_add=True) diff --git a/backend/right_tree/api/views.py b/backend/right_tree/api/views.py index 5d0fa52..41baaca 100644 --- a/backend/right_tree/api/views.py +++ b/backend/right_tree/api/views.py @@ -239,7 +239,7 @@ def purchase_key(request): invoice_creation={ 'enabled': True, 'invoice_data': { - 'description': f'Your product code is {key}', + 'description': f'Your activation key is {key}', 'rendering_options': {'amount_tax_display': 'include_inclusive_tax'}, 'footer': 'BioSphere Capital Limited', }, diff --git a/backend/right_tree/settings.py b/backend/right_tree/settings.py index cf96f59..a5ef862 100644 --- a/backend/right_tree/settings.py +++ b/backend/right_tree/settings.py @@ -11,7 +11,6 @@ https://docs.djangoproject.com/en/3.2/ref/settings/ """ import os -import stripe from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'.