chartManD commited on
Commit
c5675ea
·
1 Parent(s): 7f9ab19

Se establecen etiqutas por defecto segun la escala usada

Browse files
tecnicas/forms/sesion_tags_form.py CHANGED
@@ -1,25 +1,35 @@
1
  from django import forms
2
-
3
  from ..models import Etiqueta
4
 
 
5
  class SesionTagsForm(forms.Form):
6
- def __init__(self, *args, longitud=None, tipo_escala:str=None, **kwargs):
 
 
 
 
 
 
 
 
 
7
  super().__init__(*args, **kwargs)
8
 
9
  if tipo_escala == "estructurada":
 
10
  for i in range(longitud):
11
- self.fields[f'segmento_{i+1}'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), required=True, label=f"segmento {i+1}", empty_label="Selecione opcion", widget=forms.Select(attrs={
12
- "class":"ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
13
  }))
14
  else:
15
- self.fields['punto_inicial'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), required=True, label="Punto inicial", empty_label="Selecione opcion", widget=forms.Select(attrs={
16
- "class":"ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
17
- }))
18
-
19
- self.fields['punto_medio'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), required=True, label="Punto medio", empty_label="Selecione opcion", widget=forms.Select(attrs={
20
- "class":"ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
21
- }))
22
-
23
- self.fields['punto_final'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), required=True, label="Punto final", empty_label="Selecione opcion", widget=forms.Select(attrs={
24
- "class":"ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
25
- }))
 
1
  from django import forms
 
2
  from ..models import Etiqueta
3
 
4
+
5
  class SesionTagsForm(forms.Form):
6
+ available_struture_tags = {
7
+ "5": ["percepcion nula", "percepcion moderada", "se puede percibir",
8
+ "percepcion intensa", "percepcion total"],
9
+ "7": ["percepcion nula", "ligera percepcion", "percepcion moderada", "se puede percibir", "buena percepcion",
10
+ "percepcion intensa", "percepcion total"],
11
+ "9": ["percepcion nula", "ligera percepcion", "poca percepcion", "percepcion moderada", "se puede percibir", "buena percepcion",
12
+ "percepcion intensa", "percepcion muy intensa", "percepcion total"]
13
+ }
14
+
15
+ def __init__(self, *args, longitud=None, tipo_escala: str = None, **kwargs):
16
  super().__init__(*args, **kwargs)
17
 
18
  if tipo_escala == "estructurada":
19
+ use_tags = self.available_struture_tags[f"{longitud}"]
20
  for i in range(longitud):
21
+ self.fields[f'segmento_{i+1}'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), initial=Etiqueta.objects.get(valor_etiqueta=use_tags[i]), required=True, label=f"segmento {i+1}", empty_label="Selecione opcion", widget=forms.Select(attrs={
22
+ "class": "ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
23
  }))
24
  else:
25
+ self.fields['punto_inicial'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), initial=Etiqueta.objects.get(valor_etiqueta="percepcion nula"), required=True, label="Punto inicial", empty_label="Selecione opcion", widget=forms.Select(attrs={
26
+ "class": "ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
27
+ }))
28
+
29
+ self.fields['punto_medio'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), initial=Etiqueta.objects.get(valor_etiqueta="se puede percibir"), required=True, label="Punto medio", empty_label="Selecione opcion", widget=forms.Select(attrs={
30
+ "class": "ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
31
+ }))
32
+
33
+ self.fields['punto_final'] = forms.ModelChoiceField(queryset=Etiqueta.objects.all(), initial=Etiqueta.objects.get(valor_etiqueta="percepcion total"), required=True, label="Punto final", empty_label="Selecione opcion", widget=forms.Select(attrs={
34
+ "class": "ct-select-op p-1 max-sm:w-full bg-surface-ligt [*]:capitalize"
35
+ }))
tecnicas/templates/tecnicas/create_sesion/configuracion-panel-tags.html CHANGED
@@ -19,7 +19,8 @@
19
  <article class="p-4 flex flex-col gap-2 rounded max-sm:text-center">
20
  <h2 class="text-2xl mb-2 font-bold">Seleccion de etiquetas</h2>
21
  {% for field in form_tags %}
22
- <div class="flex max-sm:flex-col justify-center items-center gap-5 max-sm:gap-2 text-lg border-b-4 border-l-4 border-btn-secondary bg-surface-card p-1">
 
23
  <label for="{{ field.id_for_label }}"
