Compare commits

..

No commits in common. "a103ac22f5999fab628efad891d08559450b5d30" and "864a7741e6b7d409c1be4339277a29d5edb82ca3" have entirely different histories.

8 changed files with 10 additions and 41 deletions

View file

@ -1,5 +1,5 @@
from django.contrib import admin
from .user.models.user_information import UserInformation
from .user.models import *
# Register your models here.
admin.site.register(UserInformation)

View file

@ -1,25 +0,0 @@
from django.views import View
from django.contrib.auth.models import User
from django.http import HttpResponse
from api_v1.user.user_services import acreate_user_information
class RegistrationView(View):
async def post(self, request):
# Read parameters from body
username = request.POST.get('username')
password = request.POST.get('password')
email = request.POST.get('email')
display_name = request.POST.get('display_name')
# Check if user already exists
if User.objects.filter(username=username).exists():
return HttpResponse(status=400, content="User already exists")
# Create user
user = await User.objects.acreate_user(username, email, password)
# Create UserInformation
await acreate_user_information(user, display_name=display_name)
return HttpResponse(status=201, content="User created")

View file

@ -1 +1 @@
from .user.models.user_information import UserInformation
from .user.models import *

View file

@ -1,8 +0,0 @@
from django.urls import path, include
from .auth.registration_view import RegistrationView
# Assign register url
urlpatterns = [
path("auth/", include("django.contrib.auth.urls")),
path('auth/register/', RegistrationView.as_view(), name='register'),
]

View file

@ -0,0 +1,2 @@
from .models import *
from .user_services import *

View file

@ -0,0 +1 @@
from .user_information import UserInformation

View file

@ -1,9 +1,9 @@
from .models.user_information import UserInformation
from .models import UserInformation
from django.contrib.auth.models import User
from typing import Optional
async def acreate_user_information(user: User, *, display_name: Optional[str] = None) -> UserInformation:
async def create_user_information(user: User, *, display_name: Optional[str] = None) -> UserInformation:
"""Async. Create a UserInformation object for the given user.
@param user: The user to create the UserInformation object for.
@ -20,7 +20,7 @@ async def acreate_user_information(user: User, *, display_name: Optional[str] =
return user_information
async def aget_user_information(user: User) -> UserInformation:
async def get_user_information(user: User) -> UserInformation:
"""Async. Get the UserInformation object for the given user.
@param user: The user to get the UserInformation object for.
@ -29,7 +29,7 @@ async def aget_user_information(user: User) -> UserInformation:
return await UserInformation.objects.aget(user)
async def aset_user_display_name(user: User, display_name: Optional[str] = None) -> UserInformation:
async def set_user_display_name(user: User, display_name: Optional[str] = None) -> UserInformation:
"""Async. Set the display name for the given user.
@param user: The user to set the display name for.

View file

@ -15,9 +15,8 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
path("v1/", include("api_v1.urls")),
]