From 1956a644802cd4ff78418b04af09e4d9ca4713f0 Mon Sep 17 00:00:00 2001 From: s460930 Date: Mon, 30 Nov 2020 21:41:59 +0100 Subject: [PATCH 01/24] SMART-29 created django project --- rest-app/smartpicasso/db.sqlite3 | 0 rest-app/smartpicasso/manage.py | 22 ++++ .../smartpicasso/smartpicasso/__init__.py | 0 .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 180 bytes .../__pycache__/settings.cpython-38.pyc | Bin 0 -> 2325 bytes .../__pycache__/urls.cpython-38.pyc | Bin 0 -> 962 bytes .../__pycache__/wsgi.cpython-38.pyc | Bin 0 -> 593 bytes rest-app/smartpicasso/smartpicasso/asgi.py | 16 +++ .../smartpicasso/smartpicasso/settings.py | 120 ++++++++++++++++++ rest-app/smartpicasso/smartpicasso/urls.py | 21 +++ rest-app/smartpicasso/smartpicasso/wsgi.py | 16 +++ 11 files changed, 195 insertions(+) create mode 100644 rest-app/smartpicasso/db.sqlite3 create mode 100755 rest-app/smartpicasso/manage.py create mode 100644 rest-app/smartpicasso/smartpicasso/__init__.py create mode 100644 rest-app/smartpicasso/smartpicasso/__pycache__/__init__.cpython-38.pyc create mode 100644 rest-app/smartpicasso/smartpicasso/__pycache__/settings.cpython-38.pyc create mode 100644 rest-app/smartpicasso/smartpicasso/__pycache__/urls.cpython-38.pyc create mode 100644 rest-app/smartpicasso/smartpicasso/__pycache__/wsgi.cpython-38.pyc create mode 100644 rest-app/smartpicasso/smartpicasso/asgi.py create mode 100644 rest-app/smartpicasso/smartpicasso/settings.py create mode 100644 rest-app/smartpicasso/smartpicasso/urls.py create mode 100644 rest-app/smartpicasso/smartpicasso/wsgi.py diff --git a/rest-app/smartpicasso/db.sqlite3 b/rest-app/smartpicasso/db.sqlite3 new file mode 100644 index 0000000..e69de29 diff --git a/rest-app/smartpicasso/manage.py b/rest-app/smartpicasso/manage.py new file mode 100755 index 0000000..3de5872 --- /dev/null +++ b/rest-app/smartpicasso/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'smartpicasso.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/rest-app/smartpicasso/smartpicasso/__init__.py b/rest-app/smartpicasso/smartpicasso/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rest-app/smartpicasso/smartpicasso/__pycache__/__init__.cpython-38.pyc b/rest-app/smartpicasso/smartpicasso/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..efa64f6aecee426ec9afc8b3df26285eb71f9f30 GIT binary patch literal 180 zcmWIL<>g`kf{uuz@gVv!h(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o10UKO;XkRlgvy zq^L4mzcevdzc@8FwYa3nNWZu;Q$IL2v8W^JMFW3M8 literal 0 HcmV?d00001 diff --git a/rest-app/smartpicasso/smartpicasso/__pycache__/settings.cpython-38.pyc b/rest-app/smartpicasso/smartpicasso/__pycache__/settings.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ab6fb4d99b08bd1f79d65674532ab855c4e7e262 GIT binary patch literal 2325 zcmb7FTXWM!6qX&uc1#R`a4Qs0dI1cLLJgNfQt?M*l#$1U<#0dtdnuGW;P>`ESdW;^RxJiusgpyZ{}dm%!6na`hvLt^N@o) z6kq|0{hV2Z6R-#+I0>g<2~PL(<_S1sF2ZtO01?i@IXDj&;9_5-8Tjb6*w2_HxMZG$ z%kVMD!IjGbTz#FT8S@le0|{lW!OC#_WH^3GGkwuqg3rv;@VR*geOSitEPm(Ux_KUM z=tB9Xy_OM#Vs+Q{`o6>n=hW*nspp3hbM24^v}-fwOF`)Gk}j8v#ZBUo(B=fBoqg#B z3>8;xaH%ITo@$IFZ%7eCC~1tmF0aY!sQnOuT|Xoe_0WcEbLx8%{`i2RRqBv0&N-CNG}TV>*H+;vy(#O3nJ`o?Ovw?e*Z1Vg@b5oFS=f^+I6R?bZ%Xv*8DDG+-LxMnt}$wu&}q_5Db8-w9?MR$G!5zp zkkeqt>odZWKz=~sfL9ii`~$V}SZh{Iv0B^GlY-iATf|hCRN{hyjUDSoX_hY}dCS74Y*|S@z}Dx`oiK~R zOA3~iHjtDa66QNENsLV4Wmui9dZpETm@F7tqg_`GO;47#_03u; zU$0fvG+~m3s%ogISv|R^c8o_>Th;aL)>hSeqSkB3Y+;_2>S}Ydqi$+erB&4su-4El zvxP}f=%B;3wQriES$*wJGs&ei!^AxpXrq$)@v9JC#k~)QH_w!T?-B)r67D}&BHP8= z0&|>)cNMlz6+OL7+oQ`=!3gnHOkia?t!EbFn^+F^lfrkd50OLe<4r9vj)SuP_+DHR^C>O&4(Fw;fK>6w_?Nhh7DjLG EA6B{&`Tzg` literal 0 HcmV?d00001 diff --git a/rest-app/smartpicasso/smartpicasso/__pycache__/urls.cpython-38.pyc b/rest-app/smartpicasso/smartpicasso/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..755d8ecdf7c7d0afa68c8df1345e8840019eae3d GIT binary patch literal 962 zcma)5!H&}~5KYpwTe4mF1>e$0-I!f&6(G=x6)PcxSSq1hvTp3QF0mci4p6RK_!T~c zpU9OHSB_j@oTgGhLRw3)Y-jxDy*Hl4$w}nF`11B!{xk5r?{3o{1K2!)&)kQJdYMOk z8kD{WvcPxiK{*g%7Wy6wX~=@@a69@Oto`hW4zImrL}~yvf@oXuf*7OF;`Ix3q2!9M zYfUUyGK$`87`mx-SrKcQmgWYP+*qVlZJBWw46+Kn=j?+?(WTNzD9sR;E2TvXfvS=b z!;oQY9w8VTYb!Iyn5x30bW7w~Ra$LXVbekh%p`u0o?)wil))|-LwbXwXCH|GEHjTT zYgssU`?M|SS&E)giikv9R7%@9LMyEV61$vKRd?8nKkwpO$snMo5UzsQ%`}c@ovw`% zY=$He>{0C2aS~mWVA$yrgwY=A|5zxyVcHQ%TcZwioP{+4W9d`e92K&Ht*jILx+ z)|AUNn9$~P(h4Z%!Jn(v7z9+HJT8_^6SV5AobT=0mm_tCA4qnwv(}Vbvt5>IjlsY} zrq~^{xN(w1Kj6K3iQfzf6NC2X&ZrZ*_icYnyY`R4O{o*Wz`1nuU-kNh?wnl-I;bG0@1Sjbx(A~-nST|&KEM>7jZ@g``15{_t|hn3v1@Gq;u=2*W86l z7TkMFD`%HbgfvM;fx_p?dhj$XfbP1uQv9O=%01;&Td`7btY8g_uDO%jlHnQzoy~Yv zDFhADn%NBT&Ty2r4yZIZRc{N_8U&Y~&ZUA!)B_}o5GwziF<}dziX}It{l}@Wnt@@@ z(kEs*7kPGic{v&nv;6JF z$>h!H^ Date: Mon, 30 Nov 2020 22:10:22 +0100 Subject: [PATCH 02/24] SMART-29 user app and django and implement UserManager and User class for further login logic --- .idea/.gitignore | 8 ++ .idea/SmartPicasso.iml | 15 ++++ .idea/misc.xml | 6 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ rest-app/{smartpicasso => }/db.sqlite3 | 0 rest-app/{smartpicasso => }/manage.py | 0 .../{smartpicasso => }/__init__.py | 0 .../__pycache__/__init__.cpython-38.pyc | Bin .../__pycache__/settings.cpython-38.pyc | Bin .../__pycache__/urls.cpython-38.pyc | Bin .../__pycache__/wsgi.cpython-38.pyc | Bin rest-app/smartpicasso/app/user/__init__.py | 0 rest-app/smartpicasso/app/user/admin.py | 3 + rest-app/smartpicasso/app/user/apps.py | 5 ++ .../app/user/migrations/__init__.py | 0 rest-app/smartpicasso/app/user/models.py | 72 ++++++++++++++++++ rest-app/smartpicasso/app/user/tests.py | 3 + rest-app/smartpicasso/app/user/views.py | 3 + .../smartpicasso/{smartpicasso => }/asgi.py | 0 .../{smartpicasso => }/settings.py | 0 .../smartpicasso/{smartpicasso => }/urls.py | 0 .../smartpicasso/{smartpicasso => }/wsgi.py | 0 23 files changed, 129 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/SmartPicasso.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml rename rest-app/{smartpicasso => }/db.sqlite3 (100%) rename rest-app/{smartpicasso => }/manage.py (100%) rename rest-app/smartpicasso/{smartpicasso => }/__init__.py (100%) rename rest-app/smartpicasso/{smartpicasso => }/__pycache__/__init__.cpython-38.pyc (100%) rename rest-app/smartpicasso/{smartpicasso => }/__pycache__/settings.cpython-38.pyc (100%) rename rest-app/smartpicasso/{smartpicasso => }/__pycache__/urls.cpython-38.pyc (100%) rename rest-app/smartpicasso/{smartpicasso => }/__pycache__/wsgi.cpython-38.pyc (100%) create mode 100644 rest-app/smartpicasso/app/user/__init__.py create mode 100644 rest-app/smartpicasso/app/user/admin.py create mode 100644 rest-app/smartpicasso/app/user/apps.py create mode 100644 rest-app/smartpicasso/app/user/migrations/__init__.py create mode 100644 rest-app/smartpicasso/app/user/models.py create mode 100644 rest-app/smartpicasso/app/user/tests.py create mode 100644 rest-app/smartpicasso/app/user/views.py rename rest-app/smartpicasso/{smartpicasso => }/asgi.py (100%) rename rest-app/smartpicasso/{smartpicasso => }/settings.py (100%) rename rest-app/smartpicasso/{smartpicasso => }/urls.py (100%) rename rest-app/smartpicasso/{smartpicasso => }/wsgi.py (100%) diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/SmartPicasso.iml b/.idea/SmartPicasso.iml new file mode 100644 index 0000000..b09cc2b --- /dev/null +++ b/.idea/SmartPicasso.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..1763e15 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c2ddc48 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/rest-app/smartpicasso/db.sqlite3 b/rest-app/db.sqlite3 similarity index 100% rename from rest-app/smartpicasso/db.sqlite3 rename to rest-app/db.sqlite3 diff --git a/rest-app/smartpicasso/manage.py b/rest-app/manage.py similarity index 100% rename from rest-app/smartpicasso/manage.py rename to rest-app/manage.py diff --git a/rest-app/smartpicasso/smartpicasso/__init__.py b/rest-app/smartpicasso/__init__.py similarity index 100% rename from rest-app/smartpicasso/smartpicasso/__init__.py rename to rest-app/smartpicasso/__init__.py diff --git a/rest-app/smartpicasso/smartpicasso/__pycache__/__init__.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/__init__.cpython-38.pyc similarity index 100% rename from rest-app/smartpicasso/smartpicasso/__pycache__/__init__.cpython-38.pyc rename to rest-app/smartpicasso/__pycache__/__init__.cpython-38.pyc diff --git a/rest-app/smartpicasso/smartpicasso/__pycache__/settings.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc similarity index 100% rename from rest-app/smartpicasso/smartpicasso/__pycache__/settings.cpython-38.pyc rename to rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc diff --git a/rest-app/smartpicasso/smartpicasso/__pycache__/urls.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/urls.cpython-38.pyc similarity index 100% rename from rest-app/smartpicasso/smartpicasso/__pycache__/urls.cpython-38.pyc rename to rest-app/smartpicasso/__pycache__/urls.cpython-38.pyc diff --git a/rest-app/smartpicasso/smartpicasso/__pycache__/wsgi.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/wsgi.cpython-38.pyc similarity index 100% rename from rest-app/smartpicasso/smartpicasso/__pycache__/wsgi.cpython-38.pyc rename to rest-app/smartpicasso/__pycache__/wsgi.cpython-38.pyc diff --git a/rest-app/smartpicasso/app/user/__init__.py b/rest-app/smartpicasso/app/user/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rest-app/smartpicasso/app/user/admin.py b/rest-app/smartpicasso/app/user/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/rest-app/smartpicasso/app/user/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/rest-app/smartpicasso/app/user/apps.py b/rest-app/smartpicasso/app/user/apps.py new file mode 100644 index 0000000..35048d4 --- /dev/null +++ b/rest-app/smartpicasso/app/user/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class UserConfig(AppConfig): + name = 'user' diff --git a/rest-app/smartpicasso/app/user/migrations/__init__.py b/rest-app/smartpicasso/app/user/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rest-app/smartpicasso/app/user/models.py b/rest-app/smartpicasso/app/user/models.py new file mode 100644 index 0000000..8cd8a2d --- /dev/null +++ b/rest-app/smartpicasso/app/user/models.py @@ -0,0 +1,72 @@ +""" +@author p.dolata +""" + +import uuid +from django.db import models +from django.contrib.auth.models import BaseUserManager, AbstractBaseUser + + +class UserManager(BaseUserManager): + """ + Manager for custom user model + """ + + def create_user(self, email, password=None): + """ + Create and return `User` with an email, username and password + :param email: email of user + :param password: password of user + :return: model of new user + """ + if not email: + raise ValueError('Users must have an email address') + user = self.model(email=self.normalize_email(email)) + user.set_password(password) + user.save(using=self._db) + + return user + + def create_superuser(self, email, password): + """ + Create and return a `User` with superuser (admin) permissions + :param email: email of superuser + :param password: password of superuser + :return: model of new superuser + """ + if password is None: + raise TypeError('Superusers must have a password') + user = self.create_user(email, password) + user.is_superuser = True + user.is_staff = True + user.save() + + return user + + +class User(AbstractBaseUser): + """ + Model of user + """ + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) + email = models.EmailField( + verbose_name='email address', + max_length=255, + unique=True + ) + is_active = models.BooleanField(default=True) + is_staff = models.BooleanField(default=False) + is_superuser = models.BooleanField(default=False) + USERNAME_FIELD = 'email' + REQUIRED_FIELDS = [] + + objects = UserManager() + + def __str__(self): + return self.email + + class Meta: + """ + Class to set table name in database + """ + db_table = 'login' diff --git a/rest-app/smartpicasso/app/user/tests.py b/rest-app/smartpicasso/app/user/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/rest-app/smartpicasso/app/user/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/rest-app/smartpicasso/app/user/views.py b/rest-app/smartpicasso/app/user/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/rest-app/smartpicasso/app/user/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/rest-app/smartpicasso/smartpicasso/asgi.py b/rest-app/smartpicasso/asgi.py similarity index 100% rename from rest-app/smartpicasso/smartpicasso/asgi.py rename to rest-app/smartpicasso/asgi.py diff --git a/rest-app/smartpicasso/smartpicasso/settings.py b/rest-app/smartpicasso/settings.py similarity index 100% rename from rest-app/smartpicasso/smartpicasso/settings.py rename to rest-app/smartpicasso/settings.py diff --git a/rest-app/smartpicasso/smartpicasso/urls.py b/rest-app/smartpicasso/urls.py similarity index 100% rename from rest-app/smartpicasso/smartpicasso/urls.py rename to rest-app/smartpicasso/urls.py diff --git a/rest-app/smartpicasso/smartpicasso/wsgi.py b/rest-app/smartpicasso/wsgi.py similarity index 100% rename from rest-app/smartpicasso/smartpicasso/wsgi.py rename to rest-app/smartpicasso/wsgi.py From 91e974ac1086bd4d1919060bd894e9e2b11946b4 Mon Sep 17 00:00:00 2001 From: s460930 Date: Mon, 30 Nov 2020 22:17:41 +0100 Subject: [PATCH 03/24] SMART-29 done first db migration --- rest-app/db.sqlite3 | Bin 0 -> 143360 bytes .../__pycache__/settings.cpython-38.pyc | Bin 2325 -> 2339 bytes .../user/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 176 bytes .../app/user/__pycache__/admin.cpython-38.pyc | Bin 0 -> 217 bytes .../user/__pycache__/models.cpython-38.pyc | Bin 0 -> 2418 bytes .../app/user/migrations/0001_initial.py | 30 ++++++++++++++++++ .../__pycache__/0001_initial.cpython-38.pyc | Bin 0 -> 1014 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 187 bytes rest-app/smartpicasso/settings.py | 2 ++ 9 files changed, 32 insertions(+) create mode 100644 rest-app/smartpicasso/app/user/__pycache__/__init__.cpython-38.pyc create mode 100644 rest-app/smartpicasso/app/user/__pycache__/admin.cpython-38.pyc create mode 100644 rest-app/smartpicasso/app/user/__pycache__/models.cpython-38.pyc create mode 100644 rest-app/smartpicasso/app/user/migrations/0001_initial.py create mode 100644 rest-app/smartpicasso/app/user/migrations/__pycache__/0001_initial.cpython-38.pyc create mode 100644 rest-app/smartpicasso/app/user/migrations/__pycache__/__init__.cpython-38.pyc diff --git a/rest-app/db.sqlite3 b/rest-app/db.sqlite3 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..891a8cc5fd58a8adf0f725f438f54a8985d0d2b9 100644 GIT binary patch literal 143360 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 K@J!y#5d{FZNjZA} delta 195 zcmW-XI}gE797lV(^rm`SeR$RTO?(2e`2ZG?@Lw!Hx#?~ zl5?hWbuX@5Noi;ar}b+q&a%#)=gI7#vSc6!6A~6|WE%8G{! zm6$6=5&>DLqPEMTUe(ZuQz0W8O|+7yiT1ypf4d=5obu?AgFd<706dAlzf diff --git a/rest-app/smartpicasso/app/user/__pycache__/__init__.cpython-38.pyc b/rest-app/smartpicasso/app/user/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e38ba1190df4112805d6ac43fa1fbf28f80368db GIT binary patch literal 176 zcmWIL<>g`kg4C#^@gVv!h(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o10WKO;XkRlgvy zq^L4mzcevdzc@8FwYa3nNWZu;Q$IL2v8W^9IJP5tc0zaknNvY$~%CV9mSFF0p1%2^t}h_aM-BO#5hw`o*Ns884*xHF8YhWPB^VvPbP0=743gaNON@&Om%TMfAp7fIX4LeNREn3&+A)yD#53!1zEf*SzV2u(&p3t(8xenCRJ1{gXTimTREHmE*t z`|!-S^Y;PYq?ART`X!+7H85>4n&3u@2P1{;4m7z5Vn(D_Kx|IPuViK%L3?S=$Sa87 zDS2+qte4izd_{;cvyN<-cbIjmHHeK}{jPUF9Crk#1@~#je8G!SWd0)r`^bM57l$zH z^OVNPR~lSK)7o-MrF@nPw)C<&rGlol?PmS*^L@SOZJWi~O@GllZ&@SRtb>8m8Gm-x zS>+>2>8B7n|ByaKT=RV?V}eWhnkYwOhjcrojI)EFq1r#wq~t>(a-kd@YSqnhk+ltH>;}{jX9?7jpUaetC3>?*Zcs#9{Bd$Q~lo!ir=}Wn&6?A`JbYN0vNfV+LmvKRFo|omK zk6~13(OWzs_1=_rM5y{Jj$+++c0C_QD7+L2dU~2Worg#0)R9 zbs%6@*%+Yes^-NG7Vu}w9`j?>WPG2NNugZM;)0G7UUl?c_vf|Z z&A)IYSmizCVw_8^gR9yp{Uu6xc2FFuMw!J=N*)m5gQ+e769T=(gMDneJYyuGigN!9(H&^ zt8bTg=S~7O$1idps++H4;OlZ8XFh{Z;~2hzOIzh6`9YkG0!LhfZN!HtuA}$}gmT$9 z(jHchv*eSqapP^UllZv;LRlh!&M3HYku!m(R;|6gd)s$oo-k#XWz3*pgS@Fs=(dOW z0n(Fo<@IjodBSN{+qdB2!N)p=%)Jk;#8vdSzPCGkFuJufjPBkW-rrW;2g9HC?mZZ8 z*ZQs|xN7F(BR(ml_zV{!$cqjn@R|;wN$lWxHi%73{Qc8#Jh-+V=(gD~T}#^rEgdHD zC77!gJEGY^-e=?bq}S&9B+m*FkNfx!rC(QiVZj1{LDTTGuZsXF_q+PWe~)C4cz10Z K%SX@Zefl3F8fc~f literal 0 HcmV?d00001 diff --git a/rest-app/smartpicasso/app/user/migrations/0001_initial.py b/rest-app/smartpicasso/app/user/migrations/0001_initial.py new file mode 100644 index 0000000..584ea9e --- /dev/null +++ b/rest-app/smartpicasso/app/user/migrations/0001_initial.py @@ -0,0 +1,30 @@ +# Generated by Django 3.1.3 on 2020-11-30 21:16 + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('password', models.CharField(max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('email', models.EmailField(max_length=255, unique=True, verbose_name='email address')), + ('is_active', models.BooleanField(default=True)), + ('is_staff', models.BooleanField(default=False)), + ('is_superuser', models.BooleanField(default=False)), + ], + options={ + 'db_table': 'login', + }, + ), + ] diff --git a/rest-app/smartpicasso/app/user/migrations/__pycache__/0001_initial.cpython-38.pyc b/rest-app/smartpicasso/app/user/migrations/__pycache__/0001_initial.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bd43f5353ff050c06c6c1d583b4421c39821c02b GIT binary patch literal 1014 zcmYjQJ8#rL5VqHQceZnvgoIa#D3DG-91tZ!5#b?qkpT~U z<>h|r=PYHu!%PKf@Y;g__*V}&`g8szNI9?rZ`?bhJ>HnvIF~amYFQS>_VW@@nf)Ud zyE=vhc4(S!WY9}}@KOeT8qB)&bp zabSBBC5jWvi$*CO(K(h$cs1sB05}zms%?lMYcWx1S1K)Yp%>W+E^I_8NTK8@+8*XY zsOrwU|!r(0NUTx@i@{ zBM<8>Qmt=25FahB1WHwwugX4(5jD7TByKo+v5tnCo6 z!UC{3l4vw@Nv!N@6gBR-Zqd}4o{e^og?{C3vZEIidM9)2V03u+=0)f7rjcNK&OWj6 zOIL|5FnnH?3PsVOxFk_sM}GJ8eLB81e<3+8b4)5x>%~dZh&(Zvqp9`d#4KcTK=rQQ z$|HK|GNFpr4@Ffa#j+n^g`kg4C#^@gVv!h(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o10DKO;XkRlgvy zq^L4mzcevdzc@8FwYa3nNWZu;Q$IL2v8W^ Date: Mon, 30 Nov 2020 22:42:24 +0100 Subject: [PATCH 04/24] SMART-29 created user_profile app, UserProfile class and made migration --- .idea/dataSources.xml | 11 +++++++ rest-app/db.sqlite3 | Bin 143360 -> 155648 bytes .../__pycache__/settings.cpython-38.pyc | Bin 2339 -> 2374 bytes .../user/__pycache__/models.cpython-38.pyc | Bin 2418 -> 2416 bytes .../migrations/0002_auto_20201130_2119.py | 17 ++++++++++ .../0002_auto_20201130_2119.cpython-38.pyc | Bin 0 -> 530 bytes rest-app/smartpicasso/app/user/models.py | 2 +- .../smartpicasso/app/user_profile/__init__.py | 0 .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 184 bytes .../__pycache__/admin.cpython-38.pyc | Bin 0 -> 225 bytes .../__pycache__/models.cpython-38.pyc | Bin 0 -> 1124 bytes .../smartpicasso/app/user_profile/admin.py | 3 ++ .../smartpicasso/app/user_profile/apps.py | 5 +++ .../user_profile/migrations/0001_initial.py | 30 ++++++++++++++++++ .../app/user_profile/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-38.pyc | Bin 0 -> 1055 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 195 bytes .../smartpicasso/app/user_profile/models.py | 24 ++++++++++++++ .../smartpicasso/app/user_profile/tests.py | 3 ++ .../smartpicasso/app/user_profile/views.py | 3 ++ rest-app/smartpicasso/settings.py | 3 +- 21 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 .idea/dataSources.xml create mode 100644 rest-app/smartpicasso/app/user/migrations/0002_auto_20201130_2119.py create mode 100644 rest-app/smartpicasso/app/user/migrations/__pycache__/0002_auto_20201130_2119.cpython-38.pyc create mode 100644 rest-app/smartpicasso/app/user_profile/__init__.py create mode 100644 rest-app/smartpicasso/app/user_profile/__pycache__/__init__.cpython-38.pyc create mode 100644 rest-app/smartpicasso/app/user_profile/__pycache__/admin.cpython-38.pyc create mode 100644 rest-app/smartpicasso/app/user_profile/__pycache__/models.cpython-38.pyc create mode 100644 rest-app/smartpicasso/app/user_profile/admin.py create mode 100644 rest-app/smartpicasso/app/user_profile/apps.py create mode 100644 rest-app/smartpicasso/app/user_profile/migrations/0001_initial.py create mode 100644 rest-app/smartpicasso/app/user_profile/migrations/__init__.py create mode 100644 rest-app/smartpicasso/app/user_profile/migrations/__pycache__/0001_initial.cpython-38.pyc create mode 100644 rest-app/smartpicasso/app/user_profile/migrations/__pycache__/__init__.cpython-38.pyc create mode 100644 rest-app/smartpicasso/app/user_profile/models.py create mode 100644 rest-app/smartpicasso/app/user_profile/tests.py create mode 100644 rest-app/smartpicasso/app/user_profile/views.py diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..16e6268 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,11 @@ + + + + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:$PROJECT_DIR$/rest-app/db.sqlite3 + + + \ No newline at end of file diff --git a/rest-app/db.sqlite3 b/rest-app/db.sqlite3 index 891a8cc5fd58a8adf0f725f438f54a8985d0d2b9..a5478a487dea049f6c3dce6f5e1191f8b700d583 100644 GIT binary patch delta 1141 zcmZ`%O-vI(6yE6%U0U10*isbR4#lO#QrKy&rL77`R!~S0Y~u;Gg)Y(nZBq(*ps_`x zMlOJg(&sv4U@{X@N4%->KS@fwr_MRm>2aA`J`PL9W? zxWZG*vEEbI@AkA}uNS+#e!Y?~1SAYi(=IkTn@O@R+C^jRrdb!pK5^m1*y*N`3;VIp z?>^nyPGgS;uUYCR^#BzX+j;?6_}Jz+YETP(kuXBQU+@F`3}3@1a1mxPg5F@F)BP-@{k%F}x4wAzRG%KvO-bAgIOzxP|$Fdvc`B7F3sg zr1qWmh4!H~Tg-d3Y^?$~0XY}vuCrxlp*jV?fQ)fdT!t%8Shf;l6Vb%AiiFvq01iM# zW3h6$Y3=Kq2P zlLd?UOEPAm>72?)QQ$VrL`SE%y-IE0|B3D)rYpptP}li>23gBtR%GX6NkF0TczPzo zCZf}v70pG{f*NVNhi*o}fe;FY`}_HqF;F{FzSDxNsflEQV-vH}qg;BIhDDk{5dhLr z@t74!_1v!AdMF&cI2dNo5OaYUVuIbw6=da8J;HF!-p(pxA0ydDS}bk(!d` zjwY`dmGuSk3*~D$dr^hEVO7Q07r)TEH8-Xe1?Vl4E=P_}y z0~Kr9z}4_T)EI)P?fa7%wb+?h_%}9kvluk7TeFLci!(OomLw+Sq=Hp|2}S21SH}=n wg%C$4A6Eq>u$Yp9#&q2jMu+Wb`Hb@tm}R&hO=rKr2z2ox?(L6mGs=Yk0FKdP*#H0l diff --git a/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc index 37ff6a6f9ebf1c8ccd971651349afc89f60c4148..167151aacf6aea37d2c7c2873f9f23977e8f752b 100644 GIT binary patch delta 220 zcmZ21bWDghl$V!_0SLm9j>daUhF-3X~OFCl|Z;DJ5Uy5vsTq;|Nyfj0K!W^bd z#wh+2#S|r=8pRZ4FsTA2RWljWS)v3|)S?7a)T4w_SfYf1SOkbgQ#duE#8Nba88o#v zzEfk8lP%6oEGj9;OinB=&euyUD9|e{PA!TrD9TUE%t_rW%sh>iv10Nn4jEQPrtd7g JlTUI)0RTXGIo1FG delta 185 zcmW-Xy$-=p7>0ZFP@$*Vqw25quQX<(s}Re#FuZco8?d^DMr<}$Aa)yzTahptop_Vy z8J@fkd6r@&M9I*5Z|>`HCL(srW{bVDs014V4k~crLF!UQm2CLR07nf0>S&;;c*@W^ zam7fWO%6gt+X6am1Km?DWmG{Aef{ZS@b~cVQOXo27i01elLV)##@Ey^AuGUiX(Y+z W6X&jT^O$G5!?PHgUv3{>Mfw3#3@#D? diff --git a/rest-app/smartpicasso/app/user/__pycache__/models.cpython-38.pyc b/rest-app/smartpicasso/app/user/__pycache__/models.cpython-38.pyc index a8aa9a7ecc530e6b3b578dbe9c9663e44c291ff8..bc5624af33562f037b0591c32af1430cbd4ca052 100644 GIT binary patch delta 64 zcmew)^g)O>l$V!_0SIm+9*xi6$h(T2wMYoaoxG3TlU)PI@Y58Xe2`savJyuZqsC-A RPVvb{I4l{pCja9o0RSlT5lsL9 delta 56 zcmew$^ht;}l$V!_0SG3=AB`{A$h(T2{T6FZetKr!$Vi+)8m?`@!F zF#e-O$at+5%7k$oCp53}CTE3mNLQ*@DU9E+Ss^CTf$3A~6iQ7%X(@SIxN}J9Q_G5N zCFG(O6&KY!7g`|;GDp`%Bh*-OQQSF{31ls{Zr*@8w0FAgTapJ^3R1I1tsY6sN}@$6 zbfZ$DS2>xMOf|RpoM|nIvib?DYoeW6Z&fEaKV&yAVx6UwwT+}{oW@CV8q+jM&PVl1 zVf%H@F70~gW3={s4i;g`k0*$1j@gVv!h(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o10YKO;XkRlgvy zq^L4mzcevdzc@8FwYa3nNWZu;Q$IL2v8W^Gu19yfY)exT)F4ib;qQ>?HjWFPqQNG3%_*O$=1l9*#2=6T*@r7^>d{5nv e_Mq_!Gl%x1O9jL8rE9zK+F03?YQyQ>o6Nq9T0AxY literal 0 HcmV?d00001 diff --git a/rest-app/smartpicasso/app/user_profile/__pycache__/models.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/__pycache__/models.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f37a9a61be95139833d4a0e3155f0639e3f06ba3 GIT binary patch literal 1124 zcmZuwO>fgM7|w^&rfFKXf&d{7xuFQrNP`nXsME#}hYh5ymvFG$`R$r6U$Ya5_ByWn zA^Zof{0Uz%N4U$LL}u`?YEJOjs%`8WF2GK}xq*&YO)2~PPEfg7>G zO>U)TY~tHat;~*XQ^!b3GADLS^(>D95}= zS;f3tT+=uSP1VT?4yi}I1f1q9gWEl99P?hrKG78Ni)x`db)H<+aH|h6B%+Tm;Ug%L z*J-MpS<3Ruf21_AVuDlNL)ey*TQT7_woBGKTkVdIp+;qn=6cKBk5 z`^dF{pC6+|kwH|lN~|uUnq`rM3}hwtBDqSUQ`EWokeo9qiwIAqddA8!k~&&$qB^im zENbuGxLhfsd)2x~eeGS7*y14?C*er!Y6c?>cQxoDf&Yu4deiB+geEU+UEe*}KRwt#e1p}fj_MsOm}o!u=82G1qmb&QY-7fLxhQg=d7aHb zG<^QZ(OM5Q8O>PV1UW>|)JNvX9O5&wnq26%q#t2g_4tzI7sZ&*nkM4M+X{_Qp|K`6 hZk1_yJI#e}mipiR%6-)y=xcq!q>Dg^Yx<^d{{on}C+PqH literal 0 HcmV?d00001 diff --git a/rest-app/smartpicasso/app/user_profile/admin.py b/rest-app/smartpicasso/app/user_profile/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/rest-app/smartpicasso/app/user_profile/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/rest-app/smartpicasso/app/user_profile/apps.py b/rest-app/smartpicasso/app/user_profile/apps.py new file mode 100644 index 0000000..91ad550 --- /dev/null +++ b/rest-app/smartpicasso/app/user_profile/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class UserProfileConfig(AppConfig): + name = 'user_profile' diff --git a/rest-app/smartpicasso/app/user_profile/migrations/0001_initial.py b/rest-app/smartpicasso/app/user_profile/migrations/0001_initial.py new file mode 100644 index 0000000..316b371 --- /dev/null +++ b/rest-app/smartpicasso/app/user_profile/migrations/0001_initial.py @@ -0,0 +1,30 @@ +# Generated by Django 3.1.3 on 2020-11-30 21:41 + +from django.db import migrations, models +import django.db.models.deletion +import uuid + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('user', '0002_auto_20201130_2119'), + ] + + operations = [ + migrations.CreateModel( + name='UserProfile', + fields=[ + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('first_name', models.CharField(max_length=50)), + ('last_name', models.CharField(max_length=50)), + ('phone_number', models.CharField(blank=True, max_length=10, null=True)), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to='user.user')), + ], + options={ + 'db_table': 'user_profile', + }, + ), + ] diff --git a/rest-app/smartpicasso/app/user_profile/migrations/__init__.py b/rest-app/smartpicasso/app/user_profile/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rest-app/smartpicasso/app/user_profile/migrations/__pycache__/0001_initial.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/migrations/__pycache__/0001_initial.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ea880556af41be5e29f6547ce59510327ff88a26 GIT binary patch literal 1055 zcmY*Y$&S=W5Ot>QvRzAWY#L5n=1_+zR}~0pq!9u&i#V`IO<#OTWpzYVr`sE8TbklJ zoRIoM_yc}`pU5kx{sJU8G?C?EXwu4XzK9G*yom7eXw-LT`K!<3lj}HNEV#Nn0uO1| z_ep>QEOT;}u$(8HSB@Bn+H{14~@sE0%cZr#%}5gEYh_?Sl`DcJJIALHyJX)X%@9ZFP8y`U=^pID9_(Ao%7+8ErWjm5cPZvR+#nV= zP4wbt`frGg*Vd@bt?6_+7qV?iF`v$-v)SFLn9pW^o53-eU+Z$IGBjMl)3Ij)z@==n z#)Jr}kqfd6Dy?#<*WwJ5ur&8dkpxwV>M zby^lEiZ)-MzOdaKyT)H+vN+Sbgp60TS*Cq^45}`ncacqgVg+4}%0f^tut77_n8^lV z6WH*kG$AZRm+H`77uzq8n`e_Vy`{noY7>;zrm-)_2PPC7e<4g?2 zy$A)WPz{kaL%<3Pz~V$_^FLVb#E0I-^zO?Iy{xS z(~n*i_@*S$!5*ZtSe1suf;d=qG zUZ2IS%;Oq!tQ$R#>$QrHs8`Kvbt3D!j5X>1l2sMgR$FbgR&ljb@voteX;@}rOMFtT zwf(z7+VvfK;GWAbJ>O%T-()-V9I)HpdB`1p$-jD+o7>~SL>;pUEH>5Z3iQYS%1QTQ lO@4CLWBRuK(+V5z7uW6-lg@ Date: Mon, 30 Nov 2020 22:54:03 +0100 Subject: [PATCH 05/24] SMART-29 created serializers for user model --- rest-app/smartpicasso/app/user/serializers.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 rest-app/smartpicasso/app/user/serializers.py diff --git a/rest-app/smartpicasso/app/user/serializers.py b/rest-app/smartpicasso/app/user/serializers.py new file mode 100644 index 0000000..e55c7bc --- /dev/null +++ b/rest-app/smartpicasso/app/user/serializers.py @@ -0,0 +1,40 @@ +""" +@author p.dolata +""" +from rest_framework import serializers + +from smartpicasso.app.user.models import User +from smartpicasso.app.user_profile.models import UserProfile + + +class UserSerializer(serializers.ModelSerializer): + """ + Class to manage serializing UserProfile + """ + + class Meta: + model = UserProfile + fields = ('first_name', 'last_name', 'phone_number') + + +class UserRegistrationSerializer(serializers.ModelSerializer): + """ + Class to manage serializing user during registration + """ + profile = UserSerializer(required=False) + + class Meta: + model = User + fields = ('email', 'password', 'profile') + extra_kwargs = {'password': {'write_only': True}} + + def create(self, validated_data): + profile_data = validated_data.pop('profile') + user = User.objects.create_user(**validated_data) + UserProfile.objects.create( + user=user, + first_name=profile_data['first_name'], + last_name=profile_data['last_name'], + phone_number=profile_data['phone_number'], + ) + return user From 5ada608121e6ad7332049d5587e1d985f64a7d49 Mon Sep 17 00:00:00 2001 From: s460930 Date: Mon, 30 Nov 2020 22:56:52 +0100 Subject: [PATCH 06/24] SMART-29 created .gitignore --- .gitignore | 2 ++ .idea/SmartPicasso.iml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..caa32e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +*.iml \ No newline at end of file diff --git a/.idea/SmartPicasso.iml b/.idea/SmartPicasso.iml index b09cc2b..fdf8ca2 100644 --- a/.idea/SmartPicasso.iml +++ b/.idea/SmartPicasso.iml @@ -7,7 +7,9 @@ - + + + From 88634347339a3df1c6ac30f3b12f4c1fd7afeeb1 Mon Sep 17 00:00:00 2001 From: s460930 Date: Mon, 30 Nov 2020 23:13:32 +0100 Subject: [PATCH 07/24] SMART-29 created .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index caa32e6..8eea92b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea/ -*.iml \ No newline at end of file +*.iml +.idea \ No newline at end of file From 6002ba94ec9ae8cd817df788c8b483fb699ee007 Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 17:37:25 +0100 Subject: [PATCH 08/24] SMART-31 added JWT settings to settings.py --- rest-app/db.sqlite3 | Bin 155648 -> 155648 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 180 -> 167 bytes .../__pycache__/settings.cpython-38.pyc | Bin 2374 -> 2374 bytes .../__pycache__/urls.cpython-38.pyc | Bin 962 -> 949 bytes .../user/__pycache__/__init__.cpython-38.pyc | Bin 176 -> 176 bytes .../app/user/__pycache__/admin.cpython-38.pyc | Bin 217 -> 217 bytes .../user/__pycache__/models.cpython-38.pyc | Bin 2416 -> 2416 bytes .../__pycache__/0001_initial.cpython-38.pyc | Bin 1014 -> 1014 bytes .../0002_auto_20201130_2119.cpython-38.pyc | Bin 530 -> 530 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 187 -> 187 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 184 -> 184 bytes .../__pycache__/admin.cpython-38.pyc | Bin 225 -> 225 bytes .../__pycache__/models.cpython-38.pyc | Bin 1124 -> 1124 bytes .../__pycache__/0001_initial.cpython-38.pyc | Bin 1055 -> 1055 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 195 -> 195 bytes rest-app/smartpicasso/settings.py | 47 +++++++++++++++--- 16 files changed, 41 insertions(+), 6 deletions(-) diff --git a/rest-app/db.sqlite3 b/rest-app/db.sqlite3 index a5478a487dea049f6c3dce6f5e1191f8b700d583..7f21a54066032ecedc2fb835d7e381a4befacd79 100644 GIT binary patch delta 231 zcmZoTz}awsbAmLZ@oP{D|c1Na;-27cXl;(H4M)1 z@i%uiu*~;$$uIEEGz`(s%=0pJtwErs1!r{ delta 48 zcmV-00MGw`zzKlB36L8BB9RmbWDgVl$V!_0SNL7Hgef;0st**1QP%N delta 19 ZcmX>mbWDgVl$V!_0SLm9Hgef;0st(J1MC0* diff --git a/rest-app/smartpicasso/__pycache__/urls.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/urls.cpython-38.pyc index 755d8ecdf7c7d0afa68c8df1345e8840019eae3d..74f8cc8ef2a557076e3ef024bdc551d86733e70a 100644 GIT binary patch delta 29 jcmX@azLlLTl$V!_0SNL7HgdT$GkQ!8Vs@OofLRFuVC@FC delta 29 jcmdnWeu$kbl$V!_0SG!GHgdT$GlotMVs@O|#;gwjVJ`-_ diff --git a/rest-app/smartpicasso/app/user/__pycache__/__init__.cpython-38.pyc b/rest-app/smartpicasso/app/user/__pycache__/__init__.cpython-38.pyc index e38ba1190df4112805d6ac43fa1fbf28f80368db..81428760ad4de6ca3747d79c685cf37d3156d47f 100644 GIT binary patch delta 18 YcmdnMxPg%?l$V!_0SNL7CUPwU03=of1^@s6 delta 18 YcmdnMxPg%?l$V!_0SHo~CUPwU03*x;<^TWy diff --git a/rest-app/smartpicasso/app/user/__pycache__/admin.cpython-38.pyc b/rest-app/smartpicasso/app/user/__pycache__/admin.cpython-38.pyc index 3a0fd21a96903049d0fbed7316700e1952166761..6218ee92be423cd4c0f009c0106558dcf4e1bdd5 100644 GIT binary patch delta 18 Ycmcb~c$1MUl$V!_0SNL7CUTtz04ebVfdBvi delta 18 Ycmcb~c$1MUl$V!_0SHo~CUTtz04Zk#VE_OC diff --git a/rest-app/smartpicasso/app/user/__pycache__/models.cpython-38.pyc b/rest-app/smartpicasso/app/user/__pycache__/models.cpython-38.pyc index bc5624af33562f037b0591c32af1430cbd4ca052..fe0252aa03c56b92f0b610530c14aa2f037513fa 100644 GIT binary patch delta 19 Zcmew$^g)O#l$V!_0SNL7HgctL0su3o1d#v$ delta 19 Zcmew$^g)O#l$V!_0SIm+Zsbbi1OPSC1nU3* diff --git a/rest-app/smartpicasso/app/user/migrations/__pycache__/0001_initial.cpython-38.pyc b/rest-app/smartpicasso/app/user/migrations/__pycache__/0001_initial.cpython-38.pyc index bd43f5353ff050c06c6c1d583b4421c39821c02b..5119f86eece0e378c9ed1e26dd37c451de62457e 100644 GIT binary patch delta 19 Zcmeyy{*9e0l$V!_0SNL7HgdgT1^_e<1qT2C delta 19 Zcmeyy{*9e0l$V!_0SJT>H*&pU1^_Xf1e^c> diff --git a/rest-app/smartpicasso/app/user/migrations/__pycache__/0002_auto_20201130_2119.cpython-38.pyc b/rest-app/smartpicasso/app/user/migrations/__pycache__/0002_auto_20201130_2119.cpython-38.pyc index dbd521eb92fe04a5e37d7d296f0624176fa57487..1cde8a2dec2561a8ba3094c61c8bac141b00dbc5 100644 GIT binary patch delta 19 ZcmbQlGKqyNl$V!_0SNL7Hga(=0RSV=15^M2 delta 19 ZcmbQlGKqyNl$V!_0SF!>Zsg)%0stl}1GWGF diff --git a/rest-app/smartpicasso/app/user/migrations/__pycache__/__init__.cpython-38.pyc b/rest-app/smartpicasso/app/user/migrations/__pycache__/__init__.cpython-38.pyc index e3d73a60dded812b8e52c68db44a37a57ef4e87a..e34e9eb8b6ebb15e714d8cd8fc7d57071078ba4c 100644 GIT binary patch delta 18 YcmdnZxSNqHl$V!_0SNL7CUR{A043K1CjbBd delta 18 YcmdnZxSNqHl$V!_0SHo~CUR{A03}TX2LJ#7 diff --git a/rest-app/smartpicasso/app/user_profile/__pycache__/__init__.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/__pycache__/__init__.cpython-38.pyc index cc998a8880f0e47f1d9eb185665f53d1bbc2af25..90b0343ccc4d3e9778e309b6320731bc96ac7b80 100644 GIT binary patch delta 18 YcmdnNxPy@^l$V!_0SNL7CUUI<03~h&9smFU delta 18 YcmdnNxPy@^l$V!_0SGjbCUUI<03*`_$p8QV diff --git a/rest-app/smartpicasso/app/user_profile/__pycache__/admin.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/__pycache__/admin.cpython-38.pyc index bea1b456d2146ceaf225e62c9da39ad70cc85e5b..1f0e3406b910ba802ec1a8c794a459e4c3f8e00e 100644 GIT binary patch delta 18 YcmaFJ_>hq+l$V!_0SNL7CURW|04oUunE(I) delta 18 YcmaFJ_>hq+l$V!_0SGjbCURW|04Z(+L;wH) diff --git a/rest-app/smartpicasso/app/user_profile/__pycache__/models.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/__pycache__/models.cpython-38.pyc index f37a9a61be95139833d4a0e3155f0639e3f06ba3..48150205b2012ba1a9396a13b501d41f5c364aa8 100644 GIT binary patch delta 19 ZcmaFD@q~jbl$V!_0SNL7HgZL=001zC1XKV3 delta 19 ZcmaFD@q~jbl$V!_0SLaNZRCn#0RS^{1kV5f diff --git a/rest-app/smartpicasso/app/user_profile/migrations/__pycache__/0001_initial.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/migrations/__pycache__/0001_initial.cpython-38.pyc index ea880556af41be5e29f6547ce59510327ff88a26..e354c63832b91e1970d5603f142b2c1144e77107 100644 GIT binary patch delta 19 ZcmbQwF`t7gl$V!_0SNL7Hgbuw001UP1BCzp delta 19 ZcmbQwF`t7gl$V!_0SH*rH*$%x001MO0}=oL diff --git a/rest-app/smartpicasso/app/user_profile/migrations/__pycache__/__init__.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/migrations/__pycache__/__init__.cpython-38.pyc index 0f13581fd6947732554249d9017c9d2c5f522451..8f1df471de95c7aae8e37b5f4d0ad1686c189f50 100644 GIT binary patch delta 18 YcmX@ic$kqZl$V!_0SNL7CUWfr04DDQKL7v# delta 18 YcmX@ic$kqZl$V!_0SGjbCUWfr03}od>Hq)$ diff --git a/rest-app/smartpicasso/settings.py b/rest-app/smartpicasso/settings.py index f6c121c..ee23a99 100644 --- a/rest-app/smartpicasso/settings.py +++ b/rest-app/smartpicasso/settings.py @@ -10,12 +10,12 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ """ +from datetime import timedelta from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent - # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ @@ -27,7 +27,6 @@ DEBUG = True ALLOWED_HOSTS = [] - # Application definition INSTALLED_APPS = [ @@ -72,7 +71,6 @@ TEMPLATES = [ WSGI_APPLICATION = 'smartpicasso.wsgi.application' - # Database # https://docs.djangoproject.com/en/3.1/ref/settings/#databases @@ -83,7 +81,6 @@ DATABASES = { } } - # Password validation # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators @@ -102,7 +99,6 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] - # Internationalization # https://docs.djangoproject.com/en/3.1/topics/i18n/ @@ -116,8 +112,47 @@ USE_L10N = True USE_TZ = True - # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = '/static/' + +AUTH_USER_MODEL = 'user.User' +REST_FRAMEWORK = { + 'DEFAULT_PERMISSION_CLASSES': [ + 'rest_framework.permissions.IsAuthenticated', + 'rest_framework.permissions.IsAdminUser' + ], + 'DEFAULT_AUTHENTICATION_CLASSES': [ + 'rest_framework_jwt.authentication.JSONWebTokenAuthentication' + ] +} + +JWT_AUTH = { + 'JWT_ENCODE_HANDLER': + 'rest_framework_jwt.utils.jwt_encode_handler', + 'JWT_DECODE_HANDLER': + 'rest_framework_jwt.utils.jwt_decode_handler', + 'JWT_PAYLOAD_HANDLER': + 'rest_framework_jwt.utils.jwt_payload_handler', + 'JWT_PAYLOAD_GET_USER_ID_HANDLER': + 'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler', + 'JWT_RESPONSE_PAYLOAD_HANDLER': + 'rest_framework_jwt.utils.jwt_response_payload_handler', + + 'JWT_SECRET_KEY': 'SECRET_KEY', + 'JWT_GET_USER_SECRET_KEY': None, + 'JWT_PUBLIC_KEY': None, + 'JWT_PRIVATE_KEY': None, + 'JWT_ALGORITHM': 'HS256', + 'JWT_VERIFY': True, + 'JWT_VERIFY_EXPIRATION': True, + 'JWT_LEEWAY': 0, + 'JWT_EXPIRATION_DELTA': timedelta(days=30), + 'JWT_AUDIENCE': None, + 'JWT_ISSUER': None, + 'JWT_ALLOW_REFRESH': False, + 'JWT_REFRESH_EXPIRATION_DELTA': timedelta(days=30), + 'JWT_AUTH_HEADER_PREFIX': 'Bearer', + 'JWT_AUTH_COOKIE': None, +} From 837709d5535ca6d34409669aecb7465de78833ac Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 17:48:39 +0100 Subject: [PATCH 09/24] SMART-31 created serializer for user login --- .gitignore | 1 + rest-app/smartpicasso/app/user/serializers.py | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/.gitignore b/.gitignore index 82472cb..50f3221 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea/ *.iml .idea +*__pycache__/ diff --git a/rest-app/smartpicasso/app/user/serializers.py b/rest-app/smartpicasso/app/user/serializers.py index e55c7bc..e5dee9f 100644 --- a/rest-app/smartpicasso/app/user/serializers.py +++ b/rest-app/smartpicasso/app/user/serializers.py @@ -1,11 +1,17 @@ """ @author p.dolata """ +from django.contrib.auth import authenticate +from django.contrib.auth.models import update_last_login from rest_framework import serializers +from rest_framework_jwt.settings import api_settings from smartpicasso.app.user.models import User from smartpicasso.app.user_profile.models import UserProfile +JWT_PAYLOAD_HANDLER = api_settings.JWT_PAYLOAD_HANDLER +JWT_ENCODE_HANDLER = api_settings.JWT_ENCODE_HANDLER + class UserSerializer(serializers.ModelSerializer): """ @@ -38,3 +44,27 @@ class UserRegistrationSerializer(serializers.ModelSerializer): phone_number=profile_data['phone_number'], ) return user + + +class UserLoginSerializer(serializers.Serializer): + """ + Class to manage serializing user during singing in + """ + email = serializers.CharField(max_length=255) + password = serializers.CharField(max_length=128, write_only=True) + token = serializers.CharField(max_length=255, read_only=True) + + def validate(self, data): + email = data.get('email', None) + password = data.get('password', None) + user = authenticate(email=email, password=password) + if user is None: + raise serializers.ValidationError('An user with provided email and password is not found') + try: + payload = JWT_PAYLOAD_HANDLER(user) + jwt_token = JWT_ENCODE_HANDLER(payload) + update_last_login(None, user) + except User.DoesNotExist: + raise serializers.ValidationError('User with given email and password does not exist') + + return {'email': user.email, 'token': jwt_token} From 5065f040fadc7160e8fc4e66a8a686c3579b1361 Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 18:01:35 +0100 Subject: [PATCH 10/24] SMART-31 created endpoint for logging the user --- .gitignore | 1 + .../__pycache__/settings.cpython-38.pyc | Bin 2374 -> 3500 bytes .../__pycache__/wsgi.cpython-38.pyc | Bin 593 -> 580 bytes rest-app/smartpicasso/app/user/views.py | 28 ++++++++++++++++-- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 50f3221..3269869 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.iml .idea *__pycache__/ +__pycache__/ diff --git a/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc index caacdb3dd9d64236575420a8d2c9694e6624cc36..7445662b07835205a8b61749dc56b8b4e51a7f35 100644 GIT binary patch delta 1521 zcmaJ>OLH4V5Z+m>o{?X&Y$vvHAO;h~MnH(eD*-mrDB5_fRqd{#crL@nJ*?N!t5$NQ z;)@QPIr(a;pg2**1@afD{0LpCqKX?QE>tD-t{h8Ah-YeMr@O!Yx_ch`B=gHszcw+E zlCVAQJmGsYlJrL)jJG)yzQWO6B$5OYlYoHSAWfOcBv?lpk*2~FA_+xAza>A!ew6m( z`*D^4g(V@%Qm(|#K@8%MfFz{g9He2wO|Udf!W8tUVFofV3t2bLCSZ=8BtmtYk!m*DMiekYvQJmM-W1Mjj~ zxXiMc$Q+J&91DX`5I1# zSA5a!@o#*mDIT`{2lRLBd!p6zcAcJp!?m-q(DYg%=ZzO}eE(rD z?~IuGNS?oA8I`)YZ?_+a)>srY<*@i7EvYr#=2dELYnG)M6<*L)%c2%rd2Ul{c9~Xe zt)SXt_QUo634YM?8r?jm!9{Dg-3P(-j0)?vI zHcZVfZ?jY&-le8i+F^5}HK+HgnyK1-ye>nGPHA1;Vc7t4VhpZQk?OX}(jjTBsNw$5 zAs(+{4R>fJwCK7~$LdO0V40ni8Vavc%@3*UGA~oL_$BUA6&^3@{ISyi4=bS{0|Laz;gfq delta 385 zcmYk2yG{Z@6ozMJhuvi_at9Gb@Pc5a4`5=VG@2MAn&>nu`jc@93W9|lg^#e&iWn_T z?05kS^&x0|4lg4%{wM#J^XHu6!7@)gcMxq;d*nkw&FPD$Dg%N{F@DtY64>p*K9FD|C3vJ~e6%1HD8uJC)4H@I16n zJ#S=m>Q`qi|D?-;OS|lhtXg$rue$GTSC4{w`!)PTx_R}MZa%nkj-%JA<&L984X$y< a^}ux3Y=coo^)LR--C)5Al$V!_0SG!GHga8KWDK4BkkN6nD3d+_Z2Jdz diff --git a/rest-app/smartpicasso/app/user/views.py b/rest-app/smartpicasso/app/user/views.py index 91ea44a..a303436 100644 --- a/rest-app/smartpicasso/app/user/views.py +++ b/rest-app/smartpicasso/app/user/views.py @@ -1,3 +1,27 @@ -from django.shortcuts import render +from rest_framework import status +from rest_framework.generics import RetrieveAPIView +from rest_framework.permissions import AllowAny +from rest_framework.response import Response -# Create your views here. +from smartpicasso.app.user.serializers import UserLoginSerializer + + +class UserLoginView(RetrieveAPIView): + """ + View for user login + """ + permission_classes = (AllowAny,) + serializer_class = UserLoginSerializer + + def post(self, request): + serializer = self.serializer_class(data=request.data) + serializer.is_valid(raise_exception=True) + response = { + 'success': 'True', + 'status_code': status.HTTP_200_OK, + 'message': 'User logged in successfully', + 'token': serializer.data['token'] + } + status_code = status.HTTP_200_OK + + return Response(response, status=status_code) From 56cada31223e2b2ac6f622c824a8d8263d478ec3 Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 18:18:44 +0100 Subject: [PATCH 11/24] SMART-30 registered user login url --- rest-app/db.sqlite3 | Bin 155648 -> 155648 bytes .../__pycache__/settings.cpython-38.pyc | Bin 3500 -> 3500 bytes .../__pycache__/urls.cpython-38.pyc | Bin 949 -> 1015 bytes rest-app/smartpicasso/app/user/urls.py | 11 +++++++++++ rest-app/smartpicasso/urls.py | 3 ++- 5 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 rest-app/smartpicasso/app/user/urls.py diff --git a/rest-app/db.sqlite3 b/rest-app/db.sqlite3 index 7f21a54066032ecedc2fb835d7e381a4befacd79..6fe1bbc27b8def94acec1f68e49cddbb9556980c 100644 GIT binary patch delta 270 zcmZoTz}awsbAmLZ+C&*=MzzL-tqF`v{wsZ$u~6CFG?(P3U_u5 zPxnu(&<}Et3Uabc^VJSX&T;i9FwM3#GB7gGH8j#SFjO!!w=y)dGPTe%Ha0UgH8L@> zNJ=pZP@JD{p0)<5j1b_$t`~nVm diff --git a/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc index 7445662b07835205a8b61749dc56b8b4e51a7f35..092397f13661cccec3c5de43c5143dd0e5eb6f30 100644 GIT binary patch delta 19 ZcmZ1@y+)cVl$V!_0SIPQZsc0T3ji$i1djj! delta 19 ZcmZ1@y+)cVl$V!_0SGo1Y~)(R3ji%$1fKu^ diff --git a/rest-app/smartpicasso/__pycache__/urls.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/urls.cpython-38.pyc index 74f8cc8ef2a557076e3ef024bdc551d86733e70a..b91070ceaba81f431aa2fd768ea100840d2e7b35 100644 GIT binary patch delta 195 zcmdnW{+(Srl$V!_0SK;?AB#6(W?*;>;vfSSAjbiSiybCv%WCAZMzJz7q_U*2q_U>4 zHZwLe0oiP+Oj&GM?9EK+Oi>&u?7dmtVqka-;vfTNAjbiSiw!1f%StdZq_U*2q%vi(X0bIh zr87pcr?3VyXtHfA=wuRNyv0(GSdvl2mY9;8nWyik$uZfC*Qky09}0 Date: Tue, 1 Dec 2020 19:02:07 +0100 Subject: [PATCH 12/24] SMART-30 tests for authenticate endpoint --- rest-app/smartpicasso/app/__init__.py | 0 rest-app/smartpicasso/app/user/tests.py | 22 ++++++++++++++++++++-- rest-app/smartpicasso/app/user/urls.py | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 rest-app/smartpicasso/app/__init__.py diff --git a/rest-app/smartpicasso/app/__init__.py b/rest-app/smartpicasso/app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rest-app/smartpicasso/app/user/tests.py b/rest-app/smartpicasso/app/user/tests.py index 7ce503c..5e8f2b9 100644 --- a/rest-app/smartpicasso/app/user/tests.py +++ b/rest-app/smartpicasso/app/user/tests.py @@ -1,3 +1,21 @@ -from django.test import TestCase +from rest_framework.test import APITestCase, APIClient +from django.urls import reverse +from smartpicasso.app.user.models import User +from rest_framework import status -# Create your tests here. + +class UserApiTest(APITestCase): + client = APIClient() + + def test_login_when_user_non_exist(self): + url = reverse('authenticate') + response = self.client.post(url, {'email': 'non-exist', 'password': '123'}, format='json') + assert response.status_code == 400 + + def test_login_when_user_exist(self): + User.objects.create_user(email='test@test.com', password='test') + url = reverse('authenticate') + response = self.client.post(url, {'email': 'test@test.com', 'password': 'test'}, format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual(response.data['success'], 'True') + self.assertIn('token', response.data) diff --git a/rest-app/smartpicasso/app/user/urls.py b/rest-app/smartpicasso/app/user/urls.py index 66bf079..f12a788 100644 --- a/rest-app/smartpicasso/app/user/urls.py +++ b/rest-app/smartpicasso/app/user/urls.py @@ -7,5 +7,5 @@ from django.conf.urls import url from smartpicasso.app.user.views import UserLoginView urlpatterns = [ - url(r'^authenticate', UserLoginView.as_view()) + url(r'^authenticate', UserLoginView.as_view(), name='authenticate') ] From e724d92cc464bda7841e8a20a4fc1cda471e4969 Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 19:25:25 +0100 Subject: [PATCH 13/24] SMART-30 test for User model --- .../user/__pycache__/models.cpython-38.pyc | Bin 2416 -> 2416 bytes rest-app/smartpicasso/app/user/tests.py | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/rest-app/smartpicasso/app/user/__pycache__/models.cpython-38.pyc b/rest-app/smartpicasso/app/user/__pycache__/models.cpython-38.pyc index fe0252aa03c56b92f0b610530c14aa2f037513fa..b3aaace9242176886bcd1e533c65e587c5d749cd 100644 GIT binary patch delta 20 acmew$^g)O_l$V!_0SK129oxvA$_W5H2?eGA delta 20 acmew$^g)O_l$V!_0SNL7j&9^m Date: Tue, 1 Dec 2020 19:46:23 +0100 Subject: [PATCH 14/24] test jenkins --- .gitignore | 1 + .idea/.gitignore | 8 -------- .idea/SmartPicasso.iml | 17 ----------------- .idea/dataSources.xml | 11 ----------- .idea/misc.xml | 6 ------ .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ Jenkinsfile | 11 +++++++++-- rest-app/requirements.txt | 3 +++ 9 files changed, 13 insertions(+), 58 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/SmartPicasso.iml delete mode 100644 .idea/dataSources.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml create mode 100644 rest-app/requirements.txt diff --git a/.gitignore b/.gitignore index 3269869..3a5f20c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea/ +.idea/* *.iml .idea *__pycache__/ diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 73f69e0..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/SmartPicasso.iml b/.idea/SmartPicasso.iml deleted file mode 100644 index fdf8ca2..0000000 --- a/.idea/SmartPicasso.iml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml deleted file mode 100644 index 16e6268..0000000 --- a/.idea/dataSources.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - sqlite.xerial - true - org.sqlite.JDBC - jdbc:sqlite:$PROJECT_DIR$/rest-app/db.sqlite3 - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 1763e15..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index c2ddc48..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 00a16af..b1e3fad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,10 +2,17 @@ pipeline { agent any stages { + stage('Build') { + steps { + sh 'cd rest-app' + sh 'pip3 install -r requirements.txt' + } + } stage('Test') { steps { - echo 'Test pipeline' + sh 'cd rest-app' + sh 'python3 manage.py test' } } } -} \ No newline at end of file +} diff --git a/rest-app/requirements.txt b/rest-app/requirements.txt new file mode 100644 index 0000000..9bacae0 --- /dev/null +++ b/rest-app/requirements.txt @@ -0,0 +1,3 @@ +django +djangorestframework +djangorestframework-jwt From 534a7865c43d63edff9a0f2136cc48eea3857b76 Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 19:59:11 +0100 Subject: [PATCH 15/24] test jenkins --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index b1e3fad..421d167 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,6 +5,8 @@ pipeline { stage('Build') { steps { sh 'cd rest-app' + sh 'virtualenv venv' + sh '. venv/bin/activate' sh 'pip3 install -r requirements.txt' } } From fd1432e89a62211ccf6fcec1c96de567fdc6cbd6 Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 20:06:24 +0100 Subject: [PATCH 16/24] test jenkins --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 421d167..ef64cbb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,9 @@ pipeline { stages { stage('Build') { steps { + sh 'pwd' sh 'cd rest-app' + sh 'pwd' sh 'virtualenv venv' sh '. venv/bin/activate' sh 'pip3 install -r requirements.txt' From 1224e35bfe3fe20ada851ab3292fd6af44244e90 Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 19:46:23 +0100 Subject: [PATCH 17/24] build and test django in Jenkinsfile --- .gitignore | 1 + .idea/.gitignore | 8 -------- .idea/SmartPicasso.iml | 17 ----------------- .idea/dataSources.xml | 11 ----------- .idea/misc.xml | 6 ------ .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ Jenkinsfile | 11 +++++++++-- rest-app/requirements.txt | 3 +++ 9 files changed, 13 insertions(+), 58 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/SmartPicasso.iml delete mode 100644 .idea/dataSources.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml create mode 100644 rest-app/requirements.txt diff --git a/.gitignore b/.gitignore index 3269869..3a5f20c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea/ +.idea/* *.iml .idea *__pycache__/ diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 73f69e0..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/SmartPicasso.iml b/.idea/SmartPicasso.iml deleted file mode 100644 index fdf8ca2..0000000 --- a/.idea/SmartPicasso.iml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml deleted file mode 100644 index 16e6268..0000000 --- a/.idea/dataSources.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - sqlite.xerial - true - org.sqlite.JDBC - jdbc:sqlite:$PROJECT_DIR$/rest-app/db.sqlite3 - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 1763e15..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index c2ddc48..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 00a16af..b1e3fad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,10 +2,17 @@ pipeline { agent any stages { + stage('Build') { + steps { + sh 'cd rest-app' + sh 'pip3 install -r requirements.txt' + } + } stage('Test') { steps { - echo 'Test pipeline' + sh 'cd rest-app' + sh 'python3 manage.py test' } } } -} \ No newline at end of file +} diff --git a/rest-app/requirements.txt b/rest-app/requirements.txt new file mode 100644 index 0000000..9bacae0 --- /dev/null +++ b/rest-app/requirements.txt @@ -0,0 +1,3 @@ +django +djangorestframework +djangorestframework-jwt From 2cb31d70f09e1357f6f13372ac55726bc51d0942 Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 21:31:42 +0100 Subject: [PATCH 18/24] added field to migrations to prevent build error in jenkins --- rest-app/smartpicasso/app/user/migrations/0001_initial.py | 2 ++ .../smartpicasso/app/user/migrations/0002_auto_20201130_2119.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/rest-app/smartpicasso/app/user/migrations/0001_initial.py b/rest-app/smartpicasso/app/user/migrations/0001_initial.py index 584ea9e..896e01e 100644 --- a/rest-app/smartpicasso/app/user/migrations/0001_initial.py +++ b/rest-app/smartpicasso/app/user/migrations/0001_initial.py @@ -6,6 +6,8 @@ import uuid class Migration(migrations.Migration): + atomic = False + initial = True dependencies = [ diff --git a/rest-app/smartpicasso/app/user/migrations/0002_auto_20201130_2119.py b/rest-app/smartpicasso/app/user/migrations/0002_auto_20201130_2119.py index 4f74dfb..486f2c9 100644 --- a/rest-app/smartpicasso/app/user/migrations/0002_auto_20201130_2119.py +++ b/rest-app/smartpicasso/app/user/migrations/0002_auto_20201130_2119.py @@ -5,6 +5,8 @@ from django.db import migrations class Migration(migrations.Migration): + atomic = False + dependencies = [ ('user', '0001_initial'), ] From 63307a83882a8101a6d5194911a6a0f32b7e2953 Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 22:49:16 +0100 Subject: [PATCH 19/24] SMART-37 implemented registration view --- .../__pycache__/__init__.cpython-38.pyc | Bin 167 -> 167 bytes .../__pycache__/settings.cpython-38.pyc | Bin 3500 -> 3500 bytes .../__pycache__/urls.cpython-38.pyc | Bin 1015 -> 1015 bytes .../__pycache__/wsgi.cpython-38.pyc | Bin 580 -> 580 bytes .../user/__pycache__/__init__.cpython-38.pyc | Bin 176 -> 176 bytes .../app/user/__pycache__/admin.cpython-38.pyc | Bin 217 -> 217 bytes .../user/__pycache__/models.cpython-38.pyc | Bin 2416 -> 2416 bytes .../__pycache__/0001_initial.cpython-38.pyc | Bin 1014 -> 1028 bytes .../0002_auto_20201130_2119.cpython-38.pyc | Bin 530 -> 545 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 187 -> 187 bytes rest-app/smartpicasso/app/user/views.py | 25 ++++++++++++++++-- .../__pycache__/__init__.cpython-38.pyc | Bin 184 -> 184 bytes .../__pycache__/admin.cpython-38.pyc | Bin 225 -> 225 bytes .../__pycache__/models.cpython-38.pyc | Bin 1124 -> 1124 bytes .../__pycache__/0001_initial.cpython-38.pyc | Bin 1055 -> 1055 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 195 -> 195 bytes 16 files changed, 23 insertions(+), 2 deletions(-) diff --git a/rest-app/smartpicasso/__pycache__/__init__.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/__init__.cpython-38.pyc index 012896bbc20f5d4a2a54117c3a8d274e2ed8f6c9..f266be55a92b525670bd494536412d9b5c46ee9b 100644 GIT binary patch delta 19 ZcmZ3^xSWwYl$V!_0SG4a9Gl2J2LLKa1n&R< delta 19 ZcmZ3^xSWwYl$V!_0SNL7j!xvB0{|%U1hD`B diff --git a/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc index 092397f13661cccec3c5de43c5143dd0e5eb6f30..5b5865037fe9425e9bf83e0e5d76b99d6948d776 100644 GIT binary patch delta 19 ZcmZ1@y+)cVl$V!_0SG4aY~)(R3ji$_1egE- delta 19 ZcmZ1@y+)cVl$V!_0SIPQZsc0T3ji$i1djj! diff --git a/rest-app/smartpicasso/__pycache__/urls.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/urls.cpython-38.pyc index b91070ceaba81f431aa2fd768ea100840d2e7b35..74b3fd52bd0832a495c073c74b9c2eb2b89b19cf 100644 GIT binary patch delta 19 Zcmey){+*pGl$V!_0SG4aY~*^&3;;EU1xEk? delta 19 Zcmey){+*pGl$V!_0SK;?Z{&K*3;;H^1$F=c diff --git a/rest-app/smartpicasso/__pycache__/wsgi.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/wsgi.cpython-38.pyc index 4baa4a5ae6837441d900fe45ca887580f1f3b0eb..269351cdcfc2ff197e546f0837801c5067288685 100644 GIT binary patch delta 20 acmX@Ya)gCDl$V!_0SG4a9NWlk$pip1tpx4> delta 20 acmX@Ya)gCDl$V!_0SNL7j&9_(WC8#(83eEZ diff --git a/rest-app/smartpicasso/app/user/__pycache__/__init__.cpython-38.pyc b/rest-app/smartpicasso/app/user/__pycache__/__init__.cpython-38.pyc index 81428760ad4de6ca3747d79c685cf37d3156d47f..7a008fc13de5ed1c5ad00761da70068fc00e5ca8 100644 GIT binary patch delta 19 ZcmdnMxPg&7l$V!_0SG4a9Gl3!6aXug1quKF delta 19 ZcmdnMxPg&7l$V!_0SNL7j!xuW3IHlU1k3;c diff --git a/rest-app/smartpicasso/app/user/__pycache__/admin.cpython-38.pyc b/rest-app/smartpicasso/app/user/__pycache__/admin.cpython-38.pyc index 6218ee92be423cd4c0f009c0106558dcf4e1bdd5..01cd26348969e76516a1d59a4483c163e0a13e48 100644 GIT binary patch delta 19 Zcmcb~c$1Mkl$V!_0SG4a9Gl2}4gfKN1%&_r delta 19 Zcmcb~c$1Mkl$V!_0SNL7j!xu02LLcE1xEk? diff --git a/rest-app/smartpicasso/app/user/__pycache__/models.cpython-38.pyc b/rest-app/smartpicasso/app/user/__pycache__/models.cpython-38.pyc index b3aaace9242176886bcd1e533c65e587c5d749cd..7a0885a1992fa49bbf138578eaa7b11a4409d5c5 100644 GIT binary patch delta 19 Zcmew$^g)O#l$V!_0SG4aY~)Jg1OPPo1kL~e delta 19 Zcmew$^g)O#l$V!_0SK12ZRASh1OPQ<1m6Gv diff --git a/rest-app/smartpicasso/app/user/migrations/__pycache__/0001_initial.cpython-38.pyc b/rest-app/smartpicasso/app/user/migrations/__pycache__/0001_initial.cpython-38.pyc index 5119f86eece0e378c9ed1e26dd37c451de62457e..fccce74770a732773fa9c1f8727fbc1f9a1107c3 100644 GIT binary patch delta 284 zcmeyy-on8b%FD~e00etCAB$&UnaI~xzX-@nWr$)-VTfW%VT@ut#-7j1ou@ z4`$GmxW(z4nO>Awl9`|9HrbgmY4S40O^kw*Bbij$*%C|gb2F1C*D`go=>Yvxq%)a^ fxtLuA$mC#RncTu`C#4P&W&z8g61tP`FiQadNDx3E delta 255 zcmZqS_{Po`%FD~e00j93N8>**PvmQ>p9kcnGDI<^Fhnt>Fh((_GeohZvSzWRFr_f3 zvS)Fmu%s}ju=X;gF{Q8p`J5??K**lL(aQ`J;RK3srE+KSq;LU6xl*`$S%9KEKvCWl zUZ4nH3O`t#08oSv$QSHo1j-A6d0b!~CsT?rggaS*QB;UOMLd{6Q{onlWAY?sJ1I4gAPZOqmC%{| HidhN(PMtXj diff --git a/rest-app/smartpicasso/app/user/migrations/__pycache__/0002_auto_20201130_2119.cpython-38.pyc b/rest-app/smartpicasso/app/user/migrations/__pycache__/0002_auto_20201130_2119.cpython-38.pyc index 1cde8a2dec2561a8ba3094c61c8bac141b00dbc5..34c4c8a626f4a77737187501670febe8e5d44858 100644 GIT binary patch delta 162 zcmbQlvXF&0l$V!_0SNYPJ{Ipek+;Y~4aiAlh+<4(h+;}%jABkNoCDqOJN2= zmR=B_J%u%xL6hwkr*CF@QDRAEexBRJO*)Jm6Ys0Cvn7_~=Vm5PW@a>I;|Cg6#6Q`F sv5s8;$mC#RnY^D-TLU5tmIDzWsaqU2x%nxjIjMHcKwdEuklel#uTX3%84#p#=wUX)mpnV&atyAC7!#3!ng1sRRl_<;J0_$GTY*0F+^9Fxy6YHL6Q d!7?C%A4uHdu*uC&Da}c>V+QhynScZjGXPix9)$n^ diff --git a/rest-app/smartpicasso/app/user/migrations/__pycache__/__init__.cpython-38.pyc b/rest-app/smartpicasso/app/user/migrations/__pycache__/__init__.cpython-38.pyc index e34e9eb8b6ebb15e714d8cd8fc7d57071078ba4c..62d8e5b70e88d3ed03a0201522c41878e50f7972 100644 GIT binary patch delta 19 ZcmdnZxSNqXl$V!_0SG4a9Gl3!0RSy51uFmm delta 19 ZcmdnZxSNqXl$V!_0SNL7j!xv>001l21nmF- diff --git a/rest-app/smartpicasso/app/user/views.py b/rest-app/smartpicasso/app/user/views.py index a303436..ecb0a57 100644 --- a/rest-app/smartpicasso/app/user/views.py +++ b/rest-app/smartpicasso/app/user/views.py @@ -1,9 +1,9 @@ from rest_framework import status -from rest_framework.generics import RetrieveAPIView +from rest_framework.generics import RetrieveAPIView, CreateAPIView from rest_framework.permissions import AllowAny from rest_framework.response import Response -from smartpicasso.app.user.serializers import UserLoginSerializer +from smartpicasso.app.user.serializers import UserLoginSerializer, UserRegistrationSerializer class UserLoginView(RetrieveAPIView): @@ -25,3 +25,24 @@ class UserLoginView(RetrieveAPIView): status_code = status.HTTP_200_OK return Response(response, status=status_code) + + +class UserRegistrationView(CreateAPIView): + """ + View for user registration + """ + permission_classes = (AllowAny,) + serializer_class = UserRegistrationSerializer + + def post(self, request): + serializer = self.serializer_class(data=request.data) + serializer.is_valid(raise_exception=True) + serializer.save() + status_code = status.HTTP_201_CREATED + response = { + 'success': 'True', + 'status_code': status_code, + 'message': 'User registered successfully' + } + + return Response(response, status=status_code) diff --git a/rest-app/smartpicasso/app/user_profile/__pycache__/__init__.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/__pycache__/__init__.cpython-38.pyc index 90b0343ccc4d3e9778e309b6320731bc96ac7b80..6b25f622f576112f60d3465b4d8354ac09c3b4a4 100644 GIT binary patch delta 19 ZcmdnNxPy^9l$V!_0SG4a9Gl3!762^01tI_d delta 19 ZcmdnNxPy^9l$V!_0SNL7j!xuW3jix;1mpk! diff --git a/rest-app/smartpicasso/app/user_profile/__pycache__/admin.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/__pycache__/admin.cpython-38.pyc index 1f0e3406b910ba802ec1a8c794a459e4c3f8e00e..08118cc5d5a0f51ce01cebee94ac4fc8b24ff034 100644 GIT binary patch delta 19 ZcmaFJ_>hr1l$V!_0SG4a9Gl2}4FEE#1)Tr@ delta 19 ZcmaFJ_>hr1l$V!_0SNL7j!xvh1^_Ws1z!LF diff --git a/rest-app/smartpicasso/app/user_profile/__pycache__/models.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/__pycache__/models.cpython-38.pyc index 48150205b2012ba1a9396a13b501d41f5c364aa8..11e4dc95008ce57200a2532838a01292fa9dce43 100644 GIT binary patch delta 20 acmaFD@q~jrl$V!_0SG4a9NWkp$pQd5KLuC- delta 20 acmaFD@q~jrl$V!_0SNL7j&9_RWB~v-s|6YW diff --git a/rest-app/smartpicasso/app/user_profile/migrations/__pycache__/0001_initial.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/migrations/__pycache__/0001_initial.cpython-38.pyc index e354c63832b91e1970d5603f142b2c1144e77107..94e7772ebae22bca859d004989044af2256d95ce 100644 GIT binary patch delta 20 acmbQwF`t7wl$V!_0SG4a9NWk(!U6y;cLa$5 delta 20 acmbQwF`t7wl$V!_0SNL7j&9@@VF3Uv;{;0p diff --git a/rest-app/smartpicasso/app/user_profile/migrations/__pycache__/__init__.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/migrations/__pycache__/__init__.cpython-38.pyc index 8f1df471de95c7aae8e37b5f4d0ad1686c189f50..48eab08fa8b1530035b9522ce27a0f16441013b1 100644 GIT binary patch delta 19 ZcmX@ic$kqpl$V!_0SG4a9Gl3!0{|{m1w#M; delta 19 ZcmX@ic$kqpl$V!_0SNL7j!xv>0RSxi1qA>A From 516365cbc6d971df330c9b1e68e56b077fdb7e20 Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 22:51:14 +0100 Subject: [PATCH 20/24] SMART-38 register registration endpoint --- rest-app/smartpicasso/app/user/urls.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rest-app/smartpicasso/app/user/urls.py b/rest-app/smartpicasso/app/user/urls.py index f12a788..390985a 100644 --- a/rest-app/smartpicasso/app/user/urls.py +++ b/rest-app/smartpicasso/app/user/urls.py @@ -4,8 +4,9 @@ from django.conf.urls import url -from smartpicasso.app.user.views import UserLoginView +from smartpicasso.app.user.views import UserLoginView, UserRegistrationView urlpatterns = [ - url(r'^authenticate', UserLoginView.as_view(), name='authenticate') + url(r'^authenticate', UserLoginView.as_view(), name='authenticate'), + url(r'^register', UserRegistrationView.as_view(), name='register') ] From 18957651b8def3d3dce690923a41ecf6f0d2bace Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 23:00:42 +0100 Subject: [PATCH 21/24] SMART-38 removed one field in user profile --- rest-app/db.sqlite3 | Bin 155648 -> 167936 bytes rest-app/smartpicasso/app/user/serializers.py | 5 ++--- .../__pycache__/models.cpython-38.pyc | Bin 1124 -> 1060 bytes .../0002_remove_userprofile_phone_number.py | 19 ++++++++++++++++++ .../smartpicasso/app/user_profile/models.py | 1 - 5 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 rest-app/smartpicasso/app/user_profile/migrations/0002_remove_userprofile_phone_number.py diff --git a/rest-app/db.sqlite3 b/rest-app/db.sqlite3 index 6fe1bbc27b8def94acec1f68e49cddbb9556980c..02b81c542748fab5512fe98010b55b876000b0f2 100644 GIT binary patch delta 973 zcmaiy%}*0S7{>R52HKL296+iPF=>@rsWa2v*|tfQ3Th~n770R|n6jUMw7aFWe0ZTn z60Z~vJ!+zfiAh76CXjgY;>DBRIdJpnpMYC5u|!QXd6LOHljr?C^G@lLwe-feceTe$ zQIyBjO;fC?smdKc?X54o18koydC+;u%h;0jvfDNt@3TYPA5Akin&oQ4=~4Hb(*W#Scj7WbB@mrXT5B9Y?nQ(wd{$+!q%>? zoV227IK8$cVxG7#B4$9>rnJ5|m71EIc^K7Q*Hiws zyT*p;3q&oC#Qt^Ig3I)?g7x5=(c9=L{Q!-@(kZCy1+0wu_1&gi=jH0z8Qs}ocC4A* z-h!EF+7fd*V}h)SC?H}*3ldJ0M2VBJDr)A`uq-K%B+kb*c0Rjy;g2pcr(m$18Uq6Z2*ZH)L>*&BwT%f&_?bnyR!wFX(B9Zs!L@mnRH!JUXp_M< z14b3nfOEhi>6wr$^)z^Kc`!oa}fx3STSiK|J?j$K?;m9d3?`o?TVSw@xV z=d&5xB?~h0^HSsUN^_G^io{-JR%dBQ@ z58|0Is&2oK$7nKqc8vTaDJw>+gS>j?(k24AkU-%lzPs<|9rDx!Cih9 T31)N7$rtlQ7fn!Dv_Jp=UMWB7 diff --git a/rest-app/smartpicasso/app/user/serializers.py b/rest-app/smartpicasso/app/user/serializers.py index e5dee9f..cb69e9d 100644 --- a/rest-app/smartpicasso/app/user/serializers.py +++ b/rest-app/smartpicasso/app/user/serializers.py @@ -20,7 +20,7 @@ class UserSerializer(serializers.ModelSerializer): class Meta: model = UserProfile - fields = ('first_name', 'last_name', 'phone_number') + fields = ('first_name', 'last_name') class UserRegistrationSerializer(serializers.ModelSerializer): @@ -40,8 +40,7 @@ class UserRegistrationSerializer(serializers.ModelSerializer): UserProfile.objects.create( user=user, first_name=profile_data['first_name'], - last_name=profile_data['last_name'], - phone_number=profile_data['phone_number'], + last_name=profile_data['last_name'] ) return user diff --git a/rest-app/smartpicasso/app/user_profile/__pycache__/models.cpython-38.pyc b/rest-app/smartpicasso/app/user_profile/__pycache__/models.cpython-38.pyc index 11e4dc95008ce57200a2532838a01292fa9dce43..1aa4d7255859d909c737419499fb3717e8bdf01b 100644 GIT binary patch delta 209 zcmaFDv4n#+l$V!_0SMZ6AB#_!$UBRR707V_;^Mf88~sJx8B#b?xLO!exSE-w1X8$z z88mq&t1-@<{E+b&n=nvWk?`cTOlfK$W-$wp;9z87E)oSY{4@oN_&^HyL4*K^5S(nu zoaqRbErRF;iGo=oAQnhJ$T7t{Kmuft5Tg(yA0r@H~OokvSjh5aHcS)FaaS~FH4kw zJ3|V03Qr3|3Qsdrlwb;PFoP!FWD&->axX#VXtES>1F0e&AaRQ&uQVs;7Hd*YVqW&- zjf}_G#6VJFlWUpM)I@;HViq95!N|f~BmrdjX$lnyf)ogW2w@N*GMSS(Gcby$AR|97 zH9oI2Hz~CUthNYZ5=af0B@SYNOar;0m=8#Rj1^)OV&nrtAttb#CPxv-)*`9No0**j L&`p@k#v%s*KGibI diff --git a/rest-app/smartpicasso/app/user_profile/migrations/0002_remove_userprofile_phone_number.py b/rest-app/smartpicasso/app/user_profile/migrations/0002_remove_userprofile_phone_number.py new file mode 100644 index 0000000..7ee8a6a --- /dev/null +++ b/rest-app/smartpicasso/app/user_profile/migrations/0002_remove_userprofile_phone_number.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.3 on 2020-12-01 21:54 + +from django.db import migrations + + +class Migration(migrations.Migration): + + atomic = False + + dependencies = [ + ('user_profile', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='userprofile', + name='phone_number', + ), + ] diff --git a/rest-app/smartpicasso/app/user_profile/models.py b/rest-app/smartpicasso/app/user_profile/models.py index 1c0c2df..4da1ccf 100644 --- a/rest-app/smartpicasso/app/user_profile/models.py +++ b/rest-app/smartpicasso/app/user_profile/models.py @@ -15,7 +15,6 @@ class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile') first_name = models.CharField(max_length=50, unique=False) last_name = models.CharField(max_length=50, unique=False) - phone_number = models.CharField(max_length=10, unique=False, null=True, blank=True) class Meta: """ From 041587217304425545447a3b6704b7a73cc332ff Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 23:25:45 +0100 Subject: [PATCH 22/24] SMART-39 tests for UserLoginSerializer --- rest-app/smartpicasso/app/user/tests.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rest-app/smartpicasso/app/user/tests.py b/rest-app/smartpicasso/app/user/tests.py index a33d137..cc52c1c 100644 --- a/rest-app/smartpicasso/app/user/tests.py +++ b/rest-app/smartpicasso/app/user/tests.py @@ -4,6 +4,8 @@ from rest_framework import status from rest_framework.test import APITestCase, APIClient from smartpicasso.app.user.models import User +from smartpicasso.app.user.serializers import UserLoginSerializer +from rest_framework import serializers class UserApiTest(APITestCase): @@ -29,3 +31,18 @@ class UserTest(TestCase): email = 'test@test.com' user = User.objects.create_user(email=email, password='test') self.assertEqual(str(user), email) + + +class UserLoginSerializerTest(TestCase): + serializer = UserLoginSerializer() + + def test_validate_wrong_credentials(self): + data = {'email': 'test@test.com', 'password': '123'} + self.assertRaises(serializers.ValidationError, self.serializer.validate, data) + + def test_validate_success(self): + User.objects.create_user(email='test@test.com', password='test') + data = {'email': 'test@test.com', 'password': 'test'} + result = self.serializer.validate(data) + self.assertEqual(result['email'], 'test@test.com') + self.assertIn('token', result) From 4298190701022677d15b9942f8702fe6c4d48240 Mon Sep 17 00:00:00 2001 From: s460930 Date: Sat, 5 Dec 2020 19:07:25 +0100 Subject: [PATCH 23/24] SMART-39 tests for UserRegistrationSerializer --- rest-app/db.sqlite3 | Bin 167936 -> 167936 bytes .../user/__pycache__/models.cpython-38.pyc | Bin 2416 -> 2416 bytes rest-app/smartpicasso/app/user/tests.py | 45 ++++++++++++++++-- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/rest-app/db.sqlite3 b/rest-app/db.sqlite3 index 02b81c542748fab5512fe98010b55b876000b0f2..0aeefde76f76489d795545caff8a5e92ce52c00a 100644 GIT binary patch delta 526 zcmZozz}2vTYl1YR-b5K^M!m*_tqF`v{`0W#<}&by^Bv`rz#U<3tJv}g~TqPs0vM{tPG~L<2qRKGY+px;Q-MGx4#3G>5!ooDW&@0W`w7Aqb zti&}W+t$dy$UxW7NY}tr!O+~w)ZEI*OwZ85!o=7h(agfwIN8+DIL+M5B-zl+GS$c| zDJ9Lq#M02%!YI`wB|j&zBvG#*v81SyC)?N|JvT8kM=v=)ce^AX(`!Z^7Ji^(C-L9m z-_8$mEWf4-vo9kdLs>wIra#DMQkcF?p2-hr$OH!dQ~YcBC-6VtELhOMKYgt}lOPY0 zZ7kb?BH;!cO#D#{Ky^_Y8~yl$1DRNTB_(|gEYeI<%~C84%#BS<5|a{>Ow!T}ERs`A zEK^bq4NQ^)KyJ@=0eggy%cif*X9@?}vYi3wp*ujgtman*IhK$eOw;ewGig9H0>c8V Pk*J_xQfBt$1P28G#FdqT delta 166 zcmZozz}2vTYl1YR_Cy(HM(xIgtqF`v{&O+&Niy(<^Bv`r+}Oy?$K0sNJiUOINp8Cp zAJZvDE@u8o4E&S$@9=NmELhOO&!WQY%Q*c(K9j=qZSqWhK Date: Mon, 7 Dec 2020 06:25:32 +0100 Subject: [PATCH 24/24] First version of client Only "Login page" implemented --- client/app.py | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 client/app.py diff --git a/client/app.py b/client/app.py new file mode 100644 index 0000000..22bca28 --- /dev/null +++ b/client/app.py @@ -0,0 +1,128 @@ +import tkinter as tk +import requests + +FONT= ("Verdana", 12) +FONT_LARGE= ("Verdana", 20) +URL = "http://localhost:8000/api/authenticate" +TOKEN = "" + +class SmartPicasso(tk.Tk): + + def __init__(self, *args, **kwargs): + + tk.Tk.__init__(self, *args, **kwargs) + container = tk.Frame(self) + self.title('SmartPicasso') + self.geometry('610x460') + + container.pack(side="top", fill="both", expand = True) + + container.grid_rowconfigure(0, weight=1) + container.grid_columnconfigure(0, weight=1) + + self.frames = {} + + for F in (LoginPage, MainView, RegisterView): + + frame = F(container, self) + + self.frames[F] = frame + + frame.grid(row=0, column=0, sticky="nsew") + + self.show_frame(LoginPage) + + def show_frame(self, cont): + + frame = self.frames[cont] + frame.tkraise() + + +class LoginPage(tk.Frame): + + def __init__(self, parent, controller): + tk.Frame.__init__(self,parent) + label = tk.Label(self, text="SmartPicasso", font=FONT_LARGE) + label.pack(pady=10,padx=10) + + label1 = tk.Label(self, text='Login:', font=FONT) + label1.pack() + + input1 = tk.Entry(self) + input1.pack() + + label2 = tk.Label(self, text='Password:', font=FONT) + label2.pack() + + input2 = tk.Entry(self) + input2.pack() + + button = tk.Button(self, text="Login", font=FONT, command=lambda: self.login(controller, input1.get(), input2.get())) + button.pack() + + button2 = tk.Button(self, text="Register", font=FONT, command=lambda: controller.show_frame(RegisterView)) + button2.pack() + + def login(self, controller, login, passw,): + print(login) + print(passw) + data = { + "email": str(login), + "password": str(passw) + } + resp = requests.post(URL, json=data) + print(resp) + if (resp.status_code==200): + response=resp.json() + TOKEN = response['token'] + controller.show_frame(MainView) + else: + print("bad pass") + badPassLabel = tk.Label(self, text='Wrong login/password!', font=FONT) + badPassLabel.pack() + return() + + +class MainView(tk.Frame): + + def __init__(self, parent, controller): + tk.Frame.__init__(self,parent) + label = tk.Label(self, text="SmartPicasso", font=FONT_LARGE) + label.pack(pady=10,padx=10) + label_u = tk.Label(self, text="Main menu", font=FONT) + label_u.pack(pady=10,padx=10) + + +class RegisterView(tk.Frame): + + def __init__(self, parent, controller): + tk.Frame.__init__(self,parent) + label = tk.Label(self, text="SmartPicasso", font=FONT_LARGE) + label.pack(pady=10,padx=10) + label_u = tk.Label(self, text="Register", font=FONT) + label_u.pack(pady=10,padx=10) + + label1 = tk.Label(self, text='Login:', font=FONT) + label1.pack() + + input1 = tk.Entry(self) + input1.pack() + + label2 = tk.Label(self, text='Password:', font=FONT) + label2.pack() + + input2 = tk.Entry(self) + input2.pack() + + label3 = tk.Label(self, text='Email:', font=FONT) + label3.pack() + + input3 = tk.Entry(self) + input3.pack() + + button = tk.Button(self, text="Register", font=FONT, command=lambda: controller.show_frame(RegisterView)) + button.pack() + + +app = SmartPicasso() +app.mainloop() \ No newline at end of file