QRTR-3 reworked initial setup
This commit is contained in:
parent
d0dc71ad19
commit
a8acfd05ba
Binary file not shown.
BIN
api/__pycache__/admin.cpython-37.pyc
Normal file
BIN
api/__pycache__/admin.cpython-37.pyc
Normal file
Binary file not shown.
BIN
api/__pycache__/models.cpython-37.pyc
Normal file
BIN
api/__pycache__/models.cpython-37.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
||||||
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = get_user_model()
|
||||||
fields = ['url', 'username', 'email', 'groups']
|
fields = ['url', 'username', 'email', 'groups']
|
||||||
|
|
||||||
|
|
||||||
class GroupSerializer(serializers.HyperlinkedModelSerializer):
|
class GroupSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Group
|
model = Group
|
||||||
fields = ['url', 'name']
|
fields = ['url', 'name']
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -38,8 +38,21 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'rest_framework',
|
'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 = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
@ -81,6 +94,7 @@ DATABASES = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AUTH_USER_MODEL = 'user.User'
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
||||||
|
|||||||
15
core/urls.py
15
core/urls.py
@ -16,17 +16,22 @@ Including another URLconf
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
from rest_framework import routers
|
from rest_framework import routers
|
||||||
from api import views
|
from user.views import UserViewSet, GroupViewSet
|
||||||
|
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
router.register(r'users', views.UserViewSet)
|
router.register(r'users', UserViewSet)
|
||||||
router.register(r'groups', views.GroupViewSet)
|
router.register(r'groups', GroupViewSet)
|
||||||
|
|
||||||
# Wire up our API using automatic URL routing.
|
# Wire up our API using automatic URL routing.
|
||||||
# Additionally, we include login URLs for the browsable API.
|
# 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 = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('', include(router.urls)),
|
path('api/v1/', include(apipatterns), name='api'),
|
||||||
path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
|
||||||
]
|
]
|
||||||
|
|||||||
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
3
qrtr_account/admin.py
Normal file
3
qrtr_account/admin.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
5
qrtr_account/apps.py
Normal file
5
qrtr_account/apps.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class QrtrAccountConfig(AppConfig):
|
||||||
|
name = 'qrtr_account'
|
||||||
21
qrtr_account/models.py
Normal file
21
qrtr_account/models.py
Normal file
@ -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
|
||||||
3
qrtr_account/tests.py
Normal file
3
qrtr_account/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
3
qrtr_account/views.py
Normal file
3
qrtr_account/views.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
0
user/__init__.py
Normal file
0
user/__init__.py
Normal file
BIN
user/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
user/__pycache__/__init__.cpython-37.pyc
Normal file
Binary file not shown.
BIN
user/__pycache__/admin.cpython-37.pyc
Normal file
BIN
user/__pycache__/admin.cpython-37.pyc
Normal file
Binary file not shown.
BIN
user/__pycache__/models.cpython-37.pyc
Normal file
BIN
user/__pycache__/models.cpython-37.pyc
Normal file
Binary file not shown.
BIN
user/__pycache__/views.cpython-37.pyc
Normal file
BIN
user/__pycache__/views.cpython-37.pyc
Normal file
Binary file not shown.
3
user/admin.py
Normal file
3
user/admin.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
5
user/apps.py
Normal file
5
user/apps.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class UserConfig(AppConfig):
|
||||||
|
name = 'user'
|
||||||
45
user/migrations/0001_initial.py
Normal file
45
user/migrations/0001_initial.py
Normal file
@ -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()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
0
user/migrations/__init__.py
Normal file
0
user/migrations/__init__.py
Normal file
BIN
user/migrations/__pycache__/0001_initial.cpython-37.pyc
Normal file
BIN
user/migrations/__pycache__/0001_initial.cpython-37.pyc
Normal file
Binary file not shown.
BIN
user/migrations/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
user/migrations/__pycache__/__init__.cpython-37.pyc
Normal file
Binary file not shown.
8
user/models.py
Normal file
8
user/models.py
Normal file
@ -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
|
||||||
3
user/tests.py
Normal file
3
user/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
@ -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 rest_framework import viewsets
|
||||||
from api.serializers import UserSerializer, GroupSerializer
|
from api.serializers import UserSerializer, GroupSerializer
|
||||||
|
|
||||||
@ -7,7 +8,7 @@ class UserViewSet(viewsets.ModelViewSet):
|
|||||||
"""
|
"""
|
||||||
API endpoint that allows users to be viewed or edited.
|
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
|
serializer_class = UserSerializer
|
||||||
|
|
||||||
|
|
||||||
@ -16,4 +17,4 @@ class GroupViewSet(viewsets.ModelViewSet):
|
|||||||
API endpoint that allows groups to be viewed or edited.
|
API endpoint that allows groups to be viewed or edited.
|
||||||
"""
|
"""
|
||||||
queryset = Group.objects.all()
|
queryset = Group.objects.all()
|
||||||
serializer_class = GroupSerializer
|
serializer_class = GroupSerializer
|
||||||
Loading…
Reference in New Issue
Block a user