aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/contrib/sites
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-01-19 15:57:06 +0000
committerMatthew Lemon <lemon@matthewlemon.com>2020-01-19 15:57:06 +0000
commit9d76a3c52b8310726ec09e0262813f0438c21df6 (patch)
tree4acf47dce6c3aa75f8ad7c5cb56fe6486c2d64a7 /ctrack/contrib/sites
init commit - from cookiecutter
Diffstat (limited to 'ctrack/contrib/sites')
-rw-r--r--ctrack/contrib/sites/__init__.py5
-rw-r--r--ctrack/contrib/sites/migrations/0001_initial.py42
-rw-r--r--ctrack/contrib/sites/migrations/0002_alter_domain_unique.py20
-rw-r--r--ctrack/contrib/sites/migrations/0003_set_site_domain_and_name.py34
-rw-r--r--ctrack/contrib/sites/migrations/__init__.py5
5 files changed, 106 insertions, 0 deletions
diff --git a/ctrack/contrib/sites/__init__.py b/ctrack/contrib/sites/__init__.py
new file mode 100644
index 0000000..1c7ecc8
--- /dev/null
+++ b/ctrack/contrib/sites/__init__.py
@@ -0,0 +1,5 @@
+"""
+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
+"""
diff --git a/ctrack/contrib/sites/migrations/0001_initial.py b/ctrack/contrib/sites/migrations/0001_initial.py
new file mode 100644
index 0000000..304cd6d
--- /dev/null
+++ b/ctrack/contrib/sites/migrations/0001_initial.py
@@ -0,0 +1,42 @@
+import django.contrib.sites.models
+from django.contrib.sites.models import _simple_domain_name_validator
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = []
+
+ operations = [
+ migrations.CreateModel(
+ 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")),
+ ],
+ options={
+ "ordering": ("domain",),
+ "db_table": "django_site",
+ "verbose_name": "site",
+ "verbose_name_plural": "sites",
+ },
+ bases=(models.Model,),
+ managers=[("objects", django.contrib.sites.models.SiteManager())],
+ )
+ ]
diff --git a/ctrack/contrib/sites/migrations/0002_alter_domain_unique.py b/ctrack/contrib/sites/migrations/0002_alter_domain_unique.py
new file mode 100644
index 0000000..2c8d6da
--- /dev/null
+++ b/ctrack/contrib/sites/migrations/0002_alter_domain_unique.py
@@ -0,0 +1,20 @@
+import django.contrib.sites.models
+from django.db import migrations, 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/ctrack/contrib/sites/migrations/0003_set_site_domain_and_name.py b/ctrack/contrib/sites/migrations/0003_set_site_domain_and_name.py
new file mode 100644
index 0000000..e81e91e
--- /dev/null
+++ b/ctrack/contrib/sites/migrations/0003_set_site_domain_and_name.py
@@ -0,0 +1,34 @@
+"""
+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_site_forward(apps, schema_editor):
+ """Set site domain and name."""
+ Site = apps.get_model("sites", "Site")
+ Site.objects.update_or_create(
+ id=settings.SITE_ID,
+ defaults={
+ "domain": "ctrackdft.net",
+ "name": "ctrack",
+ },
+ )
+
+
+def update_site_backward(apps, schema_editor):
+ """Revert site domain and name to default."""
+ Site = apps.get_model("sites", "Site")
+ Site.objects.update_or_create(
+ id=settings.SITE_ID, defaults={"domain": "example.com", "name": "example.com"}
+ )
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [("sites", "0002_alter_domain_unique")]
+
+ operations = [migrations.RunPython(update_site_forward, update_site_backward)]
diff --git a/ctrack/contrib/sites/migrations/__init__.py b/ctrack/contrib/sites/migrations/__init__.py
new file mode 100644
index 0000000..1c7ecc8
--- /dev/null
+++ b/ctrack/contrib/sites/migrations/__init__.py
@@ -0,0 +1,5 @@
+"""
+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
+"""