Merge Basic MVP Server #13

Merged
JMR-dev merged 7 commits from jr-changes-after-building-client into main 2022-03-23 23:29:52 +00:00
33 changed files with 24 additions and 11 deletions
Showing only changes of commit b197619b2b - Show all commits
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 773 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 975 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

@@ -0,0 +1,18 @@
# Generated by Django 4.0.3 on 2022-03-18 18:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('smugfolioapi', '0003_remove_images_file_name_remove_images_file_path'),
]
operations = [
migrations.AlterField(
model_name='smug_users',
name='business_name',
field=models.CharField(default='Going-To-The-Sun-Photography', max_length=256),
),
]
+1
View File
@@ -4,6 +4,7 @@ class Images(models.Model):
album_id = models.IntegerField(default=0)
smug_user = models.ForeignKey("Smug_Users", on_delete=models.CASCADE)
upload_date = models.DateTimeField(auto_now_add=True)
file_name = models
picture = models.ImageField(
upload_to='smugimages', height_field=None,
width_field=None, max_length=None, null=True
-1
View File
@@ -43,7 +43,6 @@ def register_user(request):
Method arguments:
request -- The full HTTP request object
'''
# Create a new user by invoking the `create_user` helper method
# on Django's built-in User model
new_user = User.objects.create_user(
+4 -9
View File
@@ -3,7 +3,6 @@ from rest_framework.viewsets import ViewSet
from rest_framework.response import Response
from rest_framework import serializers, status
from smugfolioapi.models import Images, Smug_Users
from PIL import Image
import uuid
import base64
from django.core.files.base import ContentFile
@@ -49,17 +48,15 @@ class ImageView(ViewSet):
Response -- JSON serialized images instance
"""
# object must be retrived when using a foreign key
format, imgstr = request.data["picture"].split(';base64,')
file_name = request.query_params.get('file_name', None)
format, imgstr = request.data['picture'].split(';base64,')
ext = format.split('/')[-1]
data = ContentFile(base64.b64decode(imgstr), name=f'{request.data["picture"]}-{uuid.uuid4()}.{ext}')
data = ContentFile(base64.b64decode(imgstr), name=f'{file_name}-{uuid.uuid4()}.{ext}')
smug_user = Smug_Users.objects.get(user=request.auth.user)
images = Images.objects.create(
file_name=request.data["file_name"],
file_path=request.data["file_path"],
album_id=request.data["album_id"],
picture= data,
smug_user= smug_user,
upload_date = request.data["upload_date"]
)
serializer = ImagesSerializer(images)
return Response(serializer.data, status=201)
@@ -72,8 +69,6 @@ class ImageView(ViewSet):
"""
# Refactor keys to match ERD
images = Images.objects.get(pk=pk)
images.file_name = request.data["file_name"]
images.file_path = request.data["file_path"]
images.album_id = request.data["album_id"]
images.smug_user_id = request.data["smug_user_id"]
images.upload_date = request.data["upload_date"]
@@ -100,7 +95,7 @@ class ImagesSerializer(serializers.ModelSerializer):
"""
class Meta:
model = Images
fields = ('id', 'file_name', 'file_path', 'album_id', 'smug_user_id', 'upload_date', 'picture', 'imagecount')
fields = ('id', 'album_id', 'smug_user_id', 'upload_date', 'picture')
depth = 2
+1 -1
View File
@@ -23,7 +23,7 @@ from django.urls import path
from django.conf.urls.static import static
from smugfolioapi.views.image_tags import ImageTagsView
from smugfolioapi.views.images import ImageView
from smugfolioserver import settings, MEDIA_ROOT, MEDIA_URL
from django.conf import settings
router = routers.DefaultRouter(trailing_slash=False)
router.register(r'images', ImageView, 'image')