User settings page
This commit is contained in:
parent
1655ffa088
commit
3135f3e3ec
@ -217,3 +217,48 @@ 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;
|
||||
}
|
16
templates/account.html
Normal file
16
templates/account.html
Normal file
@ -0,0 +1,16 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Account{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="accountInfoContainer ">
|
||||
<!-- TODO Change-->
|
||||
<img class="resultImage" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAY1BMVEXp6ekyicju7Orv7eosh8cjhMcbgsbz7+vm6OnS3eVqo9FZm86FsdWlwNrd4+c6jcm3zd/D1OGtx93K2OOPttdhn89Hk8u0y96ZvNna4eaCr9XO2uTG1eJ7q9NHkstyqNKWudgoHijKAA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uz1kYxPIs7sHYRXxr7xhtpmH23AfNRQFAxFWvoy7pW3yTR8bYx5VGOw759GMB9cE4S8usdAhj9us34evTN0PjX0xsAAeBoUt4GD3Wv9M8M6mNC9RR8P4oD7BIa68iPAIZMNQ03yEfQv2E7S2VAjAw4ZrqwUd/oWlnDNhAOM6JoJ+xrRPRP2NSKQ1wzUQB8jwsI9E/Yr08PRn0MD3RuXwcpFE/YpPCgYmshooXOvncylHekzXXMYaEvN6QTzbgqFi0vFlW4LBlHxJyN0a2NC3ZxSK0Gnucad4MX/dImduhJCfE2Xot8cFfM10qE0feS0wA5LottO2sVNnd2x3fnspi7cNrXxaTaFwnGB6pTY7qb9UixtBP32OwxHz77PfKjcUw2vh2AL7Y0g3bqseE178zJ3rgzf054n9QeG4YeStZnrq2FDWwNvOP4Bga3HYI4uTvrB03sbiv2fsKH/fmsqiCqQG6al3qLF2cB9aNl8O5HG9pmWVpAc3UUN8Gsy/QenVo3mEmahmQAAAABJRU5ErkJggg==" alt="Card image cap">
|
||||
<h5 class="accountInfoName">{{user.first_name}} {{user.last_name}}</h5>
|
||||
<p class="accountInfoText"><b>Email:</b> {{user.email}}</p>
|
||||
<button><a href="{% url 'changeEmail' %}">Change email</a></button><br>
|
||||
<button><a href="{% url 'resetPassword' %}">Change password</a></button><br>
|
||||
<button><a href="{% url 'changeName' %}">Change name</a></button><br>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -4,38 +4,6 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}">
|
||||
<!-- <style type="text/css">-->
|
||||
<!-- .sidenav {-->
|
||||
<!-- height: 100%;-->
|
||||
<!-- width: 160px;-->
|
||||
<!-- position: fixed;-->
|
||||
<!-- z-index: 1;-->
|
||||
<!-- top: 0;-->
|
||||
<!-- left: 0;-->
|
||||
<!-- background-color: #111;-->
|
||||
<!-- overflow-x: :hidden;-->
|
||||
<!-- padding-top: 20px;-->
|
||||
<!-- }-->
|
||||
|
||||
<!-- .sidenav a {-->
|
||||
<!-- padding: 6px 8px 6px 16px;-->
|
||||
<!-- text-decoration: none;-->
|
||||
<!-- font-size: 20px;-->
|
||||
<!-- color: #818181;-->
|
||||
<!-- display: block;-->
|
||||
<!-- line-height: 1.6;-->
|
||||
<!-- }-->
|
||||
|
||||
<!-- .sidenav a:hover {-->
|
||||
<!-- color: #f1f1f1;-->
|
||||
<!-- }-->
|
||||
|
||||
<!-- .main {-->
|
||||
<!-- margin-left: 160px;-->
|
||||
<!-- padding: 0px 10px;-->
|
||||
<!-- }-->
|
||||
|
||||
<!-- </style>-->
|
||||
<title>SOITA | {% block title %}{% endblock %}</title>
|
||||
<meta name="description" content="{% block description %}{% endblock %}">
|
||||
{% block additional_head %}
|
||||
@ -44,7 +12,7 @@
|
||||
|
||||
<body>
|
||||
<div class="sidenav">
|
||||
<a href="/">Home</a>
|
||||
<a href="/home">Home</a>
|
||||
<a href="/test/create">Create test</a>
|
||||
<a href="/users/tests">Your tests</a>
|
||||
<p>Categories</p>
|
||||
|
13
templates/changeEmail.html
Normal file
13
templates/changeEmail.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Update email{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="accountInfoContainer ">
|
||||
<form method="post">
|
||||
<input type="email" id="email" name="email" class="form-control" placeholder="Email" required><br><br>
|
||||
<input type="submit" value="Change name"><br><br>
|
||||
</form>
|
||||
<a class="returnLink" href="{% url 'account' %}">Back to dashboard</a>
|
||||
</div>
|
||||
{% endblock %}
|
14
templates/changeName.html
Normal file
14
templates/changeName.html
Normal file
@ -0,0 +1,14 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Update name{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="accountInfoContainer ">
|
||||
<form method="post">
|
||||
<input type="text" id="firstName" name="firstName" class="form-control" placeholder="First Name" required><br><br>
|
||||
<input type="text" id="lastName" name="lastName" class="form-control" placeholder="First Name" required><br><br>
|
||||
<input type="submit" value="Change name"><br><br>
|
||||
</form>
|
||||
<a class="returnLink" href="{% url 'account' %}">Back to dashboard</a>
|
||||
</div>
|
||||
{% endblock %}
|
@ -12,7 +12,6 @@ class TestModelViewSet(viewsets.ModelViewSet):
|
||||
queryset = Test.objects.all()
|
||||
serializer_class = TestSerializer
|
||||
|
||||
|
||||
class TestTemplateView(TemplateView):
|
||||
|
||||
permission_classes = []
|
||||
|
@ -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')
|
||||
]
|
||||
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user