Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
merouane committed Apr 12, 2024
1 parent 6e721df commit 59e1128
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 242 deletions.
Binary file modified sfe/db.sqlite3
Binary file not shown.
Binary file modified sfe/sfe/__pycache__/views.cpython-311.pyc
Binary file not shown.
27 changes: 26 additions & 1 deletion sfe/sfe/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,45 @@ def userslist(request):

def approve_user(request,user_id):
user = User.objects.get(pk=user_id)
email=user.email
send_mail(
"Votre compte IKKIS AE est active",
"Bonjour " f"{user.username}" " , vous pouvez accéder à la plateforme IKKIS AE maintenat .",
"ikkisauto@gmail.com",
[email],
fail_silently=False,
)
user.is_active=True
user.save()

messages.success(request,"Le Compte d'utilisateur " f"{user.username} est activé")
return redirect(userslist)

def inapprove_user(request,user_id):
user = User.objects.get(pk=user_id)
email=user.email
send_mail(
"Votre compte IKKIS AE est inactive",
"Bonjour " f"{user.username}" " , vous ne pouvez pas accéder à la plateforme IKKIS AE .",
"ikkisauto@gmail.com",
[email],
fail_silently=False,
)
user.is_active=False
user.save()
messages.error(request,"Le Compte d'utilisateur " f"{user.username} est inactivé" )
return redirect(userslist)

def delete_user(request,user_id):
user= User.objects.get(pk=user_id)
email=user.email
send_mail(
"Vous pouvez plus acceder IKKIS AE",
"Bonjour " f"{user.username}" " malheureusement, vous pouvez plus accéder à la plateforme IKKIS AE, si vous pensez que c'est un problème pour contacter votre agence.",
"ikkisauto@gmail.com",
[email],
fail_silently=False,
)
user.delete()
messages.error(request,"Le Compte d'utilisateur " f"{user.username} est supprimé" )
return redirect(userslist)
Expand Down Expand Up @@ -121,7 +146,7 @@ def add_user(request):
user = User.objects.create_user(username=username,email=email,password=password)
user.is_active=False
user.save()
messages.success(request,"Utilisaeur ajoute")
messages.success(request,"Vous avez ajoutee l'utilisateur " f"{user.username}")

return redirect('userlist')
return render(request,'auth/userlist.html')
Expand Down
13 changes: 5 additions & 8 deletions sfe/templates/adm/dash.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,22 @@
</div>
<div class="z-50 hidden my-4 text-base list-none bg-white divide-y divide-gray-100 rounded shadow dark:bg-gray-700 dark:divide-gray-600" id="dropdown-user">
<div class="px-4 py-3" role="none">
<p class="text-sm text-gray-900 dark:text-white" role="none">
<p class="text-sm text-gray-900 " role="none">
{{user.username}}
</p>
<p class="text-sm font-medium text-gray-900 truncate dark:text-gray-300" role="none">
<p class="text-sm font-medium text-gray-900 truncate " role="none">
{{user.email}}
</p>
</div>
<ul class="py-1" role="none">
<li>
<a href="#" class="block px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600 dark:hover:text-white" role="menuitem">Dashboard</a>
<a href="{% url 'dashboard' %}" class="block px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 " role="menuitem">Table de bord</a>
</li>
<li>
<a href="#" class="block px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600 dark:hover:text-white" role="menuitem">Settings</a>
<a href="#" class="block px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 " role="menuitem">Profile</a>
</li>
<li>
<a href="#" class="block px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600 dark:hover:text-white" role="menuitem">Earnings</a>
</li>
<li>
<a href="#" class="block px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600 dark:hover:text-white" role="menuitem">Sign out</a>
<a href="{% url 'logout' %}" class="block px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 " role="menuitem">Se déconnecter</a>
</li>
</ul>
</div>
Expand Down
35 changes: 29 additions & 6 deletions sfe/templates/adm/userslist.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
</div>
</button>
</div>






