diff --git a/api/__pycache__/__init__.cpython-37.pyc b/api/__pycache__/__init__.cpython-37.pyc index 3442565..97d094b 100644 Binary files a/api/__pycache__/__init__.cpython-37.pyc and b/api/__pycache__/__init__.cpython-37.pyc differ diff --git a/api/__pycache__/admin.cpython-37.pyc b/api/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000..0fa1683 Binary files /dev/null and b/api/__pycache__/admin.cpython-37.pyc differ diff --git a/api/__pycache__/models.cpython-37.pyc b/api/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000..b999c7d Binary files /dev/null and b/api/__pycache__/models.cpython-37.pyc differ diff --git a/api/__pycache__/serializers.cpython-37.pyc b/api/__pycache__/serializers.cpython-37.pyc index 3e47fd1..1f7c7ac 100644 Binary files a/api/__pycache__/serializers.cpython-37.pyc and b/api/__pycache__/serializers.cpython-37.pyc differ diff --git a/api/__pycache__/views.cpython-37.pyc b/api/__pycache__/views.cpython-37.pyc index 8fa5b40..f38e756 100644 Binary files a/api/__pycache__/views.cpython-37.pyc and b/api/__pycache__/views.cpython-37.pyc differ diff --git a/api/serializers.py b/api/serializers.py index 695f76b..427e4e5 100755 --- a/api/serializers.py +++ b/api/serializers.py @@ -1,14 +1,15 @@ -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import Group +from django.contrib.auth import get_user_model from rest_framework import serializers class UserSerializer(serializers.HyperlinkedModelSerializer): class Meta: - model = User + model = get_user_model() fields = ['url', 'username', 'email', 'groups'] class GroupSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Group - fields = ['url', 'name'] \ No newline at end of file + fields = ['url', 'name'] diff --git a/core/__pycache__/__init__.cpython-37.pyc b/core/__pycache__/__init__.cpython-37.pyc index 7ca124c..6bdba31 100644 Binary files a/core/__pycache__/__init__.cpython-37.pyc and b/core/__pycache__/__init__.cpython-37.pyc differ diff --git a/core/__pycache__/settings.cpython-37.pyc b/core/__pycache__/settings.cpython-37.pyc index 45cd443..c14f2ee 100644 Binary files a/core/__pycache__/settings.cpython-37.pyc and b/core/__pycache__/settings.cpython-37.pyc differ diff --git a/core/__pycache__/urls.cpython-37.pyc b/core/__pycache__/urls.cpython-37.pyc index 9db5f46..6530a7b 100644 Binary files a/core/__pycache__/urls.cpython-37.pyc and b/core/__pycache__/urls.cpython-37.pyc differ diff --git a/core/settings.py b/core/settings.py index a5f952e..2d40208 100644 --- a/core/settings.py +++ b/core/settings.py @@ -38,8 +38,21 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', + 'rest_framework.authtoken', + 'rest_auth', + 'django.contrib.sites', + 'allauth', + 'allauth.account', + 'rest_auth.registration', + 'api', + 'user', ] +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + +SITE_ID = 1 + + MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', @@ -81,6 +94,7 @@ DATABASES = { } } +AUTH_USER_MODEL = 'user.User' # Password validation # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators diff --git a/core/urls.py b/core/urls.py index 32aef8b..b5657fc 100644 --- a/core/urls.py +++ b/core/urls.py @@ -16,17 +16,22 @@ Including another URLconf from django.contrib import admin from django.urls import include, path from rest_framework import routers -from api import views +from user.views import UserViewSet, GroupViewSet router = routers.DefaultRouter() -router.register(r'users', views.UserViewSet) -router.register(r'groups', views.GroupViewSet) +router.register(r'users', UserViewSet) +router.register(r'groups', GroupViewSet) # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. +apipatterns = [ + path('', include(router.urls)), + path('auth/', include('rest_framework.urls', namespace='rest_framework'), name='auth'), + path('auth/registration/', include('rest_auth.registration.urls'), name='register'), +] + urlpatterns = [ path('admin/', admin.site.urls), - path('', include(router.urls)), - path('api-auth/', include('rest_framework.urls', namespace='rest_framework')) + path('api/v1/', include(apipatterns), name='api'), ] diff --git a/db.sqlite3 b/db.sqlite3 index e616618..f81006e 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/api/migrations/__init__.py b/qrtr_account/__init__.py similarity index 100% rename from api/migrations/__init__.py rename to qrtr_account/__init__.py diff --git a/qrtr_account/admin.py b/qrtr_account/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/qrtr_account/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/qrtr_account/apps.py b/qrtr_account/apps.py new file mode 100644 index 0000000..8888794 --- /dev/null +++ b/qrtr_account/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class QrtrAccountConfig(AppConfig): + name = 'qrtr_account' diff --git a/connection/migrations/__init__.py b/qrtr_account/migrations/__init__.py similarity index 100% rename from connection/migrations/__init__.py rename to qrtr_account/migrations/__init__.py diff --git a/qrtr_account/models.py b/qrtr_account/models.py new file mode 100644 index 0000000..8a27b8f --- /dev/null +++ b/qrtr_account/models.py @@ -0,0 +1,21 @@ +from django.db import models +from user.models import User + + +class Account(models.Model): + owner = models.ForeignKey(User, on_delete=models.CASCADE) + admin_users = models.ManyToManyField(User, related_name="admins") + view_users = models.ManyToManyField(User, related_name="viewer") + name = models.CharField(max_length=250) + + +class InstitutionAccount(models.Model): + qrtr_account = models.ForeignKey(Account, on_delete=models.CASCADE) + name = models.CharField(max_length=250) + id = models.CharField(max_length=150) + balance = models.DecimalField() + ac_type = models.CharField() + ac_subtype = models.CharField() + +class Transaction(models.Model): + pass diff --git a/qrtr_account/tests.py b/qrtr_account/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/qrtr_account/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/qrtr_account/views.py b/qrtr_account/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/qrtr_account/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/user/__init__.py b/user/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/user/__pycache__/__init__.cpython-37.pyc b/user/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..f1b9fdf Binary files /dev/null and b/user/__pycache__/__init__.cpython-37.pyc differ diff --git a/user/__pycache__/admin.cpython-37.pyc b/user/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000..249ee44 Binary files /dev/null and b/user/__pycache__/admin.cpython-37.pyc differ diff --git a/user/__pycache__/models.cpython-37.pyc b/user/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000..2d24f48 Binary files /dev/null and b/user/__pycache__/models.cpython-37.pyc differ diff --git a/user/__pycache__/views.cpython-37.pyc b/user/__pycache__/views.cpython-37.pyc new file mode 100644 index 0000000..452fec6 Binary files /dev/null and b/user/__pycache__/views.cpython-37.pyc differ diff --git a/user/admin.py b/user/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/user/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/user/apps.py b/user/apps.py new file mode 100644 index 0000000..35048d4 --- /dev/null +++ b/user/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class UserConfig(AppConfig): + name = 'user' diff --git a/user/migrations/0001_initial.py b/user/migrations/0001_initial.py new file mode 100644 index 0000000..a31fb3c --- /dev/null +++ b/user/migrations/0001_initial.py @@ -0,0 +1,45 @@ +# Generated by Django 2.2.6 on 2019-11-12 01:26 + +import django.contrib.auth.models +import django.contrib.auth.validators +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('auth', '0011_update_proxy_permissions'), + ] + + operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('password', models.CharField(max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), + ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), + ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), + ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), + ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), + ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), + ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), + ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), + ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), + ('name', models.CharField(blank=True, max_length=255)), + ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), + ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), + ], + options={ + 'verbose_name': 'user', + 'verbose_name_plural': 'users', + 'abstract': False, + }, + managers=[ + ('objects', django.contrib.auth.models.UserManager()), + ], + ), + ] diff --git a/user/migrations/__init__.py b/user/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/user/migrations/__pycache__/0001_initial.cpython-37.pyc b/user/migrations/__pycache__/0001_initial.cpython-37.pyc new file mode 100644 index 0000000..353592a Binary files /dev/null and b/user/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/user/migrations/__pycache__/__init__.cpython-37.pyc b/user/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..b30e783 Binary files /dev/null and b/user/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/user/models.py b/user/models.py new file mode 100644 index 0000000..4851f05 --- /dev/null +++ b/user/models.py @@ -0,0 +1,8 @@ +from django.contrib.auth.models import AbstractUser +from django.db import models + +class User(AbstractUser): + name = models.CharField(blank=True, max_length=255) + + def __str__(self): + return self.email diff --git a/user/tests.py b/user/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/user/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/api/views.py b/user/views.py similarity index 66% rename from api/views.py rename to user/views.py index 6e6422f..5bdb2dc 100644 --- a/api/views.py +++ b/user/views.py @@ -1,4 +1,5 @@ -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import Group +from django.contrib.auth import get_user_model from rest_framework import viewsets from api.serializers import UserSerializer, GroupSerializer @@ -7,7 +8,7 @@ class UserViewSet(viewsets.ModelViewSet): """ API endpoint that allows users to be viewed or edited. """ - queryset = User.objects.all().order_by('-date_joined') + queryset = get_user_model().objects.all().order_by('-date_joined') serializer_class = UserSerializer @@ -16,4 +17,4 @@ class GroupViewSet(viewsets.ModelViewSet): API endpoint that allows groups to be viewed or edited. """ queryset = Group.objects.all() - serializer_class = GroupSerializer \ No newline at end of file + serializer_class = GroupSerializer