From 0cf8781c937baa984886932cb03b0f52ebb6020a Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Tue, 15 Mar 2022 14:41:34 -0500 Subject: [PATCH] adding corrected fixtures --- smugfolioapi/migrations/0001_initial.py | 52 +++++++++++++++++++ smugfolioapi/models/__init__.py | 4 ++ smugfolioapi/models/images.py | 5 +- smugfolioserver/fixtures/auth_user.json | 0 smugfolioserver/fixtures/image_tags.json | 51 +++++++++++++----- .../fixtures/image_tags_assignments.json | 3 -- smugfolioserver/fixtures/images.json | 5 -- smugfolioserver/fixtures/smug_users.json | 16 ++---- smugfolioserver/fixtures/tokens.json | 8 +++ smugfolioserver/fixtures/user.json | 23 ++++++++ 10 files changed, 134 insertions(+), 33 deletions(-) create mode 100644 smugfolioapi/migrations/0001_initial.py delete mode 100644 smugfolioserver/fixtures/auth_user.json delete mode 100644 smugfolioserver/fixtures/image_tags_assignments.json delete mode 100644 smugfolioserver/fixtures/images.json create mode 100644 smugfolioserver/fixtures/tokens.json create mode 100644 smugfolioserver/fixtures/user.json diff --git a/smugfolioapi/migrations/0001_initial.py b/smugfolioapi/migrations/0001_initial.py new file mode 100644 index 0000000..9f3f5f7 --- /dev/null +++ b/smugfolioapi/migrations/0001_initial.py @@ -0,0 +1,52 @@ +# Generated by Django 4.0.3 on 2022-03-15 16:29 + +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), + ] + + operations = [ + migrations.CreateModel( + name='Image_Tags', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('image_tag_name', models.CharField(max_length=256)), + ], + ), + migrations.CreateModel( + name='Smug_Users', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('business_name', models.CharField(max_length=256)), + ('business_owner', models.BooleanField(default=False)), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='Images', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('file_name', models.CharField(max_length=1024)), + ('file_path', models.CharField(max_length=1024)), + ('album_id', models.IntegerField(default=0)), + ('upload_date', models.DateTimeField(auto_now_add=True)), + ('smug_user_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='smugfolioapi.smug_users')), + ], + ), + migrations.CreateModel( + name='Image_Tag_Assignments', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('image_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='smugfolioapi.images')), + ('image_tag_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='smugfolioapi.image_tags')), + ], + ), + ] diff --git a/smugfolioapi/models/__init__.py b/smugfolioapi/models/__init__.py index e69de29..9fbe78a 100644 --- a/smugfolioapi/models/__init__.py +++ b/smugfolioapi/models/__init__.py @@ -0,0 +1,4 @@ +from smugfolioapi.models.image_tag_assignments import Image_Tag_Assignments +from smugfolioapi.models.image_tags import Image_Tags +from smugfolioapi.models.images import Images +from smugfolioapi.models.smug_users import Smug_Users \ No newline at end of file diff --git a/smugfolioapi/models/images.py b/smugfolioapi/models/images.py index 76ed616..0aa21a4 100644 --- a/smugfolioapi/models/images.py +++ b/smugfolioapi/models/images.py @@ -5,4 +5,7 @@ class Images(models.Model): file_path = models.CharField(max_length=1024) album_id = models.IntegerField(default=0) smug_user_id = models.ForeignKey("Smug_Users", on_delete=models.CASCADE) - upload_date = models.DateTimeField() \ No newline at end of file + upload_date = models.DateTimeField(auto_now_add=True) + + # I believe that auto_now_add is the correct syntax. If I'm understanding this correctly, it only creates a timestamp when the object is first created. + # https://www.geeksforgeeks.org/datetimefield-django-models/ \ No newline at end of file diff --git a/smugfolioserver/fixtures/auth_user.json b/smugfolioserver/fixtures/auth_user.json deleted file mode 100644 index e69de29..0000000 diff --git a/smugfolioserver/fixtures/image_tags.json b/smugfolioserver/fixtures/image_tags.json index 0647583..3f8d25f 100644 --- a/smugfolioserver/fixtures/image_tags.json +++ b/smugfolioserver/fixtures/image_tags.json @@ -1,20 +1,45 @@ -[ - { - "image_tag_name": "landscape" +[{ + "model": "smugfolioapi.image_tags", + "pk": 1, + "fields": { + "image_tag_name": "landscape" + } }, { - "image_tag_name": "portrait" + "model": "smugfolioapi.image_tags", + "pk": 2, + "fields": { + "image_tag_name": "portrait" + } }, { - "image_tag_name": "night" + "model": "smugfolioapi.image_tags", + "pk": 3, + "fields": + { + "image_tag_name": "night" + } + }, { - "image_tag_name": "high key" + "model": "smugfolioapi.image_tags", + "pk": 4, + "fields": { + "image_tag_name": "high key" + } }, - { - "image_tag_name": "family" - }, - { - "image_tag_name": "wedding" - } -] \ No newline at end of file + { + "model": "smugfolioapi.image_tags", + "pk": 5, + "fields": { + "image_tag_name": "family" + } + }, + { + "model": "smugfolioapi.image_tags", + "pk": 6, + "fields": { + "image_tag_name": "wedding" + } + } + ] \ No newline at end of file diff --git a/smugfolioserver/fixtures/image_tags_assignments.json b/smugfolioserver/fixtures/image_tags_assignments.json deleted file mode 100644 index 1610ea1..0000000 --- a/smugfolioserver/fixtures/image_tags_assignments.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - -] \ No newline at end of file diff --git a/smugfolioserver/fixtures/images.json b/smugfolioserver/fixtures/images.json deleted file mode 100644 index e10cfdc..0000000 --- a/smugfolioserver/fixtures/images.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - { - "file_name":"" - } -] \ No newline at end of file diff --git a/smugfolioserver/fixtures/smug_users.json b/smugfolioserver/fixtures/smug_users.json index e97e9c9..544dfb8 100644 --- a/smugfolioserver/fixtures/smug_users.json +++ b/smugfolioserver/fixtures/smug_users.json @@ -1,20 +1,14 @@ [ { - "first name":"Nate", - "last name":"Lubbe", - "business name":"Going-to-the-Sun Photography", - "business owner": false - }, + "model": "smugfolioapi.smug_users", + "pk": 1, + "fields": { "first name":"Ansel", "last name":"Adams", "business name":"Going-to-the-Sun Photography", "business owner": true - }, - { - "first name":"Chris", - "last name":"Cotuna", - "business name":"Going-to-the-Sun Photography", - "business owner": false } +} + ] diff --git a/smugfolioserver/fixtures/tokens.json b/smugfolioserver/fixtures/tokens.json new file mode 100644 index 0000000..0639cc3 --- /dev/null +++ b/smugfolioserver/fixtures/tokens.json @@ -0,0 +1,8 @@ +{ + "model": "authtoken.token", + "pk": "fa2eba9be8282d595c997ee5cd49f2ed31f65bed", + "fields": { + "user": 1, + "created": "2020-08-29T13:24:27.172Z" + } +} \ No newline at end of file diff --git a/smugfolioserver/fixtures/user.json b/smugfolioserver/fixtures/user.json new file mode 100644 index 0000000..e0359cc --- /dev/null +++ b/smugfolioserver/fixtures/user.json @@ -0,0 +1,23 @@ +[ + { + "model": "auth.user", + "pk": 1, + "fields": + { + "first name":"Ansel", + "last name": "Adams", + "password":"pbkdf2_sha256$216000$qMRH8szID7Z8$Vljya2V3XfruOHuvx1hGz9ZyKg4bxbw7rc2WO0gTR7I=", + "is_superuser": true, + "username": "a.adams@goingtothesunphotography.com", + "email": "a.adams@goingtothesunphotography.com", + "is_staff": true, + "is_active":true, + "date_joined": "2022-03-14 12:00:00", + "last_login": "2022-03-14 12:00:00", + "groups": [], + "user_permissions": [] + + } + +} +] \ No newline at end of file