From 679a831b7dd722b960e3d8a9a7bb638eeb4ef86a Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Sun, 11 Feb 2018 11:53:30 +0100 Subject: [PATCH 01/39] set fix versions for python libraries --- requirements.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index be753b0..ed57eeb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -Django<2.1 +Django==2.0.2 django-crispy-forms==1.7.0 django-extensions>=1.7.0 -djangorestframework>=3.6.0 -requests>=2.18.0 -django-debug-toolbar<2.0.0 +djangorestframework==3.7.7 +requests==2.18.0 +django-debug-toolbar==1.9.1 From d7181a77d42ac5ee24cbdaa2a15f754d25721d45 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Mon, 12 Feb 2018 19:27:16 +0100 Subject: [PATCH 02/39] Update Requirements --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ed57eeb..5c2b709 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,5 @@ Django==2.0.2 django-crispy-forms==1.7.0 django-extensions>=1.7.0 djangorestframework==3.7.7 -requests==2.18.0 +requests==2.18.4 django-debug-toolbar==1.9.1 From f9522046068cef562643ca8dfd7d46e1afadc276 Mon Sep 17 00:00:00 2001 From: Robert Einsle Date: Tue, 13 Feb 2018 08:38:17 +0100 Subject: [PATCH 03/39] Add myAccount view --- billard/forms.py | 10 ++++++++++ billard/urls.py | 2 ++ billard/views.py | 14 ++++++++++++++ templates/_base.html | 2 +- templates/registration/my_account.html | 21 +++++++++++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 billard/forms.py create mode 100644 templates/registration/my_account.html diff --git a/billard/forms.py b/billard/forms.py new file mode 100644 index 0000000..dd82d79 --- /dev/null +++ b/billard/forms.py @@ -0,0 +1,10 @@ +from django import forms +from django.contrib.auth.models import User + + +class UserInformationUpdateForm(forms.ModelForm): + email = forms.EmailField() + + class Meta: + model = User + fields = ('first_name', 'last_name', 'email',) diff --git a/billard/urls.py b/billard/urls.py index a28b8b8..2bbb65b 100644 --- a/billard/urls.py +++ b/billard/urls.py @@ -27,4 +27,6 @@ urlpatterns = [ path('api/v1/', include(router.urls)), # ex. /billard/process_location_data/ path('process_location_data/', views.process_location_data, name='process_location_data'), + # ex. /billard/myaccount/ + path('my_account', views.UserUpdateView.as_view(), name='my_account'), ] diff --git a/billard/views.py b/billard/views.py index 2b737d9..37fc297 100644 --- a/billard/views.py +++ b/billard/views.py @@ -8,11 +8,15 @@ from django.shortcuts import render, redirect from django.utils import timezone from django.utils.decorators import method_decorator from django.views import generic +from django.views.generic import UpdateView +from django.urls import reverse_lazy + from rest_framework import viewsets from billard.models import LocationData, Location, Client, Accounting from billard.serializers import LocationDataSerializer, ClientUpdateLastSeenSerializer from billard.tasks import process_location_data +from .forms import UserInformationUpdateForm log = logging.getLogger(__name__) @@ -113,6 +117,16 @@ class ClientUpdateLastSeenViewSet(viewsets.ModelViewSet): serializer_class = ClientUpdateLastSeenSerializer +@method_decorator(login_required, name='dispatch') +class UserUpdateView(UpdateView): + form_class = UserInformationUpdateForm + template_name = 'registration/my_account.html' + success_url = reverse_lazy('billard:my_account') + + def get_object(self): + return self.request.user + + def process_location_data(request): process_location_data() return HttpResponse('DONE') diff --git a/templates/_base.html b/templates/_base.html index 77da87d..064f9bd 100644 --- a/templates/_base.html +++ b/templates/_base.html @@ -50,7 +50,7 @@ {{ user.username }}