added application gallery
This commit is contained in:
parent
5edcd0afe9
commit
15c1950184
0
apps/gallery/__init__.py
Normal file
0
apps/gallery/__init__.py
Normal file
8
apps/gallery/admin.py
Normal file
8
apps/gallery/admin.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from gallery.models import Gallery
|
||||
|
||||
|
||||
@admin.register(Gallery)
|
||||
class GalleryModelAdmin(admin.ModelAdmin):
|
||||
"""Gallery model admin"""
|
||||
7
apps/gallery/apps.py
Normal file
7
apps/gallery/apps.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
from django.apps import AppConfig
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class GalleryConfig(AppConfig):
|
||||
name = 'gallery'
|
||||
verbose_name = _('gallery')
|
||||
0
apps/gallery/migrations/__init__.py
Normal file
0
apps/gallery/migrations/__init__.py
Normal file
16
apps/gallery/models.py
Normal file
16
apps/gallery/models.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from utils.models import ProjectBaseMixin, ImageMixin
|
||||
|
||||
|
||||
class Gallery(ProjectBaseMixin, ImageMixin):
|
||||
"""Gallery model."""
|
||||
|
||||
class Meta:
|
||||
"""Meta class."""
|
||||
verbose_name = _('Gallery')
|
||||
verbose_name_plural = _('Galleries')
|
||||
|
||||
def __str__(self):
|
||||
"""String representation"""
|
||||
return str(self.get_image_url)
|
||||
20
apps/gallery/serializers.py
Normal file
20
apps/gallery/serializers.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from rest_framework import serializers
|
||||
|
||||
from . import models
|
||||
|
||||
|
||||
class GallerySerializer(serializers.ModelSerializer):
|
||||
"""Serializer for model Gallery."""
|
||||
# RESPONSE
|
||||
url = serializers.URLField(source='get_image_url')
|
||||
|
||||
class Meta:
|
||||
"""Meta class"""
|
||||
model = models.Gallery
|
||||
fields = (
|
||||
'image',
|
||||
'url'
|
||||
)
|
||||
read_only_fields = (
|
||||
'url',
|
||||
)
|
||||
1
apps/gallery/tests.py
Normal file
1
apps/gallery/tests.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Create your tests here.
|
||||
11
apps/gallery/urls.py
Normal file
11
apps/gallery/urls.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
"""Gallery urlpaths."""
|
||||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
app_name = 'gallery'
|
||||
|
||||
url_patterns = [
|
||||
path('upload/', views.GalleryUploadImage.as_view(),
|
||||
name='upload_image')
|
||||
]
|
||||
10
apps/gallery/views.py
Normal file
10
apps/gallery/views.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from rest_framework import generics
|
||||
|
||||
from . import models, serializers
|
||||
|
||||
|
||||
class GalleryUploadImage(generics.CreateAPIView):
|
||||
"""Upload image to gallery"""
|
||||
model = models.Gallery
|
||||
queryset = models.Gallery.objects.all()
|
||||
serializer_class = serializers.GallerySerializer
|
||||
Loading…
Reference in New Issue
Block a user