Expand All @@ -49,9 +52,9 @@
<div id="crud-modal" tabindex="-1" aria-hidden="true" class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
<div class="relative p-4 w-full max-w-md max-h-full">
<!-- Modal content -->
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
<div class="relative bg-white rounded-lg shadow ">
<!-- Modal header -->
<div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t dark:border-gray-600">
<div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t ">
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">
Create New Product
</h3>
Expand All @@ -69,15 +72,15 @@ <h3 class="text-lg font-semibold text-gray-900 dark:text-white">
<div class="grid gap-4 mb-4 grid-cols-2">
<div class="col-span-2">
<label for="name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">username</label>
<input type="text" name="username" id="username" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" placeholder="Type product name" required="">
<input type="text" name="username" id="username" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 " placeholder="Type product name" required="">
</div>
<div class="col-span-2 sm:col-span-1">
<label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">email</label>
<input type="email" name="email" id="email" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" placeholder="$2999" required="">
<input type="email" name="email" id="email" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 " placeholder="$2999" required="">
</div>
<div class="col-span-2 sm:col-span-1">
<label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">password</label>
<input type="password" id="password" name="password" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" placeholder="$2999" required="">
<input type="password" id="password" name="password" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 " placeholder="$2999" required="">
</div>

</div>
Expand Down Expand Up @@ -107,12 +110,21 @@ <h3 class="text-lg font-semibold text-gray-900 dark:text-white">
<th scope="col" class="px-6 py-3">
Status
</th>
<th scope="col" class="px-6 py-3">
Role
</th>
<th scope="col" class="px-6 py-3">
Actions
</th>

</tr>
</thead>
<tbody>





{% for user in users %}


Expand All @@ -130,13 +142,23 @@ <h3 class="text-lg font-semibold text-gray-900 dark:text-white">
<td class="px-6 py-4">
<div class="flex items-center">

{% if user.is_active is True %}
{% if user.is_active is True %}
<div class="h-2.5 w-2.5 rounded-full bg-green-500 me-2"></div> Actif
{% else %}
<div class="h-2.5 w-2.5 rounded-full bg-red-500 me-2"></div> Inactif
{% endif %}
</div>
</td>
<td class="px-6 py-4">
<div class="flex items-center">

{% if user.is_superuser is True %}
<div class="h-2.5 w-2.5 rounded-full bg-green-500 me-2"></div> admin
{% else %}
<div class="h-2.5 w-2.5 rounded-full bg-red-500 me-2"></div> client
{% endif %}
</div>
</td>
<td class="px-6 py-4">
<!-- Modal toggle -->
<a href="{% url 'approve_user' user_id=user.id %}" type="button" class="mr-2 font-medium text-green-500 hover:underline">Activer</a>
Expand All @@ -145,6 +167,7 @@ <h3 class="text-lg font-semibold text-gray-900 dark:text-white">

</td>
{% endfor %}

</tr>

</div>
Expand Down
15 changes: 6 additions & 9 deletions sfe/templates/admdashnav.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,24 @@

</button>
</div>
<div class="z-50 hidden my-4 text-base list-none bg-white divide-y divide-gray-100 rounded shadow dark:bg-gray-700 dark:divide-gray-600" id="dropdown-user">
<div class="z-50 hidden my-4 text-base list-none bg-white divide-y divide-gray-100 rounded shadow " id="dropdown-user">
<div class="px-4 py-3" role="none">
<p class="text-sm text-gray-900 dark:text-white" role="none">
<p class="text-sm text-gray-900 " role="none">
{{user.username}}
</p>
<p class="text-sm font-medium text-gray-900 truncate dark:text-gray-300" role="none">
<p class="text-sm font-medium text-gray-900 truncate " role="none">
{{user.email}}
</p>
</div>
<ul class="py-1" role="none">
<li>
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600 dark:hover:text-white" role="menuitem">Dashboard</a>
<a href="{% url 'dashboard' %}" class="block px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 " role="menuitem">Table de bord</a>
</li>
<li>
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600 dark:hover:text-white" role="menuitem">Settings</a>
<a href="#" class="block px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 " role="menuitem">Profile</a>
</li>
<li>
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600 dark:hover:text-white" role="menuitem">Earnings</a>
</li>
<li>
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600 dark:hover:text-white" role="menuitem">Sign out</a>
<a href="{% url 'logout' %}" class="block px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 " role="menuitem">Se déconnecter</a>
</li>
</ul>
</div>
Expand Down
Loading

0 comments on commit 59e1128

Please sign in to comment.