24
  class="font-medium p-1 px-3 max-sm:w-full capitalize rounded">
25
  {{ field.label }}
@@ -44,11 +45,10 @@
44
  <button type="submit" class="cts-btn-general cts-btn-primary btn-push flex-1 w-full">
45
  Continuar
46
  </button>
47
- <a href="{% url 'cata_system:seleccion_tecnica' %}" class="flex-1 w-full">
48
- <button type="button" class="cts-btn-general cts-btn-secondary btn-push w-full">
49
- Paso anterior
50
- </button>
51
- </a>
52
  </section>
53
  <a href="{% url 'cata_system:seleccion_tecnica' %}" class="flex-1 w-full">
54
  <button type="button" class="cts-btn-general cts-btn-error btn-push w-full">
@@ -71,7 +71,8 @@
71
  <p
72
  class="ct-error-tag mt-4 font-bold bg-red-500 text-white text-md capitalize text-center rounded hidden">
73
  error</p>
74
- <article class="flex max-sm:flex-col justify-center gap-8 max-sm:gap-4 mt-4 text-white font-medium tracking-wide">
 
75
  <button type="submit" class="cts-btn-general cts-btn-primary btn-push">
76
  Agregar
77
  </button>
@@ -89,20 +90,7 @@
89
 
90
  {% block extra_js %}
91
  <script src="{% static 'js/panel-tags.js' %}"></script>
 
92
 
93
- {%if escala == "estructurada"%}
94
- <script>
95
- for (let i = 0; i < options.length; i++) {
96
- if (options.item(i).value) {
97
- values.push(options.item(i).value)
98
- }
99
- }
100
-
101
- values.sort()
102
-
103
- for (let i = 0; i < values.length; i++) {
104
- itemsSelects.item(i).value = values[i]
105
- }
106
- </script>
107
- {% endif %}
108
- {% endblock %}
 
19
  <article class="p-4 flex flex-col gap-2 rounded max-sm:text-center">
20
  <h2 class="text-2xl mb-2 font-bold">Seleccion de etiquetas</h2>
21
  {% for field in form_tags %}
22
+ <div
23
+ class="flex max-sm:flex-col justify-center items-center gap-5 max-sm:gap-2 text-lg border-b-4 border-l-4 border-btn-secondary bg-surface-card p-1">
24
  <label for="{{ field.id_for_label }}"
25
  class="font-medium p-1 px-3 max-sm:w-full capitalize rounded">
26
  {{ field.label }}
 
45
  <button type="submit" class="cts-btn-general cts-btn-primary btn-push flex-1 w-full">
46
  Continuar
47
  </button>
48
+ <button type="button" class="cts-btn-general cts-btn-secondary btn-push w-full"
49
+ onclick="window.history.back();">
50
+ Paso anterior
51
+ </button>
 
52
  </section>
53
  <a href="{% url 'cata_system:seleccion_tecnica' %}" class="flex-1 w-full">
54
  <button type="button" class="cts-btn-general cts-btn-error btn-push w-full">
 
71
  <p
72
  class="ct-error-tag mt-4 font-bold bg-red-500 text-white text-md capitalize text-center rounded hidden">
73
  error</p>
74
+ <article
75
+ class="flex max-sm:flex-col justify-center gap-8 max-sm:gap-4 mt-4 text-white font-medium tracking-wide">
76
  <button type="submit" class="cts-btn-general cts-btn-primary btn-push">
77
  Agregar
78
  </button>
 
90
 
91
  {% block extra_js %}
92
  <script src="{% static 'js/panel-tags.js' %}"></script>
93
+ {% endblock %}
94
 
95
+ <a href="{% url 'cata_system:seleccion_tecnica' %}" class="flex-1 w-full">
96
+ </a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tecnicas/views/sessions_config/configuration_panel_tags.py CHANGED
@@ -1,8 +1,8 @@
1
  from django.http import HttpRequest
2
  from django.shortcuts import redirect, render
3
  from django.urls import reverse
4
- from ...forms import SesionTagsForm, EtiquetaForm
5
- from ...models import TipoEscala
6
 
7
 
8
  def configurationPanelTags(req: HttpRequest):
 
1
  from django.http import HttpRequest
2
  from django.shortcuts import redirect, render
3
  from django.urls import reverse
4
+ from tecnicas.forms import SesionTagsForm, EtiquetaForm
5
+ from tecnicas.models import TipoEscala
6
 
7
 
8
  def configurationPanelTags(req: HttpRequest):