Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/BE-35: Art Item Category #358

Merged
merged 5 commits into from
Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions App/backend/api/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.2 on 2022-12-09 09:21
# Generated by Django 4.1.2 on 2022-12-17 14:45

from django.conf import settings
import django.contrib.auth.models
Expand Down Expand Up @@ -59,7 +59,7 @@ class Migration(migrations.Migration):
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200)),
('description', models.CharField(max_length=500)),
('type', models.CharField(max_length=500)),
('category', models.CharField(choices=[('AR', 'Architecture'), ('SC', 'Sculpture'), ('DR', 'Drawing'), ('PH', 'Photography'), ('PR', 'Prints'), ('PA', 'Painting/Acrylic'), ('PO', 'Painting Oilpaint'), ('PW', 'Painting Watercolour'), ('PD', 'Painting Digital'), ('PM', 'Painting Mural'), ('PG', 'Painting Gouache'), ('PP', 'Painting Pastel'), ('PE', 'Painting Encaustic'), ('PF', 'Painting Fresco'), ('PS', 'Painting Spray'), ('OP', 'Painting Other'), ('Other', 'Other')], default='Other', max_length=20)),
('artitem_image', models.ImageField(default='artitem/defaultart.jpg', upload_to='artitem/')),
('artitem_path', models.TextField(default='artitem/defaultart.jpg')),
('created_at', models.DateTimeField(auto_now_add=True)),
Expand Down
25 changes: 24 additions & 1 deletion App/backend/api/models/artitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.contrib.auth.models import AbstractUser
from django.conf import settings
from .user import User
from django.utils.translation import gettext_lazy as _

class Tag(models.Model):
tagname = models.CharField(max_length=100)
Expand All @@ -14,11 +15,33 @@ def __str__(self):
return self.tagname

class ArtItem(models.Model):

class Category(models.TextChoices):
ARCHITECTURE = 'AR', _('Architecture')
SCULPTURE = 'SC', _('Sculpture')
SKETCH = 'SK', _('Sketch')
DRAWING = 'DR', _('Drawing')
POSTER = 'PT', _('Poster')
PHOTOGRAPHY = 'PH', _('Photography')
PRINTS = 'PR', _('Prints')
PAINTING_ACRYLIC = 'PA', _('Painting/Acrylic')
PAINTING_OILPAINT = 'PO', _("Painting Oilpaint")
PAINTING_WATERCOLOUR = 'PW', _("Painting Watercolour")
PAINTING_DIGITAL = 'PD', _("Painting Digital")
PAINTING_MURAL = 'PM', _("Painting Mural")
PAINTING_GOUACHE = 'PG', _("Painting Gouache")
PAINTING_PASTEL = 'PP', _("Painting Pastel")
PAINTING_ENCAUSTIC = 'PE', _("Painting Encaustic")
PAINTING_FRESCO = 'PF', _("Painting Fresco")
PAINTING_SPRAY = 'PS', _("Painting Spray")
PAINTING_OTHER = 'OP', _("Painting Other")
OTHER = 'OT', _("Other")

title = models.CharField(max_length=200)
description = models.CharField(max_length=500)
owner = models.ForeignKey(User, on_delete=models.CASCADE)
tags = models.ManyToManyField(Tag, blank=True) # tags are not required
type = models.CharField(max_length=500)
category = models.CharField(max_length=2, choices=Category.choices, default=Category.OTHER)
artitem_image = models.ImageField( default='artitem/defaultart.jpg', upload_to='artitem/')
artitem_path = models.TextField(default= 'artitem/defaultart.jpg')
created_at = models.DateTimeField(auto_now_add=True)
Expand Down
2 changes: 1 addition & 1 deletion App/backend/api/serializers/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ArtItemSerializer(serializers.ModelSerializer):

class Meta:
model = ArtItem
fields = ['id', 'owner', 'title', 'description', 'type', 'tags', 'artitem_path', 'likes', 'created_at']
fields = ['id', 'owner', 'title', 'description', 'category', 'tags', 'artitem_path', 'likes', 'created_at']

def to_representation(self, instance):
rep = super().to_representation(instance)
Expand Down
14 changes: 7 additions & 7 deletions App/backend/api/views/artitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"surname": "Blocker",
"profile_path": "avatar/default.png"
},
"type": "sketch",
"category": "DR",
"tags": [],
"likes": 5,
"artitem_path": "artitem/docker.jpg"
Expand Down Expand Up @@ -85,7 +85,7 @@ def get_artitems(request):
properties={
"title": openapi.Schema(type=openapi.TYPE_STRING, description='title of the art item', default="Portrait of Joel Miller"),
"description": openapi.Schema(type=openapi.TYPE_STRING, description='description of the art item', default="Joel Miller from TLOU universe."),
"type": openapi.Schema(type=openapi.TYPE_STRING, description='type of the art item', default="Sketch"),
"category": openapi.Schema(type=openapi.TYPE_STRING, description='category of the art item', default="OT"),
"tags": openapi.Schema(type=openapi.TYPE_ARRAY, items=openapi.Items(type=openapi.TYPE_INTEGER), description='an array of tag IDs attached to the art item (can be empty)', default=[1]),
"artitem_image": openapi.Schema(type=openapi.TYPE_STRING, description='base64 encoded version of the image', default="base64 string"),
}),
Expand All @@ -105,7 +105,7 @@ def get_artitems(request):
"surname": "Blocker",
"profile_path": "avatar/default.png"
},
"type": "sketch",
"category": "DR",
"tags": [1],
"likes": 0,
"artitem_path": "artitem/docker.jpg"
Expand Down Expand Up @@ -229,7 +229,7 @@ def delete_artitem(request, id):
"surname": "Blocker",
"profile_path": "avatar/default.png"
},
"type": "sketch",
"category": "DR",
"tags": [],
"artitem_path": "artitem/docker.jpg",
"isLiked": False
Expand Down Expand Up @@ -288,7 +288,7 @@ def artitems_by_id(request, id):
"surname": "Blocker",
"profile_path": "avatar/default.png"
},
"type": "sketch",
"category": "DR",
"tags": [],
"likes": 5,
"artitem_path": "artitem/docker.jpg"
Expand Down Expand Up @@ -340,7 +340,7 @@ def artitems_by_userid(request, id):
"surname": "Blocker",
"profile_path": "avatar/default.png"
},
"type": "sketch",
"category": "DR",
"tags": [],
"likes": 5,
"artitem_path": "artitem/docker.jpg"
Expand Down Expand Up @@ -393,7 +393,7 @@ def artitems_by_username(request, username):
},
"title": "Portrait of Joel Miller",
"description": "Joel Miller from TLOU universe.",
"type": "sketch",
"category": "DR",
"tags": [],
"likes": 5,
"artitem_path": "artitem/artitem-0.png",
Expand Down
2 changes: 1 addition & 1 deletion App/backend/api/views/like.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def unlike_artitem(request, id):
"name": "Captain Joseph",
"surname": "Blocker"
},
"type": "sketch",
"category": "DR",
"tags": [],
"artitem_path": "artitem/docker.jpg"
}
Expand Down