From 030c03b320d159e728e7b386a71799181de07766 Mon Sep 17 00:00:00 2001 From: Farid Chowdhury Date: Mon, 26 Sep 2022 07:14:05 +0600 Subject: [PATCH] made a demo version of the project --- accounts/admin.py | 4 + album/admin.py | 7 + album/migrations/0001_initial.py | 28 ++ album/models.py | 15 ++ album/serializers.py | 9 + album/templates/album/base.html | 389 ---------------------------- album/templates/album/homepage.html | 379 +++++---------------------- album/views.py | 29 +-- config/settings/base.py | 7 +- db.sqlite3 | Bin 147456 -> 151552 bytes profiles/admin.py | 4 + requirements.txt | 21 ++ templates/base.html | 14 + 13 files changed, 186 insertions(+), 720 deletions(-) create mode 100644 album/migrations/0001_initial.py delete mode 100644 album/templates/album/base.html diff --git a/accounts/admin.py b/accounts/admin.py index 8c38f3f..168e0d7 100644 --- a/accounts/admin.py +++ b/accounts/admin.py @@ -1,3 +1,7 @@ from django.contrib import admin +from .models import UserAccount + # Register your models here. + +admin.site.register(UserAccount) diff --git a/album/admin.py b/album/admin.py index 8c38f3f..0c7ec8c 100644 --- a/album/admin.py +++ b/album/admin.py @@ -1,3 +1,10 @@ from django.contrib import admin +from .models import Album + # Register your models here. + +class AlbumAdmin(admin.ModelAdmin): + list_display = ['id', 'image', 'is_verified'] + +admin.site.register(Album, AlbumAdmin) diff --git a/album/migrations/0001_initial.py b/album/migrations/0001_initial.py new file mode 100644 index 0000000..1fa0746 --- /dev/null +++ b/album/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# Generated by Django 3.2 on 2022-09-26 00:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Album', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('image', models.ImageField(upload_to='')), + ('is_verified', models.BooleanField(blank=True, default=False)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('modified_at', models.DateTimeField(auto_now=True)), + ], + options={ + 'verbose_name': 'Album', + 'verbose_name_plural': 'Albums', + }, + ), + ] diff --git a/album/models.py b/album/models.py index 71a8362..d38fccf 100644 --- a/album/models.py +++ b/album/models.py @@ -1,3 +1,18 @@ from django.db import models +from django.utils.translation import gettext_lazy as _ # Create your models here. + + +class Album(models.Model): + image = models.ImageField() + is_verified = models.BooleanField(default=False, blank=True) + + # Helpers + created_at = models.DateTimeField(auto_now_add=True) + modified_at = models.DateTimeField(auto_now=True) + + class Meta: + verbose_name = _('Album') + verbose_name_plural = _('Albums') + ordering = ('-id',) diff --git a/album/serializers.py b/album/serializers.py index e69de29..3cc7215 100644 --- a/album/serializers.py +++ b/album/serializers.py @@ -0,0 +1,9 @@ +from rest_framework import serializers + +from .models import Album + + +class AlbumCreateUpdateSerializer(serializers.ModelSerializer): + class Meta: + model = Album + fields = ('image',) diff --git a/album/templates/album/base.html b/album/templates/album/base.html deleted file mode 100644 index f101c3b..0000000 --- a/album/templates/album/base.html +++ /dev/null @@ -1,389 +0,0 @@ -{% extends 'base.html' %} - -{% block content %} - -
- - -
- -
-
-
-

Album example

-

- Something short and leading about the collection below—its contents, the - creator, etc. Make it short and sweet, but not too short so folks don't - simply skip over it entirely. -

-

- Main call to action - Secondary action -

-
-
- -
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
- -
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
- -
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
-
-
- -{% endblock content %} diff --git a/album/templates/album/homepage.html b/album/templates/album/homepage.html index f101c3b..61da1d5 100644 --- a/album/templates/album/homepage.html +++ b/album/templates/album/homepage.html @@ -1,5 +1,7 @@ {% extends 'base.html' %} +{% load humanize %} + {% block content %}
@@ -48,342 +50,91 @@ Album - +
+ {% if messages %} + {% for message in messages %} +
+
+
+ {{ message }} +
+
+
+ {% endfor %} +{% endif %}
-

Album example

-

- Something short and leading about the collection below—its contents, the - creator, etc. Make it short and sweet, but not too short so folks don't - simply skip over it entirely. -

-

- Main call to action - Secondary action -

+

Upload Album Photo

