-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from Signbank/develop
Develop
- Loading branch information
Showing
178 changed files
with
2,986 additions
and
1,342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class DictionaryConfig(AppConfig): | ||
class AccountsConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'dictionary' | ||
name = 'accounts' |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from rest_framework import serializers | ||
from django.contrib.auth.models import User | ||
|
||
|
||
# User Serializer | ||
class UserSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = User | ||
fields = ('id', 'username', 'email') | ||
|
||
|
||
# Register Serializer | ||
class RegisterSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = User | ||
fields = ('id', 'username', 'email', 'password') | ||
extra_kwargs = {'password': {'write_only': True}} | ||
|
||
def create(self, validated_data): | ||
user = User.objects.create_user(validated_data['username'], validated_data['email'], validated_data['password']) | ||
|
||
return user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from .views import RegisterAPI | ||
from django.urls import path | ||
from knox import views as knox_views | ||
from .views import LoginAPI | ||
|
||
urlpatterns = [ | ||
path('register/', RegisterAPI.as_view(), name='register'), | ||
path('login/', LoginAPI.as_view(), name='login'), | ||
path('logout/', knox_views.LogoutView.as_view(), name='logout'), | ||
path('logoutall/', knox_views.LogoutAllView.as_view(), name='logoutall'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from django.contrib.auth import login | ||
from rest_framework import generics, permissions | ||
from rest_framework.response import Response | ||
from knox.models import AuthToken | ||
from .serializers import UserSerializer, RegisterSerializer | ||
from rest_framework.authtoken.serializers import AuthTokenSerializer | ||
from knox.views import LoginView as KnoxLoginView | ||
|
||
|
||
# Register API | ||
class RegisterAPI(generics.GenericAPIView): | ||
serializer_class = RegisterSerializer | ||
|
||
def post(self, request, *args, **kwargs): | ||
serializer = self.get_serializer(data=request.data) | ||
serializer.is_valid(raise_exception=True) | ||
user = serializer.save() | ||
return Response({ | ||
"user": UserSerializer(user, context=self.get_serializer_context()).data, | ||
"token": AuthToken.objects.create(user)[1] | ||
}) | ||
|
||
|
||
class LoginAPI(KnoxLoginView): | ||
permission_classes = (permissions.AllowAny,) | ||
|
||
def post(self, request, format=None): | ||
serializer = AuthTokenSerializer(data=request.data) | ||
serializer.is_valid(raise_exception=True) | ||
user = serializer.validated_data['user'] | ||
login(request, user) | ||
return super(LoginAPI, self).post(request, format=None) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.