From 9685d36f2025bafda38ab40e83d189b68059777a Mon Sep 17 00:00:00 2001 From: Tudor Amariei Date: Sat, 27 Jan 2024 10:50:04 +0200 Subject: [PATCH] Fix migrations and model changes - redo all migrations - change Ngo, Donor imports to use the right source --- backend/donations/admin.py | 2 +- backend/donations/forms.py | 2 +- .../management/commands/generate_orgs.py | 2 +- backend/donations/migrations/0001_initial.py | 313 +++++++----------- .../migrations/0002_alter_ngo_form_url.py | 17 - backend/donations/migrations/0002_initial.py | 31 ++ ...tial_donor_personal_identifier_and_more.py | 30 -- ...ge_ngo_logo_alter_ngo_form_url_and_more.py | 46 --- ...05_rename_personal_identifier_donor_cnp.py | 17 - .../migrations/0006_donor_pdf_file.py | 23 -- ...orm_url_unique_ngo_custom_form_and_more.py | 55 --- backend/donations/models/jobs.py | 10 +- backend/donations/models/main.py | 15 +- backend/donations/views/admin.py | 2 +- backend/donations/views/api.py | 2 +- backend/donations/views/my_account.py | 2 +- backend/donations/views/ngo.py | 2 +- backend/donations/views/site.py | 2 +- backend/partners/migrations/0001_initial.py | 4 +- .../migrations/0002_alter_partner_ngos.py | 18 - backend/partners/models.py | 2 +- backend/users/migrations/0001_initial.py | 62 +--- ..._verified_user_token_timestamp_and_more.py | 28 -- .../migrations/0003_alter_user_username.py | 18 - backend/users/models.py | 2 +- 25 files changed, 201 insertions(+), 506 deletions(-) delete mode 100644 backend/donations/migrations/0002_alter_ngo_form_url.py create mode 100644 backend/donations/migrations/0002_initial.py delete mode 100644 backend/donations/migrations/0003_donor_initial_donor_personal_identifier_and_more.py delete mode 100644 backend/donations/migrations/0004_ngo_image_ngo_logo_alter_ngo_form_url_and_more.py delete mode 100644 backend/donations/migrations/0005_rename_personal_identifier_donor_cnp.py delete mode 100644 backend/donations/migrations/0006_donor_pdf_file.py delete mode 100644 backend/donations/migrations/0007_remove_ngo_form_url_unique_ngo_custom_form_and_more.py delete mode 100644 backend/partners/migrations/0002_alter_partner_ngos.py delete mode 100644 backend/users/migrations/0002_user_is_verified_user_token_timestamp_and_more.py delete mode 100644 backend/users/migrations/0003_alter_user_username.py diff --git a/backend/donations/admin.py b/backend/donations/admin.py index e947e580..20973235 100644 --- a/backend/donations/admin.py +++ b/backend/donations/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from .models import Ngo, Donor +from .models.main import Ngo, Donor from django.utils.translation import gettext_lazy as _ diff --git a/backend/donations/forms.py b/backend/donations/forms.py index 06232c0f..57500773 100644 --- a/backend/donations/forms.py +++ b/backend/donations/forms.py @@ -2,7 +2,7 @@ from django.utils.translation import gettext_lazy as _ from localflavor.ro.forms import ROCNPField -from donations.models import Donor +from donations.models.main import Donor class DonorInputForm(forms.ModelForm): diff --git a/backend/donations/management/commands/generate_orgs.py b/backend/donations/management/commands/generate_orgs.py index cd97b8cd..0d0c65e5 100644 --- a/backend/donations/management/commands/generate_orgs.py +++ b/backend/donations/management/commands/generate_orgs.py @@ -7,7 +7,7 @@ from faker import Faker from localflavor.ro.ro_counties import COUNTIES_CHOICES -from donations.models import Ngo +from donations.models.main import Ngo fake = Faker("ro_RO") diff --git a/backend/donations/migrations/0001_initial.py b/backend/donations/migrations/0001_initial.py index 3e10828e..f4304800 100644 --- a/backend/donations/migrations/0001_initial.py +++ b/backend/donations/migrations/0001_initial.py @@ -1,7 +1,11 @@ -# Generated by Django 4.2.7 on 2023-11-24 14:31 +# Generated by Django 4.2.9 on 2024-01-27 08:54 from django.db import migrations, models import django.db.models.deletion +import django.db.models.functions.text +import django_cryptography.fields +import donations.models.main +import functools class Migration(migrations.Migration): @@ -11,263 +15,188 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name="Ngo", + name="Donor", fields=[ + ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), + ("first_name", models.CharField(blank=True, default="", max_length=100, verbose_name="first name")), + ("last_name", models.CharField(blank=True, default="", max_length=100, verbose_name="last name")), + ("initial", models.CharField(blank=True, default="", max_length=5, verbose_name="initials")), ( - "id", - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ( - "name", - models.CharField( - db_index=True, max_length=100, verbose_name="Name" + "cnp", + django_cryptography.fields.encrypt( + models.CharField(blank=True, default="", max_length=13, verbose_name="CNP") ), ), - ("description", models.TextField(verbose_name="description")), - ( - "logo_url", - models.URLField(blank=True, default="", verbose_name="logo url"), - ), - ( - "image_url", - models.URLField(blank=True, default="", verbose_name="image url"), - ), - ( - "bank_account", - models.CharField(max_length=100, verbose_name="bank account"), - ), - ( - "registration_number", - models.CharField( - db_index=True, - max_length=100, - unique=True, - verbose_name="registration number", - ), - ), - ( - "address", - models.TextField(blank=True, default="", verbose_name="address"), - ), + ("city", models.CharField(blank=True, db_index=True, default="", max_length=100, verbose_name="city")), ( "county", - models.CharField( - blank=True, - db_index=True, - default="", - max_length=100, - verbose_name="county", - ), + models.CharField(blank=True, db_index=True, default="", max_length=100, verbose_name="county"), ), + ("phone", models.CharField(blank=True, default="", max_length=30, verbose_name="telephone")), + ("email", models.EmailField(db_index=True, max_length=254, verbose_name="email")), ( - "active_region", - models.CharField( - blank=True, + "is_anonymous", + models.BooleanField( db_index=True, - default="", - max_length=100, - verbose_name="active region", + default=True, + help_text="If the user would like the ngo to see the donation", + verbose_name="anonymous", ), ), ( - "phone", + "income_type", models.CharField( - blank=True, default="", max_length=30, verbose_name="telephone" - ), - ), - ( - "email", - models.EmailField( blank=True, - db_index=True, - default="", - max_length=254, - verbose_name="email", - ), - ), - ( - "website", - models.URLField(blank=True, default="", verbose_name="website"), - ), - ( - "other_emails", - models.TextField( - blank=True, default="", verbose_name="other emails" - ), - ), - ( - "is_verified", - models.BooleanField( - db_index=True, default=False, verbose_name="is verified" - ), - ), - ( - "has_special_status", - models.BooleanField( - db_index=True, default=False, verbose_name="has special status" - ), - ), - ( - "is_accepting_forms", - models.BooleanField( - db_index=True, default=False, verbose_name="is accepting forms" + choices=[("wage", "wage"), ("pension", "pension")], + default="wage", + max_length=30, + verbose_name="income type", ), ), ( - "is_active", + "two_years", models.BooleanField( - db_index=True, default=True, verbose_name="is active" + default=False, help_text="If the user wants to donate for 2 years", verbose_name="two years" ), ), + ("geoip", models.JSONField(blank=True, default=dict, verbose_name="Geo IP")), + ("pdf_url", models.URLField(blank=True, default="", max_length=255, verbose_name="PDF URL")), + ("filename", models.CharField(blank=True, default="", max_length=100, verbose_name="filename")), + ("has_signed", models.BooleanField(db_index=True, default=False, verbose_name="has signed")), ( - "form_url", - models.URLField( - blank=True, default="", max_length=255, verbose_name="form url" - ), - ), - ( - "date_created", - models.DateTimeField( - auto_now_add=True, db_index=True, verbose_name="date created" + "pdf_file", + models.FileField( + blank=True, + upload_to=functools.partial(donations.models.main.year_directory_path, *("documents",), **{}), + verbose_name="PDF file", ), ), + ("date_created", models.DateTimeField(auto_now_add=True, db_index=True, verbose_name="date created")), ], options={ - "verbose_name": "NGO", - "verbose_name_plural": "NGOs", + "verbose_name": "donor", + "verbose_name_plural": "donors", }, ), migrations.CreateModel( - name="Donor", + name="Job", fields=[ + ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ( - "id", - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", + "status", + models.CharField( + choices=[("new", "New"), ("error", "Error"), ("done", "Done")], + db_index=True, + default="new", + max_length=5, + verbose_name="status", ), ), + ("url", models.URLField(blank=True, default="", max_length=255, verbose_name="URL")), + ("date_created", models.DateTimeField(auto_now_add=True, db_index=True, verbose_name="date created")), + ], + ), + migrations.CreateModel( + name="Ngo", + fields=[ + ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ( - "first_name", - models.CharField( - blank=True, - default="", + "slug", + models.SlugField( max_length=100, - verbose_name="first name", + unique=True, + validators=[donations.models.main.ngo_slug_validator], + verbose_name="slug", ), ), + ("name", models.CharField(db_index=True, max_length=100, verbose_name="Name")), + ("description", models.TextField(verbose_name="description")), + ("logo_url", models.URLField(blank=True, default="", verbose_name="logo url")), ( - "last_name", - models.CharField( - blank=True, default="", max_length=100, verbose_name="last name" + "logo", + models.ImageField( + blank=True, + storage=donations.models.main.select_public_storage, + upload_to=functools.partial(donations.models.main.ngo_directory_path, *("logos",), **{}), + verbose_name="logo", ), ), + ("image_url", models.URLField(blank=True, default="", verbose_name="image url")), ( - "city", - models.CharField( + "image", + models.ImageField( blank=True, - db_index=True, - default="", - max_length=100, - verbose_name="city", + storage=donations.models.main.select_public_storage, + upload_to=functools.partial(donations.models.main.ngo_directory_path, *("images",), **{}), + verbose_name="image", ), ), + ("bank_account", models.CharField(max_length=100, verbose_name="bank account")), ( - "county", + "registration_number", models.CharField( - blank=True, db_index=True, - default="", max_length=100, - verbose_name="county", - ), - ), - ( - "email", - models.EmailField( - db_index=True, max_length=254, verbose_name="email" - ), - ), - ( - "phone", - models.CharField( - blank=True, default="", max_length=30, verbose_name="telephone" + unique=True, + validators=[donations.models.main.ngo_id_number_validator], + verbose_name="registration number", ), ), + ("address", models.TextField(blank=True, default="", verbose_name="address")), ( - "is_anonymous", - models.BooleanField( - db_index=True, - default=True, - help_text="If the user would like the ngo to see the donation", - verbose_name="anonymous", - ), + "county", + models.CharField(blank=True, db_index=True, default="", max_length=100, verbose_name="county"), ), ( - "income_type", + "active_region", models.CharField( - blank=True, - choices=[("wage", "wage"), ("pension", "pension")], - default="wage", - max_length=30, - verbose_name="income type", - ), - ), - ( - "two_years", - models.BooleanField( - default=False, - help_text="If the user wants to donate for 2 years", - verbose_name="two years", - ), - ), - ( - "geoip", - models.JSONField(blank=True, default=dict, verbose_name="Geo IP"), - ), - ( - "pdf_url", - models.URLField( - blank=True, default="", max_length=255, verbose_name="PDF URL" + blank=True, db_index=True, default="", max_length=100, verbose_name="active region" ), ), + ("phone", models.CharField(blank=True, default="", max_length=30, verbose_name="telephone")), ( - "filename", - models.CharField( - blank=True, default="", max_length=100, verbose_name="filename" - ), + "email", + models.EmailField(blank=True, db_index=True, default="", max_length=254, verbose_name="email"), ), + ("website", models.URLField(blank=True, default="", verbose_name="website")), + ("other_emails", models.TextField(blank=True, default="", verbose_name="other emails")), + ("is_verified", models.BooleanField(db_index=True, default=False, verbose_name="is verified")), ( - "has_signed", - models.BooleanField( - db_index=True, default=False, verbose_name="has signed" - ), + "has_special_status", + models.BooleanField(db_index=True, default=False, verbose_name="has special status"), ), ( - "date_created", - models.DateTimeField( - auto_now_add=True, db_index=True, verbose_name="date created" - ), + "is_accepting_forms", + models.BooleanField(db_index=True, default=False, verbose_name="is accepting forms"), ), + ("is_active", models.BooleanField(db_index=True, default=True, verbose_name="is active")), + ("form_url", models.URLField(blank=True, default="", max_length=255, verbose_name="form url")), ( - "ngo", - models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, - to="donations.ngo", - verbose_name="NGO", + "custom_form", + models.FileField( + blank=True, + storage=donations.models.main.select_public_storage, + upload_to=functools.partial(donations.models.main.ngo_directory_path, *("forms",), **{}), + verbose_name="form with ngo data", ), ), + ("date_created", models.DateTimeField(auto_now_add=True, db_index=True, verbose_name="date created")), + ("date_updated", models.DateTimeField(auto_now=True, db_index=True, verbose_name="date updated")), ], options={ - "verbose_name": "donor", - "verbose_name_plural": "donors", + "verbose_name": "NGO", + "verbose_name_plural": "NGOs", }, ), + migrations.AddConstraint( + model_name="ngo", + constraint=models.UniqueConstraint(django.db.models.functions.text.Lower("slug"), name="slug__unique"), + ), + migrations.AddField( + model_name="job", + name="ngo", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="donations.ngo", verbose_name="NGO" + ), + ), ] diff --git a/backend/donations/migrations/0002_alter_ngo_form_url.py b/backend/donations/migrations/0002_alter_ngo_form_url.py deleted file mode 100644 index cfaf8239..00000000 --- a/backend/donations/migrations/0002_alter_ngo_form_url.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 4.2.8 on 2024-01-03 16:20 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("donations", "0001_initial"), - ] - - operations = [ - migrations.AlterField( - model_name="ngo", - name="form_url", - field=models.CharField(blank=True, default="", max_length=255, verbose_name="form url"), - ), - ] diff --git a/backend/donations/migrations/0002_initial.py b/backend/donations/migrations/0002_initial.py new file mode 100644 index 00000000..24280cd7 --- /dev/null +++ b/backend/donations/migrations/0002_initial.py @@ -0,0 +1,31 @@ +# Generated by Django 4.2.9 on 2024-01-27 08:54 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ("donations", "0001_initial"), + ] + + operations = [ + migrations.AddField( + model_name="job", + name="owner", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name="owner" + ), + ), + migrations.AddField( + model_name="donor", + name="ngo", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="donations.ngo", verbose_name="NGO" + ), + ), + ] diff --git a/backend/donations/migrations/0003_donor_initial_donor_personal_identifier_and_more.py b/backend/donations/migrations/0003_donor_initial_donor_personal_identifier_and_more.py deleted file mode 100644 index 589d0538..00000000 --- a/backend/donations/migrations/0003_donor_initial_donor_personal_identifier_and_more.py +++ /dev/null @@ -1,30 +0,0 @@ -# Generated by Django 4.2.9 on 2024-01-04 13:58 - -from django.db import migrations, models -import django_cryptography.fields - - -class Migration(migrations.Migration): - dependencies = [ - ("donations", "0002_alter_ngo_form_url"), - ] - - operations = [ - migrations.AddField( - model_name="donor", - name="initial", - field=models.CharField(blank=True, default="", max_length=5, verbose_name="initials"), - ), - migrations.AddField( - model_name="donor", - name="personal_identifier", - field=django_cryptography.fields.encrypt( - models.CharField(blank=True, default="", max_length=13, verbose_name="CNP") - ), - ), - migrations.AlterField( - model_name="ngo", - name="form_url", - field=models.CharField(blank=True, default="", max_length=255, unique=True, verbose_name="form url"), - ), - ] diff --git a/backend/donations/migrations/0004_ngo_image_ngo_logo_alter_ngo_form_url_and_more.py b/backend/donations/migrations/0004_ngo_image_ngo_logo_alter_ngo_form_url_and_more.py deleted file mode 100644 index 31002929..00000000 --- a/backend/donations/migrations/0004_ngo_image_ngo_logo_alter_ngo_form_url_and_more.py +++ /dev/null @@ -1,46 +0,0 @@ -# Generated by Django 4.2.9 on 2024-01-10 04:54 - -from django.db import migrations, models -import django.db.models.functions.text -import donations.models -import functools - - -class Migration(migrations.Migration): - dependencies = [ - ("donations", "0003_donor_initial_donor_personal_identifier_and_more"), - ] - - operations = [ - migrations.AddField( - model_name="ngo", - name="image", - field=models.ImageField( - blank=True, - storage=donations.models.select_public_storage, - upload_to=functools.partial(donations.models.ngo_directory_path, *("images",), **{}), - verbose_name="image", - ), - ), - migrations.AddField( - model_name="ngo", - name="logo", - field=models.ImageField( - blank=True, - storage=donations.models.select_public_storage, - upload_to=functools.partial(donations.models.ngo_directory_path, *("logos",), **{}), - verbose_name="logo", - ), - ), - migrations.AlterField( - model_name="ngo", - name="form_url", - field=models.SlugField(max_length=100, null=True, unique=True, verbose_name="form url"), - ), - migrations.AddConstraint( - model_name="ngo", - constraint=models.UniqueConstraint( - django.db.models.functions.text.Lower("form_url"), name="form_url_unique" - ), - ), - ] diff --git a/backend/donations/migrations/0005_rename_personal_identifier_donor_cnp.py b/backend/donations/migrations/0005_rename_personal_identifier_donor_cnp.py deleted file mode 100644 index c699eb38..00000000 --- a/backend/donations/migrations/0005_rename_personal_identifier_donor_cnp.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 4.2.9 on 2024-01-10 06:07 - -from django.db import migrations - - -class Migration(migrations.Migration): - dependencies = [ - ("donations", "0004_ngo_image_ngo_logo_alter_ngo_form_url_and_more"), - ] - - operations = [ - migrations.RenameField( - model_name="donor", - old_name="personal_identifier", - new_name="cnp", - ), - ] diff --git a/backend/donations/migrations/0006_donor_pdf_file.py b/backend/donations/migrations/0006_donor_pdf_file.py deleted file mode 100644 index 3948a09e..00000000 --- a/backend/donations/migrations/0006_donor_pdf_file.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.2.9 on 2024-01-11 05:34 - -from django.db import migrations, models -import donations.models -import functools - - -class Migration(migrations.Migration): - dependencies = [ - ("donations", "0005_rename_personal_identifier_donor_cnp"), - ] - - operations = [ - migrations.AddField( - model_name="donor", - name="pdf_file", - field=models.FileField( - blank=True, - upload_to=functools.partial(donations.models.year_directory_path, *("documents",), **{}), - verbose_name="PDF file", - ), - ), - ] diff --git a/backend/donations/migrations/0007_remove_ngo_form_url_unique_ngo_custom_form_and_more.py b/backend/donations/migrations/0007_remove_ngo_form_url_unique_ngo_custom_form_and_more.py deleted file mode 100644 index d07bf96c..00000000 --- a/backend/donations/migrations/0007_remove_ngo_form_url_unique_ngo_custom_form_and_more.py +++ /dev/null @@ -1,55 +0,0 @@ -# Generated by Django 4.2.9 on 2024-01-11 11:38 - -from django.db import migrations, models -import django.db.models.functions.text -import donations.models -import functools - - -class Migration(migrations.Migration): - dependencies = [ - ("donations", "0006_donor_pdf_file"), - ] - - operations = [ - migrations.RemoveConstraint( - model_name="ngo", - name="form_url_unique", - ), - migrations.AddField( - model_name="ngo", - name="custom_form", - field=models.FileField( - blank=True, - storage=donations.models.select_public_storage, - upload_to=functools.partial(donations.models.ngo_directory_path, *("forms",), **{}), - verbose_name="form with ngo data", - ), - ), - migrations.AddField( - model_name="ngo", - name="date_updated", - field=models.DateTimeField(auto_now=True, db_index=True, verbose_name="date updated"), - ), - migrations.AddField( - model_name="ngo", - name="slug", - field=models.SlugField( - default="", - max_length=100, - unique=True, - validators=[donations.models.ngo_identifier_validator], - verbose_name="slug", - ), - preserve_default=False, - ), - migrations.AlterField( - model_name="ngo", - name="form_url", - field=models.URLField(blank=True, default="", max_length=255, verbose_name="form url"), - ), - migrations.AddConstraint( - model_name="ngo", - constraint=models.UniqueConstraint(django.db.models.functions.text.Lower("slug"), name="slug__unique"), - ), - ] diff --git a/backend/donations/models/jobs.py b/backend/donations/models/jobs.py index db4c4794..836b8c27 100644 --- a/backend/donations/models/jobs.py +++ b/backend/donations/models/jobs.py @@ -6,6 +6,12 @@ from users.models import User +class JobStatusChoices(models.TextChoices): + NEW = "new", _("New") + ERROR = "error", _("Error") + DONE = "done", _("Done") + + class Job(models.Model): """Keep track for download jobs""" @@ -15,8 +21,8 @@ class Job(models.Model): verbose_name=_("status"), blank=False, null=False, - default="new", - choices=("new", "error", "done"), + default=JobStatusChoices.NEW, + choices=JobStatusChoices.choices, max_length=5, db_index=True, ) diff --git a/backend/donations/models/main.py b/backend/donations/models/main.py index 757cbb0d..c9fbcc76 100644 --- a/backend/donations/models/main.py +++ b/backend/donations/models/main.py @@ -27,17 +27,23 @@ def year_directory_path(subdir, instance, filename) -> str: return "{0}/{1}/{2}/{3}".format(subdir, timestamp.date().year, instance.pk, filename) -def ngo_identifier_validator(value): - valid_identifier_sample: str = "asociatia-de-exemplu" +def ngo_slug_validator(value): + valid_slug_sample: str = "asociatia-de-exemplu" error_message = _("%(value)s is not a valid identifier. The identifier must look like %(sample)s") % { "value": value, - "sample": valid_identifier_sample, + "sample": valid_slug_sample, } if not value.islower(): raise ValidationError(error_message) +def ngo_id_number_validator(value): + error_message = _("The ID number must be 8 digits long") + if len(value) != 8: + raise ValidationError(error_message) + + class Ngo(models.Model): # DEFAULT_NGO_LOGO = "https://storage.googleapis.com/redirectioneaza/logo_bw.png" @@ -48,7 +54,7 @@ class Ngo(models.Model): max_length=100, db_index=True, unique=True, - validators=[ngo_identifier_validator], + validators=[ngo_slug_validator], ) name = models.CharField(verbose_name=_("Name"), blank=False, null=False, max_length=100, db_index=True) @@ -85,6 +91,7 @@ class Ngo(models.Model): blank=False, null=False, unique=True, + validators=[ngo_id_number_validator], ) address = models.TextField(verbose_name=_("address"), blank=True, null=False, default="") diff --git a/backend/donations/views/admin.py b/backend/donations/views/admin.py index 5c9b5851..649ff238 100644 --- a/backend/donations/views/admin.py +++ b/backend/donations/views/admin.py @@ -12,7 +12,7 @@ from users.models import User from .base import BaseHandler -from ..models import Ngo, Donor +from ..models.main import Ngo, Donor logger = logging.getLogger(__name__) diff --git a/backend/donations/views/api.py b/backend/donations/views/api.py index 56dad66e..2fd5abe7 100644 --- a/backend/donations/views/api.py +++ b/backend/donations/views/api.py @@ -10,7 +10,7 @@ from django.urls import reverse from django.utils.decorators import method_decorator -from ..models import Ngo +from ..models.main import Ngo from ..models.jobs import Job from .base import BaseHandler, AccountHandler diff --git a/backend/donations/views/my_account.py b/backend/donations/views/my_account.py index 46bd0dba..4ed3cab4 100644 --- a/backend/donations/views/my_account.py +++ b/backend/donations/views/my_account.py @@ -9,7 +9,7 @@ from django.utils.decorators import method_decorator from .base import AccountHandler -from ..models import Donor, Ngo +from ..models.main import Donor, Ngo class MyAccountDetailsHandler(AccountHandler): diff --git a/backend/donations/views/ngo.py b/backend/donations/views/ngo.py index e8930a10..807987e5 100644 --- a/backend/donations/views/ngo.py +++ b/backend/donations/views/ngo.py @@ -11,7 +11,7 @@ from django.utils import timezone from .base import BaseHandler -from ..models import Donor, Ngo +from ..models.main import Donor, Ngo from ..pdf import create_pdf diff --git a/backend/donations/views/site.py b/backend/donations/views/site.py index 7cd50896..6a25f5be 100644 --- a/backend/donations/views/site.py +++ b/backend/donations/views/site.py @@ -3,7 +3,7 @@ from django.urls import reverse from .base import BaseHandler -from ..models import Ngo +from ..models.main import Ngo class HomePage(BaseHandler): diff --git a/backend/partners/migrations/0001_initial.py b/backend/partners/migrations/0001_initial.py index 8185e55a..adb92dd7 100644 --- a/backend/partners/migrations/0001_initial.py +++ b/backend/partners/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.8 on 2023-12-27 14:48 +# Generated by Django 4.2.9 on 2024-01-27 08:54 from django.db import migrations, models import django.db.models.functions.text @@ -19,7 +19,7 @@ class Migration(migrations.Migration): ("name", models.CharField(blank=True, db_index=True, max_length=100, verbose_name="name")), ("subdomain", models.CharField(max_length=100, unique=True, verbose_name="subdomain")), ("is_active", models.BooleanField(db_index=True, default=True, verbose_name="is active")), - ("ngos", models.ManyToManyField(to="donations.ngo", verbose_name="NGOs")), + ("ngos", models.ManyToManyField(blank=True, to="donations.ngo", verbose_name="NGOs")), ], options={ "verbose_name": "Partner", diff --git a/backend/partners/migrations/0002_alter_partner_ngos.py b/backend/partners/migrations/0002_alter_partner_ngos.py deleted file mode 100644 index 28a0fddc..00000000 --- a/backend/partners/migrations/0002_alter_partner_ngos.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.8 on 2023-12-27 15:02 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("donations", "0001_initial"), - ("partners", "0001_initial"), - ] - - operations = [ - migrations.AlterField( - model_name="partner", - name="ngos", - field=models.ManyToManyField(blank=True, to="donations.ngo", verbose_name="NGOs"), - ), - ] diff --git a/backend/partners/models.py b/backend/partners/models.py index c26c674d..4a9c125d 100644 --- a/backend/partners/models.py +++ b/backend/partners/models.py @@ -2,7 +2,7 @@ from django.db.models.functions import Lower from django.utils.translation import gettext_lazy as _ -from donations.models import Ngo +from donations.models.main import Ngo class Partner(models.Model): diff --git a/backend/users/migrations/0001_initial.py b/backend/users/migrations/0001_initial.py index 0a8c01f4..70eb25e8 100644 --- a/backend/users/migrations/0001_initial.py +++ b/backend/users/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.7 on 2023-11-24 14:31 +# Generated by Django 4.2.9 on 2024-01-27 08:54 from django.db import migrations, models import django.db.models.deletion @@ -11,30 +11,17 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ("donations", "0001_initial"), ("auth", "0012_alter_user_first_name_max_length"), + ("donations", "0001_initial"), ] operations = [ migrations.CreateModel( name="User", fields=[ - ( - "id", - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), + ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), ("password", models.CharField(max_length=128, verbose_name="password")), - ( - "last_login", - models.DateTimeField( - blank=True, null=True, verbose_name="last login" - ), - ), + ("last_login", models.DateTimeField(blank=True, null=True, verbose_name="last login")), ( "is_superuser", models.BooleanField( @@ -43,18 +30,8 @@ class Migration(migrations.Migration): verbose_name="superuser status", ), ), - ( - "first_name", - models.CharField( - blank=True, max_length=150, verbose_name="first name" - ), - ), - ( - "last_name", - models.CharField( - blank=True, max_length=150, verbose_name="last name" - ), - ), + ("first_name", models.CharField(blank=True, max_length=150, verbose_name="first name")), + ("last_name", models.CharField(blank=True, max_length=150, verbose_name="last name")), ( "is_staff", models.BooleanField( @@ -71,28 +48,27 @@ class Migration(migrations.Migration): verbose_name="active", ), ), - ( - "date_joined", - models.DateTimeField( - default=django.utils.timezone.now, verbose_name="date joined" - ), - ), + ("date_joined", models.DateTimeField(default=django.utils.timezone.now, verbose_name="date joined")), ( "username", models.CharField( + blank=True, + default="", editable=False, help_text="We do not use this field", max_length=150, - null=True, - unique=True, verbose_name="username", ), ), + ("email", models.EmailField(max_length=254, unique=True, verbose_name="email address")), + ("is_verified", models.BooleanField(db_index=True, default=False, verbose_name="is verified")), ( - "email", - models.EmailField( - max_length=254, unique=True, verbose_name="email address" - ), + "validation_token", + models.UUIDField(blank=True, editable=False, null=True, verbose_name="validation token"), + ), + ( + "token_timestamp", + models.DateTimeField(blank=True, null=True, verbose_name="validation token timestamp"), ), ( "groups", @@ -137,8 +113,6 @@ class Migration(migrations.Migration): ), migrations.AddConstraint( model_name="user", - constraint=models.UniqueConstraint( - django.db.models.functions.text.Lower("email"), name="email_unique" - ), + constraint=models.UniqueConstraint(django.db.models.functions.text.Lower("email"), name="email_unique"), ), ] diff --git a/backend/users/migrations/0002_user_is_verified_user_token_timestamp_and_more.py b/backend/users/migrations/0002_user_is_verified_user_token_timestamp_and_more.py deleted file mode 100644 index 94fe7b1d..00000000 --- a/backend/users/migrations/0002_user_is_verified_user_token_timestamp_and_more.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by Django 4.2.8 on 2023-12-13 06:01 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='user', - name='is_verified', - field=models.BooleanField(db_index=True, default=False, verbose_name='is verified'), - ), - migrations.AddField( - model_name='user', - name='token_timestamp', - field=models.DateTimeField(blank=True, null=True, verbose_name='validation token timestamp'), - ), - migrations.AddField( - model_name='user', - name='validation_token', - field=models.UUIDField(blank=True, editable=False, null=True, verbose_name='validation token'), - ), - ] diff --git a/backend/users/migrations/0003_alter_user_username.py b/backend/users/migrations/0003_alter_user_username.py deleted file mode 100644 index fa3a2cec..00000000 --- a/backend/users/migrations/0003_alter_user_username.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.8 on 2023-12-25 08:31 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('users', '0002_user_is_verified_user_token_timestamp_and_more'), - ] - - operations = [ - migrations.AlterField( - model_name='user', - name='username', - field=models.CharField(blank=True, default='', editable=False, help_text='We do not use this field', max_length=150, verbose_name='username'), - ), - ] diff --git a/backend/users/models.py b/backend/users/models.py index da32a25d..7b214b0e 100644 --- a/backend/users/models.py +++ b/backend/users/models.py @@ -8,7 +8,7 @@ from django.utils import timezone from django.utils.translation import gettext_lazy as _ -from donations.models import Ngo +from donations.models.main import Ngo class CustomUserManager(UserManager):