+
+ {% csrf_token %} +
+
+ + +
+
+ +
+
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - + + {% for album in albums %} +
+
+ Card image cap +
+
+ {% if album.is_verified %} + Verified + {% else %} + Unverified + {% endif %} + {% comment %}
+ +
{% endcomment %} + {{ album.created_at | naturaltime }}
- 9 mins
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
+ {% endfor %} -
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
-
-
- Card image cap -
-

- This is a wider card with supporting text below as a natural - lead-in to additional content. This content is a little bit - longer. -

-
-
- - -
- 9 mins -
-
-
-
{% endblock content %} + +{% block footer %} + + + +{% endblock footer %} + \ No newline at end of file diff --git a/album/views.py b/album/views.py index 15a7df7..4111443 100644 --- a/album/views.py +++ b/album/views.py @@ -1,9 +1,13 @@ +from django.contrib import messages from django.contrib.auth.mixins import LoginRequiredMixin from django.core.exceptions import PermissionDenied from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render from django.views.generic import CreateView, TemplateView +from .models import Album +from .serializers import AlbumCreateUpdateSerializer + # Create your views here. class HomePageView(TemplateView): @@ -14,25 +18,20 @@ class HomePageView(TemplateView): # NOTE: This will be used to update the active window in navbar context.update({ - 'contact_us_create': 'active' + 'contact_us_create': 'active', + 'albums': Album.objects.all() }) return context - # def post(self, request, *args, **kwargs) -> HttpResponse: - # data = { - # 'user': request.user.id, - # 'title': request.POST.get('title'), - # 'description': request.POST.get('description'), - # 'inquiry_type': request.POST.get('inquiry_type'), - # } - # serializer = ContactUsCreateSerializer(data=data) - - # serializer.is_valid(raise_exception=True) - # instance = serializer.save() + def post(self, request, *args, **kwargs) -> HttpResponse: + data = {'image': request.FILES.get('image')} - # send_new_inquiry_notification.delay(instance.id) + serializer = AlbumCreateUpdateSerializer(data=data) + serializer.is_valid(raise_exception=True) - # messages.success(self.request, 'Enquiry submitted successfully.') + instance = serializer.save() - # return HttpResponseRedirect('/dashboard') + messages.success(self.request, 'Image uploaded successfully.') + + return HttpResponseRedirect('/') diff --git a/config/settings/base.py b/config/settings/base.py index d0913ff..661e36a 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -21,6 +21,11 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django.contrib.humanize', + + # Third party apps + 'rest_framework', + 'django_extensions', # Local apps 'accounts', @@ -28,8 +33,6 @@ INSTALLED_APPS = [ 'core', 'profiles', - # Third party apps - # .... ] MIDDLEWARE = [ diff --git a/db.sqlite3 b/db.sqlite3 index 1172d98f44c9dc435e17daed8cc751ea115a0dca..804c80e108d96c39adf5ca6e48bb74cdbacae79d 100644 GIT binary patch delta 2299 zcmb7GO>7%Q6rS-q_HGh;(vrwP+jwyrK`D0k-(IVw-6SSWYUj`SYpTexy=%vby}OB> z#7R}TE*DOyZ4luCMF@#YkuX8(feUADAV44xLLh-qRXCv@C@SN1+9oLoG1`5eo%b{E zeeauHU%pITew(^_=zs_S=*IVhAzgcchhlB+1|ko+@M1^vN1M*JW47jxYSk;vtxQJ~ z@N_H5d}^hz={?+WK%yBY%<^GT41^etW0~!rpFZ5wz6G2p4$#Nw7jy;PL~-;L%GIi; z(4lrG;fLx%QqLNRq*}=7iM)}uc_>1pwmzGJ?ax19CyvA9N@+e}YRiROv6wS-8hs8r z9%T6Nck||n?o;(;J0giLXyuf!q{BlH{DWQ6hF;S2QlhkOYGgAuC(#r@m(g!%YP*#g zKyAqG@ie?GXL2)p`ptF{O#*ZWeS0x7pz{kX+4aYmKbvgLc>rNma{hC9SdKZ7ikdF&;ZhoyZQo zkW8v-!{o^JyR&mP2Sh4BYOOkhD%Gc;8&ppz6gckjxG0J;Q;TYbOBCmmoG2aTBnFS8 zq51M!W?etGva+GY@);u=nVcEZk1nm2$4>MP&d5U}#o+nAaYbcTH+rLST`f+>4PoMZ zv3GDXzcxC?MNV0{^VU3$oR^GnNdbje<3?L>*v=?g4af`@r1q z$cY~b0#F~$+1m&jMK+yRWsE->MdwhYR{hKUWD@})Nn6ru$xcfi*`B@e-Wh^!Avc{r z$YhJz5^Z^|g{)OSX|8nAO#nV~Y!|e>Nu90(O)GU``n*`*?calR-J*f~j!kF7W;gV8 zo5pj)=I{}0<9+r~FX{$K)u}er+ppeUZO4tdgNcHR{Ry=nB#u-2ka2B8lc2HHLrB~f zBoyUpc?BEiCy4uFlQRqw;o)jaF;bala(y`^L-uUQ0b&}i4RyLT+2j7R8kr6(Gp zeY-SUvqMm{=L*T}>x1yn*<3NPsx9X-IZgG^DZ|LqL&M|r&_p!)0_{sLYsr#^Nm}yJ zDxQ^c1#P#!V5pWSHrV=L6t=_WZ8&$|`;OW6@Vai=NgMhDpg++c7{FhV$7;RJPC&{! zsWx;M6A9hL%G;>JPEgQB5EwaJx(%HK=q+@zR%K9S&PD+R`IC@>yE)5-S$v5Bi4$Z& zmMm`2MruJzm+0rDV;3&^8r@cXVfvyEmzh_KczVG%P^2FgK6~lXENPpA|F{Da7K33S z!UaOCAjl%OcMI-+ZGn#n=85}z;Qqc={lZw27Jivt`Cuo*Bwd79}HV#QS4o@jgBu zi}U4#rjKW1Vb(~ehkL>kT#w224-Bkl6f+uJTPjR1=Sx!)niyHm_Ls)uW}vt%Nay@X zjajpL$})bIsef#C-a`T>$wK38^Bq9nVTyc?0$oIm`Y*g1K0gBVBlh_kaYqP+`u82` zTywYw0s0UvqNDCF-LJU^YgNfzIqPtMW0ay4l6oSQ)OBq+uwZ8Q(GO=U2ZF4~GtxfI z4l#LAWKK6ZfQM9+De@ Kr@GymVCZiZ>S410 delta 447 zcmZozz}e8iIYC-bm4Sgl1&Cq5bfS(iqw2 diff --git a/profiles/admin.py b/profiles/admin.py index 8c38f3f..0b95cfc 100644 --- a/profiles/admin.py +++ b/profiles/admin.py @@ -1,3 +1,7 @@ from django.contrib import admin +from .models import UserProfile + # Register your models here. + +admin.site.register(UserProfile) diff --git a/requirements.txt b/requirements.txt index cd0ae47..abdd336 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,8 @@ asgiref==3.5.2 astroid==2.12.10 +asttokens==2.0.8 autopep8==1.7.0 +backcall==0.2.0 backports.zoneinfo==0.2.1 black==22.8.0 certifi==2022.9.24 @@ -9,27 +11,46 @@ click==8.1.3 decorator==5.1.1 dill==0.3.5.1 Django==3.2 +django-filter==22.1 +djangorestframework==3.14.0 +executing==1.1.0 idna==3.4 +importlib-metadata==4.12.0 +ipython==8.5.0 isort==5.10.1 +jedi==0.18.1 lazy-object-proxy==1.7.1 +Markdown==3.4.1 +matplotlib-inline==0.1.6 mccabe==0.7.0 mypy-extensions==0.4.3 +parso==0.8.3 pathspec==0.10.1 +pexpect==4.8.0 +pickleshare==0.7.5 Pillow==9.2.0 platformdirs==2.5.2 +prompt-toolkit==3.0.31 +ptyprocess==0.7.0 +pure-eval==0.2.2 pycodestyle==2.9.1 +Pygments==2.13.0 pylint==2.15.3 python-decouple==3.6 pytz==2022.2.1 requests==2.27.1 six==1.16.0 sqlparse==0.4.3 +stack-data==0.5.1 toml==0.10.2 tomli==2.0.1 tomlkit==0.11.4 tqdm==4.64.1 +traitlets==5.4.0 typing-extensions==4.3.0 urllib3==1.26.12 validators==0.18.2 +wcwidth==0.2.5 weaviate-client==3.8.0 wrapt==1.14.1 +zipp==3.8.1 diff --git a/templates/base.html b/templates/base.html index 4476626..f0b2797 100644 --- a/templates/base.html +++ b/templates/base.html @@ -20,6 +20,12 @@ + + + {% block head %} + + {% endblock head %} + @@ -38,6 +44,9 @@ + + + @@ -49,5 +58,10 @@ + + + {% block footer %} + + {% endblock footer %}