chartManD commited on
Commit
7d2330f
·
1 Parent(s): e443a46

Manejo de salida del sistema como Presentado

Browse files
tecnicas/templates/tecnicas/main-panel.html CHANGED
@@ -1,4 +1,5 @@
1
  {% extends 'tecnicas/layouts/base.html' %}
 
2
 
3
  {% block title %}Panel principal{% endblock %}
4
 
@@ -14,16 +15,18 @@
14
  <section class="flex flex-col text-black flex-1 flex-wrap gap-4">
15
  <fieldset class="fieldset rounded-box border px-3 pb-3 rounded-2xl">
16
  <legend class="text-black fieldset-legend px-1.5">Nombre Presentador</legend>
17
- <p class="text-3xl max-sm:text-2xl font-medium">{{ presentador.nombre }}</p>
18
  </fieldset>
19
  <fieldset class="fieldset rounded-box border px-3 pb-3 rounded-2xl">
20
- <legend class="text-black fieldset-legend px-1.5">Identificador</legend>
21
- <p class="text-3xl max-sm:text-2xl font-medium">{{ presentador.id }}</p>
 
22
  </fieldset>
23
  </section>
24
  <section class="flex-1 flex justify-center">
25
  <button type="button"
26
- class="btn btn-active text-xl tracking-wider font-bold text-black btn-error py-8 px-12 border-b-red-600 btn-push">
 
27
  Salir del sistema
28
  </button>
29
  </section>
@@ -59,5 +62,13 @@
59
  </article>
60
  </article>
61
  </article>
 
 
 
 
62
  </article>
 
 
 
 
63
  {% endblock %}
 
1
  {% extends 'tecnicas/layouts/base.html' %}
2
+ {% load static %}
3
 
4
  {% block title %}Panel principal{% endblock %}
5
 
 
15
  <section class="flex flex-col text-black flex-1 flex-wrap gap-4">
16
  <fieldset class="fieldset rounded-box border px-3 pb-3 rounded-2xl">
17
  <legend class="text-black fieldset-legend px-1.5">Nombre Presentador</legend>
18
+ <p class="text-3xl max-sm:text-2xl font-medium">{{ name }}</p>
19
  </fieldset>
20
  <fieldset class="fieldset rounded-box border px-3 pb-3 rounded-2xl">
21
+ <legend class="text-black fieldset-legend px-1.5">Nombre de usuario</legend>
22
+ <p class="text-3xl max-sm:text-2xl font-medium">{{ username }}</p>
23
+ <p class="text-3xl max-sm:text-2xl font-medium">{{ cumple }}</p>
24
  </fieldset>
25
  </section>
26
  <section class="flex-1 flex justify-center">
27
  <button type="button"
28
+ class="btn btn-active text-xl tracking-wider font-bold text-black btn-error py-8 px-12 border-b-red-600 btn-push"
29
+ onclick="exit_sesion('frm-exit')">
30
  Salir del sistema
31
  </button>
32
  </section>
 
62
  </article>
63
  </article>
64
  </article>
65
+ <form action="" method="post" class="frm-exit hidden">
66
+ <input type="hidden" name="action" class="action-input">
67
+ {% csrf_token %}
68
+ </form>
69
  </article>
70
+ {% endblock %}
71
+
72
+ {% block extra_js %}
73
+ <script src="{% static 'js/actions-form.js' %}"></script>
74
  {% endblock %}
tecnicas/views/main_panel.py CHANGED
@@ -1,10 +1,22 @@
1
- from django.shortcuts import render
 
 
 
2
 
3
- def mainPanel(req):
4
- pres = Presente("1233MMAS092222", "Juan Mendez Salazar")
5
- return render(req, "tecnicas/main-panel.html", context={"presentador":pres})
6
 
7
- class Presente():
8
- def __init__(self, id, nombre):
9
- self.id = id
10
- self.nombre = nombre
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.contrib.auth import logout
2
+ from django.http import HttpRequest
3
+ from django.shortcuts import render, redirect
4
+ from tecnicas.utils import general_error
5
 
 
 
 
6
 
7
+ def mainPanel(req: HttpRequest):
8
+ if req.method == "GET":
9
+ context_view = {
10
+ "name": f"{req.user.first_name} {req.user.last_name}",
11
+ "username": f"{req.user.username}"
12
+ }
13
+ return render(req, "tecnicas/main-panel.html", context=context_view)
14
+ elif req.method == "POST":
15
+ action = req.POST["action"]
16
+ if action == "exit_session":
17
+ logout(req)
18
+ return redirect("cata_system:autenticacion")
19
+ else:
20
+ general_error("Acción no definida")
21
+ else:
22
+ general_error("Método no permitido")