aboutsummaryrefslogtreecommitdiffstats
path: root/alphabetlearning/contrib/sites/migrations
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-12-31 16:01:12 +0000
committerMatthew Lemon <y@yulqen.org>2024-12-31 16:01:12 +0000
commitc74ea9e6b4af97be26029334868fa3264032c2d3 (patch)
tree6d0dcc825f9c4d70f543eeb1817d664e5e358320 /alphabetlearning/contrib/sites/migrations
parentb00665b30423e4818afafdec305202797638e145 (diff)
Major refactoring and removal of junk
This commit includes significant refactoring, cleanup, and updates across various components of the Django project. The following changes were made: - **Database Migration Updates:** - Removed unnecessary migrations in the `alphabetlearning.contrib.sites` and `alphabetlearning.payments` apps, consolidating them into cleaner initial migration files. - Altered the `Site` model in `alphabetlearning.contrib.sites` to streamline its fields and default settings. - Introduced new models in `alphabetlearning.payments` related to email signups and verification, reflecting a shift in focus and better alignment with current business logic. - **Django Settings Changes:** - Updated the database settings to use SQLite for local development, while commenting out production-specific configurations. - Managed third-party dependencies within `requirements.txt` and `pyproject.toml`, ensuring alignment with the latest Django version (5.1.4) and removing obsolete dependencies (e.g., `celery`, `django-celery-beat`, `flower`, etc.). - **Docker and Compose Clean-up:** - Removed old Dockerfiles and unnecessary services from the `docker-compose` configuration, streamlining the local and production setups. - Updated the Dockerfile configuration for local development, focusing on essential services only. - **General Code Clean-up:** - Removed unused tasks, views, tests, and files related to the Celery and Redis frameworks. - Cleaned up various model definitions and their related migrations for consistency and clarity. - **Documentation and Comments:** - Updated comments and code documentation where necessary to reflect the changes made during this cleanup process. This major refactor aims to enhance project maintainability and streamline the development experience while preparing for future feature expansions and improvements.
Diffstat (limited to 'alphabetlearning/contrib/sites/migrations')
-rw-r--r--alphabetlearning/contrib/sites/migrations/0001_initial.py47
-rw-r--r--alphabetlearning/contrib/sites/migrations/0002_alter_domain_unique.py21
-rw-r--r--alphabetlearning/contrib/sites/migrations/0003_set_site_domain_and_name.py63
-rw-r--r--alphabetlearning/contrib/sites/migrations/0004_alter_options_ordering_domain.py21
4 files changed, 18 insertions, 134 deletions
diff --git a/alphabetlearning/contrib/sites/migrations/0001_initial.py b/alphabetlearning/contrib/sites/migrations/0001_initial.py
index fd76afb..d6bb9e1 100644
--- a/alphabetlearning/contrib/sites/migrations/0001_initial.py
+++ b/alphabetlearning/contrib/sites/migrations/0001_initial.py
@@ -1,43 +1,32 @@
+# Generated by Django 5.1.4 on 2024-12-31 15:26
+
import django.contrib.sites.models
-from django.contrib.sites.models import _simple_domain_name_validator
-from django.db import migrations
-from django.db import models
+from django.db import migrations, models
class Migration(migrations.Migration):
- dependencies = []
+ initial = True
+
+ dependencies = [
+ ]
operations = [
migrations.CreateModel(
- name="Site",
+ name='Site',
fields=[
- (
- "id",
- models.AutoField(
- verbose_name="ID",
- serialize=False,
- auto_created=True,
- primary_key=True,
- ),
- ),
- (
- "domain",
- models.CharField(
- max_length=100,
- verbose_name="domain name",
- validators=[_simple_domain_name_validator],
- ),
- ),
- ("name", models.CharField(max_length=50, verbose_name="display name")),
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('domain', models.CharField(max_length=100, unique=True, validators=[django.contrib.sites.models._simple_domain_name_validator], verbose_name='domain name')),
+ ('name', models.CharField(max_length=50, verbose_name='display name')),
],
options={
- "ordering": ("domain",),
- "db_table": "django_site",
- "verbose_name": "site",
- "verbose_name_plural": "sites",
+ 'verbose_name': 'site',
+ 'verbose_name_plural': 'sites',
+ 'db_table': 'django_site',
+ 'ordering': ['domain'],
},
- bases=(models.Model,),
- managers=[("objects", django.contrib.sites.models.SiteManager())],
+ managers=[
+ ('objects', django.contrib.sites.models.SiteManager()),
+ ],
),
]
diff --git a/alphabetlearning/contrib/sites/migrations/0002_alter_domain_unique.py b/alphabetlearning/contrib/sites/migrations/0002_alter_domain_unique.py
deleted file mode 100644
index 4a44a6a..0000000
--- a/alphabetlearning/contrib/sites/migrations/0002_alter_domain_unique.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import django.contrib.sites.models
-from django.db import migrations
-from django.db import models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [("sites", "0001_initial")]
-
- operations = [
- migrations.AlterField(
- model_name="site",
- name="domain",
- field=models.CharField(
- max_length=100,
- unique=True,
- validators=[django.contrib.sites.models._simple_domain_name_validator],
- verbose_name="domain name",
- ),
- )
- ]
diff --git a/alphabetlearning/contrib/sites/migrations/0003_set_site_domain_and_name.py b/alphabetlearning/contrib/sites/migrations/0003_set_site_domain_and_name.py
deleted file mode 100644
index f4b1cbb..0000000
--- a/alphabetlearning/contrib/sites/migrations/0003_set_site_domain_and_name.py
+++ /dev/null
@@ -1,63 +0,0 @@
-"""
-To understand why this file is here, please read:
-
-http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django
-"""
-from django.conf import settings
-from django.db import migrations
-
-
-def _update_or_create_site_with_sequence(site_model, connection, domain, name):
- """Update or create the site with default ID and keep the DB sequence in sync."""
- site, created = site_model.objects.update_or_create(
- id=settings.SITE_ID,
- defaults={
- "domain": domain,
- "name": name,
- },
- )
- if created:
- # We provided the ID explicitly when creating the Site entry, therefore the DB
- # sequence to auto-generate them wasn't used and is now out of sync. If we
- # don't do anything, we'll get a unique constraint violation the next time a
- # site is created.
- # To avoid this, we need to manually update DB sequence and make sure it's
- # greater than the maximum value.
- max_id = site_model.objects.order_by("-id").first().id
- with connection.cursor() as cursor:
- cursor.execute("SELECT last_value from django_site_id_seq")
- (current_id,) = cursor.fetchone()
- if current_id <= max_id:
- cursor.execute(
- "alter sequence django_site_id_seq restart with %s",
- [max_id + 1],
- )
-
-
-def update_site_forward(apps, schema_editor):
- """Set site domain and name."""
- Site = apps.get_model("sites", "Site")
- _update_or_create_site_with_sequence(
- Site,
- schema_editor.connection,
- "resources.joannalemon.com",
- "pyblackbird-cc",
- )
-
-
-def update_site_backward(apps, schema_editor):
- """Revert site domain and name to default."""
- Site = apps.get_model("sites", "Site")
- _update_or_create_site_with_sequence(
- Site,
- schema_editor.connection,
- "example.com",
- "example.com",
- )
-
-
-class Migration(migrations.Migration):
-
- dependencies = [("sites", "0002_alter_domain_unique")]
-
- operations = [migrations.RunPython(update_site_forward, update_site_backward)]
diff --git a/alphabetlearning/contrib/sites/migrations/0004_alter_options_ordering_domain.py b/alphabetlearning/contrib/sites/migrations/0004_alter_options_ordering_domain.py
deleted file mode 100644
index f7118ca..0000000
--- a/alphabetlearning/contrib/sites/migrations/0004_alter_options_ordering_domain.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Generated by Django 3.1.7 on 2021-02-04 14:49
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ("sites", "0003_set_site_domain_and_name"),
- ]
-
- operations = [
- migrations.AlterModelOptions(
- name="site",
- options={
- "ordering": ["domain"],
- "verbose_name": "site",
- "verbose_name_plural": "sites",
- },
- ),
- ]