chore: minor optimizations and code cleanup
This commit is contained in:
parent
0ac3a5049c
commit
fcc2467bcb
3 changed files with 25 additions and 35 deletions
|
|
@ -29,7 +29,7 @@ class LoginView(APIView):
|
|||
|
||||
def _create_token_response(self, user):
|
||||
token, created = Token.objects.get_or_create(user=user)
|
||||
return Response({'token': token.key}, status=status.HTTP_200_OK)
|
||||
return Response({'token': token.key, 'user_id' : user.id}, status=status.HTTP_200_OK)
|
||||
|
||||
class LogoutView(APIView):
|
||||
authentication_classes = [authentication.TokenAuthentication]
|
||||
|
|
|
|||
|
|
@ -30,21 +30,13 @@ ALLOWED_HOSTS = [
|
|||
'127.0.0.1',
|
||||
]
|
||||
|
||||
CORS_ALLOWED_ORIGINS = [
|
||||
'http://localhost:4200',
|
||||
]
|
||||
|
||||
# CORS settings
|
||||
CORS_ALLOWED_ORIGINS = ['http://localhost:4200']
|
||||
CORS_ALLOW_HEADERS = [
|
||||
'content-type',
|
||||
'accept',
|
||||
'authorization',
|
||||
'x-csrftoken',
|
||||
'sentry-trace',
|
||||
'baggage',
|
||||
'content-type', 'accept', 'authorization', 'x-csrftoken', 'sentry-trace', 'baggage',
|
||||
]
|
||||
|
||||
# Application definition
|
||||
|
||||
# Application config
|
||||
AUTH_USER_MODEL = 'user_app.User'
|
||||
|
||||
INSTALLED_APPS = [
|
||||
|
|
@ -76,15 +68,6 @@ MIDDLEWARE = [
|
|||
|
||||
ROOT_URLCONF = 'join.urls'
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_RENDERER_CLASSES': (
|
||||
'djangorestframework_camel_case.render.CamelCaseJSONRenderer',
|
||||
),
|
||||
'DEFAULT_PARSER_CLASSES': (
|
||||
'djangorestframework_camel_case.parser.CamelCaseJSONParser',
|
||||
),
|
||||
}
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
|
|
@ -103,7 +86,8 @@ TEMPLATES = [
|
|||
|
||||
WSGI_APPLICATION = 'join.wsgi.application'
|
||||
|
||||
# Redis
|
||||
# Caching (Redis)
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django_redis.cache.RedisCache',
|
||||
|
|
@ -167,19 +151,25 @@ STATIC_URL = 'static/'
|
|||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
|
||||
# Auth
|
||||
# Authentication
|
||||
|
||||
AUTH_USER_MODEL = 'user_app.User'
|
||||
AUTH_EMAIL_VERIFICATION = True
|
||||
|
||||
# Rest Framework
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||||
'rest_framework.authentication.TokenAuthentication',
|
||||
],
|
||||
}
|
||||
|
||||
AUTHENTICATION_BACKENDS = (
|
||||
'auth_app.custom_backend.EmailBackend',
|
||||
'django.contrib.auth.backends.ModelBackend',
|
||||
)
|
||||
|
||||
# REST Framework config
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||||
'rest_framework.authentication.TokenAuthentication',
|
||||
],
|
||||
'DEFAULT_RENDERER_CLASSES': (
|
||||
'djangorestframework_camel_case.render.CamelCaseJSONRenderer',
|
||||
),
|
||||
'DEFAULT_PARSER_CLASSES': (
|
||||
'djangorestframework_camel_case.parser.CamelCaseJSONParser',
|
||||
),
|
||||
}
|
||||
|
|
@ -11,14 +11,14 @@ class SubTaskSerializer(serializers.ModelSerializer):
|
|||
class AssignedTaskSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = AssignedTask
|
||||
fields = ['id', 'user_id']
|
||||
fields = ['user_id']
|
||||
|
||||
class TaskSerializer(serializers.ModelSerializer):
|
||||
assignees = serializers.SerializerMethodField()
|
||||
subtasks = SubTaskSerializer(many=True, read_only=True)
|
||||
|
||||
def get_assignees(self, obj):
|
||||
return obj.assigned_tasks.all().values('id', 'user_id')
|
||||
return obj.assigned_tasks.all().values('user_id')
|
||||
|
||||
class Meta:
|
||||
model = Task
|
||||
|
|
|
|||
Loading…
Reference in a new issue