Add profile drop down and clean up sidebar
This commit is contained in:
parent
525a2a9378
commit
7a153c46e6
6 changed files with 50 additions and 111 deletions
|
@ -64,21 +64,18 @@ layout-wide customizer-hide
|
|||
<span class="app-brand-text demo text-body fw-bold">سامانه شفافیت</span>
|
||||
</a>
|
||||
</div>
|
||||
<!-- /Logo -->
|
||||
<h4 class="mb-2">Welcome to Sneat! 👋</h4>
|
||||
<p class="mb-4">Please sign-in to your account and start the adventure</p>
|
||||
|
||||
<form id="formAuthentication" class="mb-3 fv-plugins-bootstrap5 fv-plugins-framework" method="post" novalidate="novalidate">
|
||||
{% csrf_token %}
|
||||
<div class="mb-3 fv-plugins-icon-container">
|
||||
<label for="email" class="form-label">Email or Username</label>
|
||||
<label for="email" class="form-label">نام کاربری</label>
|
||||
<input type="text" class="form-control" id="email" name="username" placeholder="Enter your email or username" autofocus="">
|
||||
<div class="fv-plugins-message-container fv-plugins-message-container--enabled invalid-feedback"></div></div>
|
||||
<div class="mb-3 form-password-toggle fv-plugins-icon-container">
|
||||
<div class="d-flex justify-content-between">
|
||||
<label class="form-label" for="password">Password</label>
|
||||
<label class="form-label" for="password">رمز عبور</label>
|
||||
<a href="auth-forgot-password-basic.html">
|
||||
<small>Forgot Password?</small>
|
||||
<small>رمز عبور را فراموش کرده اید؟</small>
|
||||
</a>
|
||||
</div>
|
||||
<div class="input-group input-group-merge has-validation">
|
||||
|
@ -86,43 +83,12 @@ layout-wide customizer-hide
|
|||
<span class="input-group-text cursor-pointer"><i class="bx bx-hide"></i></span>
|
||||
</div><div class="fv-plugins-message-container fv-plugins-message-container--enabled invalid-feedback"></div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="remember-me">
|
||||
<label class="form-check-label" for="remember-me">
|
||||
Remember Me
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<button class="btn btn-primary d-grid w-100" type="submit">Sign in</button>
|
||||
<button class="btn btn-primary d-grid w-100" type="submit">ورود</button>
|
||||
</div>
|
||||
<input type="hidden"></form>
|
||||
|
||||
<p class="text-center">
|
||||
<span>New on our platform?</span>
|
||||
<a href="auth-register-basic.html">
|
||||
<span>Create an account</span>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<div class="divider my-4">
|
||||
<div class="divider-text">or</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-center">
|
||||
<a href="javascript:;" class="btn btn-icon btn-label-facebook me-3">
|
||||
<i class="tf-icons bx bxl-facebook"></i>
|
||||
</a>
|
||||
|
||||
<a href="javascript:;" class="btn btn-icon btn-label-google-plus me-3">
|
||||
<i class="tf-icons bx bxl-google-plus"></i>
|
||||
</a>
|
||||
|
||||
<a href="javascript:;" class="btn btn-icon btn-label-twitter">
|
||||
<i class="tf-icons bx bxl-twitter"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Register -->
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
from django.urls import path
|
||||
|
||||
from accounts.views import login_view, dashboard, customer_list, add_customer_ajax, edit_customer_ajax, get_customer_data
|
||||
from accounts.views import login_view, dashboard, customer_list, add_customer_ajax, edit_customer_ajax, get_customer_data, logout_view
|
||||
|
||||
app_name = "accounts"
|
||||
urlpatterns = [
|
||||
path('login/', login_view, name='login'),
|
||||
path('logout/', logout_view, name='logout'),
|
||||
path('dashboard/', dashboard, name='dashboard'),
|
||||
path('customers/', customer_list, name='customer_list'),
|
||||
path('customers/add/', add_customer_ajax, name='add_customer_ajax'),
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from django.contrib import messages
|
||||
from django.contrib.auth import login, authenticate
|
||||
from django.contrib.auth import login, authenticate, logout
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.http import JsonResponse
|
||||
from django.views.decorators.http import require_POST, require_GET
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django import forms
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from accounts.models import Profile
|
||||
from accounts.forms import CustomerForm
|
||||
from common.consts import UserRoles
|
||||
|
@ -21,15 +21,12 @@ def login_view(request):
|
|||
username = request.POST.get("username")
|
||||
password = request.POST.get("password")
|
||||
user = authenticate(request, username=username, password=password)
|
||||
# if user is not None:
|
||||
# login(request, user)
|
||||
# if user.profile.has_none_of([UserRoles.MANAGER]):
|
||||
# return redirect("dashboard:dashboard")
|
||||
# else:
|
||||
# return redirect("dashboard:admin_dashboard")
|
||||
# else:
|
||||
# messages.error(request, "کاربری با این مشخصات یافت نشد!")
|
||||
# return redirect("accounts:login")
|
||||
if user is not None:
|
||||
login(request, user)
|
||||
return redirect("processes:request_list")
|
||||
else:
|
||||
messages.error(request, "کاربری با این مشخصات یافت نشد!")
|
||||
return redirect("accounts:login")
|
||||
|
||||
return render(request, "accounts/login.html")
|
||||
|
||||
|
@ -37,7 +34,7 @@ def dashboard(request):
|
|||
return render(request, "accounts/dashboard.html")
|
||||
|
||||
|
||||
|
||||
@login_required
|
||||
def customer_list(request):
|
||||
# Get all profiles that have customer role
|
||||
customers = Profile.objects.filter(roles__slug=UserRoles.CUSTOMER.value, is_deleted=False).select_related('user')
|
||||
|
@ -163,3 +160,9 @@ def get_customer_data(request, customer_id):
|
|||
},
|
||||
'form_html': form_html
|
||||
})
|
||||
|
||||
|
||||
def logout_view(request):
|
||||
"""Log out current user and redirect to login page."""
|
||||
logout(request)
|
||||
return redirect("accounts:login")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue