From 916de9fd6bbcb6e74fa7654287327c95472c4ae9 Mon Sep 17 00:00:00 2001 From: jedi Date: Sat, 9 Dec 2023 00:57:09 +0100 Subject: [PATCH] stash --- TODO.md | 78 +++++++++++++++++ core/authentication/api_v2.py | 34 +++++++- web/src/App.vue | 18 ++-- web/src/router.js | 59 +++++++++---- web/src/store/index.js | 69 ++++++++++++--- web/src/views/Login.vue | 120 ++++++++++++++++++++++++++ web/src/views/Register.vue | 154 ++++++++++++++++++++++++++++++++++ 7 files changed, 498 insertions(+), 34 deletions(-) create mode 100644 TODO.md create mode 100644 web/src/views/Login.vue create mode 100644 web/src/views/Register.vue diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..a0eb090 --- /dev/null +++ b/TODO.md @@ -0,0 +1,78 @@ +# Issues + +* [ ] Frontend to add, edit and delete events +* [ ] Backend to add, edit and delete events +* [ ] api testcases for events +* [ ] Frontend to add, edit and delete users +* [ ] Backend to add, edit and delete users +* [ ] api testcases for users +* [ ] check permissions in all api endpoints +* [ ] tickets + * [ ] Frontend to add, edit and delete tickets + * [ ] Backend to add, edit and delete tickets + * [ ] api testcases for tickets + * [ ] Frontend: change ticket status + * [ ] Backend: change ticket status + * [ ] api testcases for ticket status + * [ ] Frontend: assign tickets to users + * [ ] Backend: assign tickets to users + * [ ] api testcases for ticket assignment + * [ ] Frontend: ticket search + * [ ] Backend: ticket search + * [ ] api testcases for ticket search + * [ ] Frontend: ticket comments + * [ ] Backend: ticket comments + * [ ] api testcases for ticket comments + * [ ] Frontend: send replay mails + * [ ] Backend: send replay mails + * [ ] api testcases for replay mails + * [ ] Frontend: manage auto mail triggers + * [ ] Backend: manage auto mail triggers + * [ ] api testcases for auto mail triggers + * [ ] Frontend: manage mail templates + * [ ] Backend: manage mail templates + * [ ] api testcases for mail templates + * [ ] Backend: send notification mails to users + * [ ] testcases for notification mails + * [ ] Frontend: notification settings + * [ ] Backend: notification settings + * [ ] api testcases for notification settings + * [ ] Backend: Telegram bot + * [ ] Backend: route mail to tickets bases on +tag + * [ ] testcases for mail to tickets +* [ ] Frontend: login, logout, register +* [ ] Backend: login, logout, register +* [ ] api testcases for login, logout, register +* [ ] Frontend: item search +* [ ] Backend: item search +* [ ] api testcases for item search +* [ ] Frontend: to math items to tickets +* [ ] Backend: to math items to tickets +* [ ] api testcases for item to tickets +* [ ] Frontend: to show item history +* [ ] Backend: to show item history +* [ ] api testcases for item history +* [ ] Frontend: to delegate permissions via qr code +* [ ] testcases for qr code +* [ ] Frontend to add, edit and delete boxes +* [ ] Backend to add, edit and delete boxes +* [ ] api testcases for boxes +* [ ] Frontend: to show box history +* [ ] Backend: to show box history +* [ ] api testcases for box history +* [ ] Frontend: clear, disband and move boxes +* [ ] Backend: clear, disband and move boxes +* [ ] api testcases for clear, disband and move boxes +* [ ] testcases for receiving mails and auto reply +* [ ] Frontend: merging tickets +* [ ] Backend: merging tickets +* [ ] api testcases for merging tickets +* [ ] concept: create items from "found something" tickets +* [ ] concept: purge old tickets +* [ ] concept: purge old items +* [ ] concept: auto email stale after x days + +## Priority: TODO + +* send mails from web frontend +* login / user management diff --git a/core/authentication/api_v2.py b/core/authentication/api_v2.py index 5dac2a8..70e4bc1 100644 --- a/core/authentication/api_v2.py +++ b/core/authentication/api_v2.py @@ -1,4 +1,7 @@ from rest_framework import routers, viewsets, serializers +from rest_framework.decorators import api_view, permission_classes, authentication_classes +from rest_framework.response import Response +from rest_framework.authentication import BasicAuthentication from django.contrib.auth.models import User @@ -8,13 +11,42 @@ class UserSerializer(serializers.ModelSerializer): fields = ('id', 'username', 'email', 'first_name', 'last_name') +class RegisterUserSerializer(serializers.ModelSerializer): + class Meta: + model = User + fields = ('username', 'password', 'email') + extra_kwargs = { + 'password': {'write_only': True}, + } + + class UserViewSet(viewsets.ModelViewSet): queryset = User.objects.all() serializer_class = UserSerializer - authentication_classes = [] + authentication_classes = [BasicAuthentication] permission_classes = [] +@api_view(['GET']) +@permission_classes([]) +@authentication_classes([BasicAuthentication]) +def token(request): + return Response({ + 'token': request.user.auth_token.key + }) + + +@api_view(['POST']) +@permission_classes([]) +@authentication_classes([]) +def registerUser(request): + serializer = RegisterUserSerializer(data=request.data) + if serializer.is_valid(): + user = serializer.save() + return Response({'username': user.username, 'email': user.email}, status=201) + return Response(serializer.errors, status=400) + + router = routers.SimpleRouter() router.register(r'users', UserViewSet, basename='users') diff --git a/web/src/App.vue b/web/src/App.vue index bedb68c..070c9c8 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -1,9 +1,9 @@