diff --git a/smugfolioapi/fixtures/image_tags.json b/smugfolioapi/fixtures/image_tags.json new file mode 100644 index 0000000..3f8d25f --- /dev/null +++ b/smugfolioapi/fixtures/image_tags.json @@ -0,0 +1,45 @@ +[{ + "model": "smugfolioapi.image_tags", + "pk": 1, + "fields": { + "image_tag_name": "landscape" + } + }, + { + "model": "smugfolioapi.image_tags", + "pk": 2, + "fields": { + "image_tag_name": "portrait" + } + }, + { + "model": "smugfolioapi.image_tags", + "pk": 3, + "fields": + { + "image_tag_name": "night" + } + + }, + { + "model": "smugfolioapi.image_tags", + "pk": 4, + "fields": { + "image_tag_name": "high key" + } + }, + { + "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/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/smugfolioapi/fixtures/tokens.json b/smugfolioapi/fixtures/tokens.json new file mode 100644 index 0000000..3b38893 --- /dev/null +++ b/smugfolioapi/fixtures/tokens.json @@ -0,0 +1,9 @@ +[{ + "model": "authtoken.token", + "pk": "fa2eba9be8282d595c997ee5cd49f2ed31f65bed", + "fields": { + "user": 1, + "created": "2020-08-29T13:24:27.172Z" + } +}] + diff --git a/smugfolioapi/fixtures/user.json b/smugfolioapi/fixtures/user.json new file mode 100644 index 0000000..483b37a --- /dev/null +++ b/smugfolioapi/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 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/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..0aa21a4 100644 --- a/smugfolioapi/models/images.py +++ b/smugfolioapi/models/images.py @@ -0,0 +1,11 @@ +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(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/smugfolioapi/models/smug_users.py b/smugfolioapi/models/smug_users.py new file mode 100644 index 0000000..311ab34 --- /dev/null +++ b/smugfolioapi/models/smug_users.py @@ -0,0 +1,10 @@ +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) + business_name = models.CharField(max_length=256) + business_owner = models.BooleanField(default=False) + + \ No newline at end of file diff --git a/smugfolioapi/models/users.py b/smugfolioapi/views/auth.py similarity index 100% rename from smugfolioapi/models/users.py rename to smugfolioapi/views/auth.py