diff --git a/static/style.css b/static/style.css
index 04edfc7..3d0d34b 100644
--- a/static/style.css
+++ b/static/style.css
@@ -216,4 +216,49 @@ background-color:#FF0B7E
}
.resultText {
+}
+
+.accountInfoContainer{
+ border-radius: 25px;
+ padding: 20px;
+ width: 800px;
+ height: 1000px;
+ padding-bottom: 15px;
+}
+
+.accountInfoName {
+ font-weight: bold;
+ font-size: 20px;
+}
+
+.accountInfoText {
+}
+
+.accountInfoContainer button{
+ background-color: #00916E;
+ border: 1px solid green; /* Green border */
+ color: white; /* White text */
+ padding: 10px 24px; /* Some padding */
+ cursor: pointer; /* Pointer/hand icon */
+ width: 250px; /* Set a width if needed */
+ display: block; /* Make the buttons appear below each other */
+ border-radius: 25px;
+}
+
+.accountInfoContainer button:not(:last-child) {
+ border-bottom: none; /* Prevent double borders */
+}
+
+/* Add a background color on hover */
+.accountInfoContainer button:hover {
+ background-color: #3e8e41;
+}
+
+.accountInfoContainer a{
+ color: inherit;
+ text-decoration: inherit;
+}
+
+.returnLink{
+ color: #00916E;
}
\ No newline at end of file
diff --git a/templates/account.html b/templates/account.html
new file mode 100644
index 0000000..49233dd
--- /dev/null
+++ b/templates/account.html
@@ -0,0 +1,16 @@
+{% extends "base.html" %}
+
+{% block title %}Account{% endblock %}
+
+{% block content %}
+
-
Home
+
Home
Create test
Your tests
Categories
diff --git a/templates/changeEmail.html b/templates/changeEmail.html
new file mode 100644
index 0000000..8bb160e
--- /dev/null
+++ b/templates/changeEmail.html
@@ -0,0 +1,13 @@
+{% extends "base.html" %}
+
+{% block title %}Update email{% endblock %}
+
+{% block content %}
+
+{% endblock %}
diff --git a/templates/changeName.html b/templates/changeName.html
new file mode 100644
index 0000000..72d4a45
--- /dev/null
+++ b/templates/changeName.html
@@ -0,0 +1,14 @@
+{% extends "base.html" %}
+
+{% block title %}Update name{% endblock %}
+
+{% block content %}
+
+{% endblock %}
diff --git a/trials/views.py b/trials/views.py
index 66a9420..57f9acb 100644
--- a/trials/views.py
+++ b/trials/views.py
@@ -12,7 +12,6 @@ class TestModelViewSet(viewsets.ModelViewSet):
queryset = Test.objects.all()
serializer_class = TestSerializer
-
class TestTemplateView(TemplateView):
permission_classes = []
diff --git a/users/urls.py b/users/urls.py
index 42c9169..40f2b6d 100644
--- a/users/urls.py
+++ b/users/urls.py
@@ -4,7 +4,7 @@ from django.urls import path
from users.views import UserModelViewSet
from rest_framework_simplejwt.views import TokenObtainPairView
from rest_framework_simplejwt.views import TokenRefreshView
-from .views import PasswordReset, UserPasswordResetConfirmView, RegisterViewSet, login, logout, register, register_success
+from .views import PasswordReset, UserPasswordResetConfirmView, RegisterViewSet, login, logout, register, register_success, account, changeEmail, changeName
router = DefaultRouter(trailing_slash=False)
@@ -21,7 +21,10 @@ urlpatterns = [
path('register', register, name='register'),
path('api/token', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('api/token/refresh', TokenRefreshView.as_view(), name='token_refresh'),
- path("password/reset", PasswordReset.as_view()),
- path("password/reset/confirm", UserPasswordResetConfirmView.as_view()),
+ path("password/reset", PasswordReset.as_view(), name="resetPassword"),
+ path("password/reset/confirm", UserPasswordResetConfirmView.as_view(), name="resetPasswordConfirm"),
+ path("email/change", changeEmail, name='changeEmail'),
+ path("name/change", changeName, name='changeName'),
+ path("account", account, name='account')
]
diff --git a/users/views.py b/users/views.py
index 29cc290..e40141d 100644
--- a/users/views.py
+++ b/users/views.py
@@ -15,6 +15,7 @@ from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth import login as auth_login
from config.authh import SettingsBackend
from django.contrib.auth.decorators import login_required
+from django.contrib.auth import logout as django_logout
class UserModelViewSet(viewsets.ModelViewSet):
@@ -71,9 +72,7 @@ class UserPasswordResetConfirmView(PasswordResetConfirmShortcut, generics.Generi
def logout(request):
- # context = {
- # 'latest_question_list': latest_question_list,
- # }
+ django_logout(request)
return render(request, 'logout.html')
def register_success(request):
@@ -99,6 +98,7 @@ def register(request):
return render(request, 'register.html', context)
+@login_required
def login_success(request):
return render(request, 'great.html')
@@ -119,3 +119,36 @@ def login(request):
form = AuthenticationForm()
context['login_form'] = form
return render(request, 'login.html', context)
+
+
+@login_required
+def account(request):
+ context = {}
+ context['user'] = request.user
+ return render(request, 'account.html', context)
+
+
+@login_required
+def changeEmail(request):
+ if request.POST:
+ email = request.POST.get("email")
+
+ u = request.user
+ u.email = email
+ u.save()
+ return redirect('account')
+ return render(request, 'changeEmail.html')
+
+
+@login_required
+def changeName(request):
+ if request.POST:
+ firstName = request.POST.get("firstName")
+ lastName = request.POST.get("lastName")
+
+ u = request.user
+ u.first_name = firstName
+ u.last_name = lastName
+ u.save()
+ return redirect('account')
+ return render(request, 'changeName.html')