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