From f4d0e61be99c4e49f766eebe89e40d16cb02d529 Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Fri, 11 Mar 2022 21:43:39 -0600 Subject: [PATCH 1/5] models created, checking for completeness --- smugfolioapi/models/image_tag_assignments.py | 6 ++++++ smugfolioapi/models/image_tags.py | 4 ++++ smugfolioapi/models/images.py | 8 ++++++++ smugfolioapi/models/smug_users.py | 12 ++++++++++++ smugfolioapi/models/users.py | 0 5 files changed, 30 insertions(+) create mode 100644 smugfolioapi/models/smug_users.py delete mode 100644 smugfolioapi/models/users.py diff --git a/smugfolioapi/models/image_tag_assignments.py b/smugfolioapi/models/image_tag_assignments.py index e69de29..ef03899 100644 --- a/smugfolioapi/models/image_tag_assignments.py +++ b/smugfolioapi/models/image_tag_assignments.py @@ -0,0 +1,6 @@ +from django.db import models + +class Image_Tag_Assignments(models.Model): + + image_tag_id = models.ForeignKey("Image_Tags", on_delete=models.CASCADE) + image_id = models.ForeignKey("Images", on_delete=models.CASCADE) \ No newline at end of file diff --git a/smugfolioapi/models/image_tags.py b/smugfolioapi/models/image_tags.py index e69de29..5804583 100644 --- a/smugfolioapi/models/image_tags.py +++ b/smugfolioapi/models/image_tags.py @@ -0,0 +1,4 @@ +from django.db import models +class Image_Tags(models.Model): + + image_tag_name = models.CharField(max_length=256) \ No newline at end of file diff --git a/smugfolioapi/models/images.py b/smugfolioapi/models/images.py index e69de29..76ed616 100644 --- a/smugfolioapi/models/images.py +++ b/smugfolioapi/models/images.py @@ -0,0 +1,8 @@ +from django.db import models +class Images(models.Model): + + file_name = models.CharField(max_length=1024) + 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 diff --git a/smugfolioapi/models/smug_users.py b/smugfolioapi/models/smug_users.py new file mode 100644 index 0000000..e41f818 --- /dev/null +++ b/smugfolioapi/models/smug_users.py @@ -0,0 +1,12 @@ +from django.db import models +from django.contrib.auth.models import User + +class Smug_Users(models.Model): + + user = models.OneToOneField(User, on_delete=models.CASCADE) + first_name = models.CharField(max_length=256) + last_name = models.CharField(max_length=256) + business_name = models.CharField(max_length=256) + business_owner = models.BooleanField() + + \ No newline at end of file diff --git a/smugfolioapi/models/users.py b/smugfolioapi/models/users.py deleted file mode 100644 index e69de29..0000000 From e25e77390615821444797be9333c1dc314f13cf7 Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Fri, 11 Mar 2022 21:55:18 -0600 Subject: [PATCH 2/5] saving fixture files --- smugfolioserver/fixtures/image_tags.json | 0 smugfolioserver/fixtures/image_tags_assignments.json | 0 smugfolioserver/fixtures/images.json | 0 smugfolioserver/fixtures/smug_users.json | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 smugfolioserver/fixtures/image_tags.json create mode 100644 smugfolioserver/fixtures/image_tags_assignments.json create mode 100644 smugfolioserver/fixtures/images.json create mode 100644 smugfolioserver/fixtures/smug_users.json diff --git a/smugfolioserver/fixtures/image_tags.json b/smugfolioserver/fixtures/image_tags.json new file mode 100644 index 0000000..e69de29 diff --git a/smugfolioserver/fixtures/image_tags_assignments.json b/smugfolioserver/fixtures/image_tags_assignments.json new file mode 100644 index 0000000..e69de29 diff --git a/smugfolioserver/fixtures/images.json b/smugfolioserver/fixtures/images.json new file mode 100644 index 0000000..e69de29 diff --git a/smugfolioserver/fixtures/smug_users.json b/smugfolioserver/fixtures/smug_users.json new file mode 100644 index 0000000..e69de29 From 444b82cdcc8d8586df3ed02de88043d65e30f431 Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Mon, 14 Mar 2022 14:52:14 -0500 Subject: [PATCH 3/5] saving new users file --- smugfolioapi/models/smug_users.py | 4 +--- smugfolioserver/fixtures/auth_user.json | 0 smugfolioserver/fixtures/image_tags.json | 20 +++++++++++++++++++ .../fixtures/image_tags_assignments.json | 3 +++ smugfolioserver/fixtures/images.json | 5 +++++ smugfolioserver/fixtures/smug_users.json | 20 +++++++++++++++++++ 6 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 smugfolioserver/fixtures/auth_user.json diff --git a/smugfolioapi/models/smug_users.py b/smugfolioapi/models/smug_users.py index e41f818..311ab34 100644 --- a/smugfolioapi/models/smug_users.py +++ b/smugfolioapi/models/smug_users.py @@ -4,9 +4,7 @@ from django.contrib.auth.models import User class Smug_Users(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) - first_name = models.CharField(max_length=256) - last_name = models.CharField(max_length=256) business_name = models.CharField(max_length=256) - business_owner = models.BooleanField() + business_owner = models.BooleanField(default=False) \ No newline at end of file diff --git a/smugfolioserver/fixtures/auth_user.json b/smugfolioserver/fixtures/auth_user.json new file mode 100644 index 0000000..e69de29 diff --git a/smugfolioserver/fixtures/image_tags.json b/smugfolioserver/fixtures/image_tags.json index e69de29..0647583 100644 --- a/smugfolioserver/fixtures/image_tags.json +++ b/smugfolioserver/fixtures/image_tags.json @@ -0,0 +1,20 @@ +[ + { + "image_tag_name": "landscape" + }, + { + "image_tag_name": "portrait" + }, + { + "image_tag_name": "night" + }, + { + "image_tag_name": "high key" + }, + { + "image_tag_name": "family" + }, + { + "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 index e69de29..1610ea1 100644 --- a/smugfolioserver/fixtures/image_tags_assignments.json +++ b/smugfolioserver/fixtures/image_tags_assignments.json @@ -0,0 +1,3 @@ +[ + +] \ No newline at end of file diff --git a/smugfolioserver/fixtures/images.json b/smugfolioserver/fixtures/images.json index e69de29..e10cfdc 100644 --- a/smugfolioserver/fixtures/images.json +++ b/smugfolioserver/fixtures/images.json @@ -0,0 +1,5 @@ +[ + { + "file_name":"" + } +] \ No newline at end of file diff --git a/smugfolioserver/fixtures/smug_users.json b/smugfolioserver/fixtures/smug_users.json index e69de29..e97e9c9 100644 --- a/smugfolioserver/fixtures/smug_users.json +++ b/smugfolioserver/fixtures/smug_users.json @@ -0,0 +1,20 @@ +[ + { + "first name":"Nate", + "last name":"Lubbe", + "business name":"Going-to-the-Sun Photography", + "business owner": false + }, + { + "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 + } +] From 0cf8781c937baa984886932cb03b0f52ebb6020a Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Tue, 15 Mar 2022 14:41:34 -0500 Subject: [PATCH 4/5] 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 From a44a38f8c907829f6810aa1acb6810c088e0e58f Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Tue, 15 Mar 2022 18:56:00 -0500 Subject: [PATCH 5/5] completed migrations --- .../fixtures/image_tags.json | 0 smugfolioapi/fixtures/smug_users.json | 13 +++++++++++++ .../fixtures/tokens.json | 5 +++-- .../fixtures/user.json | 4 ++-- smugfolioapi/views/auth.py | 0 smugfolioserver/fixtures/smug_users.json | 14 -------------- 6 files changed, 18 insertions(+), 18 deletions(-) rename {smugfolioserver => smugfolioapi}/fixtures/image_tags.json (100%) create mode 100644 smugfolioapi/fixtures/smug_users.json rename {smugfolioserver => smugfolioapi}/fixtures/tokens.json (96%) rename {smugfolioserver => smugfolioapi}/fixtures/user.json (90%) create mode 100644 smugfolioapi/views/auth.py delete mode 100644 smugfolioserver/fixtures/smug_users.json diff --git a/smugfolioserver/fixtures/image_tags.json b/smugfolioapi/fixtures/image_tags.json similarity index 100% rename from smugfolioserver/fixtures/image_tags.json rename to smugfolioapi/fixtures/image_tags.json diff --git a/smugfolioapi/fixtures/smug_users.json b/smugfolioapi/fixtures/smug_users.json new file mode 100644 index 0000000..010121a --- /dev/null +++ b/smugfolioapi/fixtures/smug_users.json @@ -0,0 +1,13 @@ +[ + { + "model": "smugfolioapi.smug_users", + "pk": 1, + "fields": + { + "business_name":"Going-to-the-Sun Photography", + "business_owner": true, + "user": 1 + } +} + +] diff --git a/smugfolioserver/fixtures/tokens.json b/smugfolioapi/fixtures/tokens.json similarity index 96% rename from smugfolioserver/fixtures/tokens.json rename to smugfolioapi/fixtures/tokens.json index 0639cc3..3b38893 100644 --- a/smugfolioserver/fixtures/tokens.json +++ b/smugfolioapi/fixtures/tokens.json @@ -1,8 +1,9 @@ -{ +[{ "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/smugfolioapi/fixtures/user.json similarity index 90% rename from smugfolioserver/fixtures/user.json rename to smugfolioapi/fixtures/user.json index e0359cc..483b37a 100644 --- a/smugfolioserver/fixtures/user.json +++ b/smugfolioapi/fixtures/user.json @@ -4,8 +4,8 @@ "pk": 1, "fields": { - "first name":"Ansel", - "last name": "Adams", + "first_name":"Ansel", + "last_name": "Adams", "password":"pbkdf2_sha256$216000$qMRH8szID7Z8$Vljya2V3XfruOHuvx1hGz9ZyKg4bxbw7rc2WO0gTR7I=", "is_superuser": true, "username": "a.adams@goingtothesunphotography.com", diff --git a/smugfolioapi/views/auth.py b/smugfolioapi/views/auth.py new file mode 100644 index 0000000..e69de29 diff --git a/smugfolioserver/fixtures/smug_users.json b/smugfolioserver/fixtures/smug_users.json deleted file mode 100644 index 544dfb8..0000000 --- a/smugfolioserver/fixtures/smug_users.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "model": "smugfolioapi.smug_users", - "pk": 1, - "fields": - { - "first name":"Ansel", - "last name":"Adams", - "business name":"Going-to-the-Sun Photography", - "business owner": true - } -} - -]