Spaces:
Running
Running
Creacion de ruta pra formulario style-words
Browse files- tecnicas/forms/__init__.py +1 -1
- tecnicas/forms/{palabras_form.py → codes_form.py} +2 -2
- tecnicas/static/js/panel-codes.js +156 -0
- tecnicas/static/js/panel-words.js +60 -148
- tecnicas/templates/tecnicas/create_sesion/configuracion-panel-codes.html +2 -2
- tecnicas/templates/tecnicas/create_sesion/configuracion-panel-words.html +62 -0
- tecnicas/urls.py +5 -4
- tecnicas/views/__init__.py +2 -1
- tecnicas/views/configuration_panel_codes.py +4 -5
- tecnicas/views/configuration_panel_words.py +7 -4
tecnicas/forms/__init__.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
from .sesion_basic_form import SesionBasicForm
|
| 2 |
from .sesion_tags_form import SesionTagsForm
|
| 3 |
from .etiqueta_form import EtiquetaForm
|
| 4 |
-
from .
|
| 5 |
from .catador_form import CatadorForm
|
|
|
|
| 1 |
from .sesion_basic_form import SesionBasicForm
|
| 2 |
from .sesion_tags_form import SesionTagsForm
|
| 3 |
from .etiqueta_form import EtiquetaForm
|
| 4 |
+
from .codes_form import CodesForm
|
| 5 |
from .catador_form import CatadorForm
|
tecnicas/forms/{palabras_form.py → codes_form.py}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
from django import forms
|
| 2 |
|
| 3 |
-
class
|
| 4 |
def __init__(self, *args, codes = [], **kwargs):
|
| 5 |
super().__init__(*args, **kwargs)
|
| 6 |
|
| 7 |
for index, code in enumerate(codes):
|
| 8 |
self.fields[f'producto_{index+1}'] = forms.CharField(max_length=3, required=True, min_length=3, initial=code, label=f"codigo {index+1}", widget=forms.TextInput(attrs={
|
| 9 |
-
"class": "ct-
|
| 10 |
}))
|
|
|
|
| 1 |
from django import forms
|
| 2 |
|
| 3 |
+
class CodesForm(forms.Form):
|
| 4 |
def __init__(self, *args, codes = [], **kwargs):
|
| 5 |
super().__init__(*args, **kwargs)
|
| 6 |
|
| 7 |
for index, code in enumerate(codes):
|
| 8 |
self.fields[f'producto_{index+1}'] = forms.CharField(max_length=3, required=True, min_length=3, initial=code, label=f"codigo {index+1}", widget=forms.TextInput(attrs={
|
| 9 |
+
"class": "ct-code bg-gray-300 p-1 border-b-1 text-center w-full disabled:bg-gray-500 uppercase"
|
| 10 |
}))
|
tecnicas/static/js/panel-codes.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
let inWords = document
|
| 2 |
+
.getElementsByClassName("ct-codes-form")[0]
|
| 3 |
+
.getElementsByClassName("ct-code");
|
| 4 |
+
let codes = [];
|
| 5 |
+
let numCata = document.getElementsByClassName("ct-num-cata")[0].value;
|
| 6 |
+
|
| 7 |
+
let sortData;
|
| 8 |
+
|
| 9 |
+
initIU();
|
| 10 |
+
|
| 11 |
+
function submitData(e) {
|
| 12 |
+
const codesInput = document.createElement("input");
|
| 13 |
+
codesInput.type = "hidden";
|
| 14 |
+
codesInput.name = "sort_codes";
|
| 15 |
+
codesInput.value = JSON.stringify(sortData);
|
| 16 |
+
this.appendChild(codesInput);
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
function initIU() {
|
| 20 |
+
setCodes();
|
| 21 |
+
definePermutations();
|
| 22 |
+
addIUPermutations();
|
| 23 |
+
|
| 24 |
+
const formWords = document.getElementsByClassName("ct-codes-form")[0];
|
| 25 |
+
formWords.addEventListener("submit", submitData);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
function setCodes() {
|
| 29 |
+
if (codes) {
|
| 30 |
+
codes = [];
|
| 31 |
+
}
|
| 32 |
+
for (let i = 0; i < inWords.length; i++) {
|
| 33 |
+
codes.push(inWords.item(i).value.toUpperCase());
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function setPermutations() {
|
| 38 |
+
definePermutations();
|
| 39 |
+
addIUPermutations();
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
function definePermutations() {
|
| 43 |
+
setCodes();
|
| 44 |
+
const permutations = generatePermutations(codes);
|
| 45 |
+
const newPer = shuffle(permutations);
|
| 46 |
+
|
| 47 |
+
const usePermutations = [];
|
| 48 |
+
let index = 0;
|
| 49 |
+
|
| 50 |
+
while (true) {
|
| 51 |
+
if (usePermutations.length == numCata) {
|
| 52 |
+
break;
|
| 53 |
+
} else if (index < newPer.length) {
|
| 54 |
+
usePermutations.push(newPer[index]);
|
| 55 |
+
index++;
|
| 56 |
+
} else if (index >= newPer.length) {
|
| 57 |
+
index = 0;
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
const permutationsSort = [];
|
| 62 |
+
|
| 63 |
+
usePermutations.forEach((permutation) => {
|
| 64 |
+
let newValue = [];
|
| 65 |
+
let index = 1;
|
| 66 |
+
|
| 67 |
+
permutation.forEach((cod) => {
|
| 68 |
+
newValue.push({
|
| 69 |
+
code: cod,
|
| 70 |
+
position: index,
|
| 71 |
+
});
|
| 72 |
+
|
| 73 |
+
index++;
|
| 74 |
+
});
|
| 75 |
+
|
| 76 |
+
permutationsSort.push(newValue);
|
| 77 |
+
});
|
| 78 |
+
|
| 79 |
+
sortData = permutationsSort.slice();
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
function generatePermutations(objetos) {
|
| 83 |
+
var result = [];
|
| 84 |
+
|
| 85 |
+
var backtrack = (index, objetos) => {
|
| 86 |
+
if (index === objetos.length) {
|
| 87 |
+
result.push(objetos.slice());
|
| 88 |
+
return;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
for (let j = index; j < objetos.length; j++) {
|
| 92 |
+
[objetos[index], objetos[j]] = [objetos[j], objetos[index]];
|
| 93 |
+
backtrack(index + 1, objetos);
|
| 94 |
+
[objetos[index], objetos[j]] = [objetos[j], objetos[index]];
|
| 95 |
+
}
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
backtrack(0, objetos);
|
| 99 |
+
return result;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
function shuffle(arr) {
|
| 103 |
+
const arrSuffle = arr.slice();
|
| 104 |
+
|
| 105 |
+
for (let i = arrSuffle.length - 1; i > 0; i--) {
|
| 106 |
+
const j = Math.floor(Math.random() * (i + 1));
|
| 107 |
+
[arrSuffle[i], arrSuffle[j]] = [arrSuffle[j], arrSuffle[i]];
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
return arrSuffle;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
function addIUPermutations() {
|
| 114 |
+
const container = document.getElementsByClassName("ct-orden-list")[0];
|
| 115 |
+
const itemsChild = [];
|
| 116 |
+
container.replaceChildren();
|
| 117 |
+
|
| 118 |
+
let index = 1;
|
| 119 |
+
|
| 120 |
+
sortData.forEach((permuta) => {
|
| 121 |
+
const paragraph = document.createElement("p");
|
| 122 |
+
paragraph.classList.add("px-3", "font-bold", "text-xl", "text-black");
|
| 123 |
+
paragraph.textContent = `orden ${index}`;
|
| 124 |
+
|
| 125 |
+
const unlist = document.createElement("ul");
|
| 126 |
+
unlist.classList.add(
|
| 127 |
+
"flex",
|
| 128 |
+
"flex-wrap",
|
| 129 |
+
"gap-3",
|
| 130 |
+
"px-3",
|
| 131 |
+
"py-1",
|
| 132 |
+
"text-white"
|
| 133 |
+
);
|
| 134 |
+
|
| 135 |
+
permuta.forEach((obj) => {
|
| 136 |
+
const itemList = document.createElement("li");
|
| 137 |
+
itemList.classList.add(
|
| 138 |
+
"px-2",
|
| 139 |
+
"bg-gray-600",
|
| 140 |
+
"font-bold",
|
| 141 |
+
"tracking-wide"
|
| 142 |
+
);
|
| 143 |
+
itemList.textContent = `${obj.position}: ${obj.code}`;
|
| 144 |
+
unlist.appendChild(itemList);
|
| 145 |
+
});
|
| 146 |
+
|
| 147 |
+
const section = document.createElement("section");
|
| 148 |
+
section.classList.add("bg-gray-400", "py-2");
|
| 149 |
+
|
| 150 |
+
section.appendChild(paragraph);
|
| 151 |
+
section.appendChild(unlist);
|
| 152 |
+
|
| 153 |
+
container.appendChild(section);
|
| 154 |
+
index++;
|
| 155 |
+
});
|
| 156 |
+
}
|
tecnicas/static/js/panel-words.js
CHANGED
|
@@ -1,156 +1,68 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
let
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
const codesInput = document.createElement("input");
|
| 13 |
-
codesInput.type = "hidden";
|
| 14 |
-
codesInput.name = "sort_codes";
|
| 15 |
-
codesInput.value = JSON.stringify(sortData);
|
| 16 |
-
this.appendChild(codesInput);
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
-
function initIU() {
|
| 20 |
-
setCodes();
|
| 21 |
-
definePermutations();
|
| 22 |
-
addIUPermutations();
|
| 23 |
-
|
| 24 |
-
const formWords = document.getElementsByClassName("ct-palabras-form")[0];
|
| 25 |
-
formWords.addEventListener("submit", submitData);
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
function setCodes() {
|
| 29 |
-
if (codes) {
|
| 30 |
-
codes = [];
|
| 31 |
-
}
|
| 32 |
-
for (let i = 0; i < inWords.length; i++) {
|
| 33 |
-
codes.push(inWords.item(i).value.toUpperCase());
|
| 34 |
-
}
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
function setPermutations() {
|
| 38 |
-
definePermutations();
|
| 39 |
-
addIUPermutations();
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
function definePermutations() {
|
| 43 |
-
setCodes();
|
| 44 |
-
const permutations = generatePermutations(codes);
|
| 45 |
-
const newPer = shuffle(permutations);
|
| 46 |
-
|
| 47 |
-
const usePermutations = [];
|
| 48 |
-
let index = 0;
|
| 49 |
-
|
| 50 |
-
while (true) {
|
| 51 |
-
if (usePermutations.length == numCata) {
|
| 52 |
-
break;
|
| 53 |
-
} else if (index < newPer.length) {
|
| 54 |
-
usePermutations.push(newPer[index]);
|
| 55 |
-
index++;
|
| 56 |
-
} else if (index >= newPer.length) {
|
| 57 |
-
index = 0;
|
| 58 |
-
}
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
const permutationsSort = [];
|
| 62 |
-
|
| 63 |
-
usePermutations.forEach((permutation) => {
|
| 64 |
-
let newValue = [];
|
| 65 |
-
let index = 1;
|
| 66 |
-
|
| 67 |
-
permutation.forEach((cod) => {
|
| 68 |
-
newValue.push({
|
| 69 |
-
code: cod,
|
| 70 |
-
position: index,
|
| 71 |
-
});
|
| 72 |
-
|
| 73 |
-
index++;
|
| 74 |
-
});
|
| 75 |
-
|
| 76 |
-
permutationsSort.push(newValue);
|
| 77 |
});
|
| 78 |
-
|
| 79 |
-
sortData = permutationsSort.slice();
|
| 80 |
}
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
var backtrack = (index, objetos) => {
|
| 86 |
-
if (index === objetos.length) {
|
| 87 |
-
result.push(objetos.slice());
|
| 88 |
-
return;
|
| 89 |
-
}
|
| 90 |
-
|
| 91 |
-
for (let j = index; j < objetos.length; j++) {
|
| 92 |
-
[objetos[index], objetos[j]] = [objetos[j], objetos[index]];
|
| 93 |
-
backtrack(index + 1, objetos);
|
| 94 |
-
[objetos[index], objetos[j]] = [objetos[j], objetos[index]];
|
| 95 |
-
}
|
| 96 |
-
};
|
| 97 |
-
|
| 98 |
-
backtrack(0, objetos);
|
| 99 |
-
return result;
|
| 100 |
}
|
| 101 |
|
| 102 |
-
function
|
| 103 |
-
const
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
const
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
});
|
| 146 |
-
|
| 147 |
-
const section = document.createElement("section");
|
| 148 |
-
section.classList.add("bg-gray-400", "py-2");
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
|
| 153 |
-
|
| 154 |
-
index++;
|
| 155 |
-
});
|
| 156 |
}
|
|
|
|
| 1 |
+
const selectWordsContainer = document.querySelector(".ct-words-select");
|
| 2 |
+
const tagsWords = document.querySelectorAll(".word");
|
| 3 |
+
let numberWords = 3;
|
| 4 |
+
const allWords = [];
|
| 5 |
+
|
| 6 |
+
for (let i = 0; i < tagsWords.length; i++) {
|
| 7 |
+
let atributes = tagsWords.item(i).children;
|
| 8 |
+
allWords.push({
|
| 9 |
+
id: atributes[1].innerText,
|
| 10 |
+
name: atributes[0].innerText,
|
| 11 |
+
selected: false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
});
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
|
| 15 |
+
for (let i = 1; i <= numberWords; i++) {
|
| 16 |
+
const select = creadSelect(i);
|
| 17 |
+
selectWordsContainer.appendChild(select);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
|
| 20 |
+
function creadSelect(index) {
|
| 21 |
+
const label = document.createElement("label");
|
| 22 |
+
label.attributes["form"] = `palabra-${index}`;
|
| 23 |
+
label.classList.add(
|
| 24 |
+
"font-medium",
|
| 25 |
+
"py-2",
|
| 26 |
+
"px-3",
|
| 27 |
+
"bg-gray-200",
|
| 28 |
+
"capitalize",
|
| 29 |
+
"rounded",
|
| 30 |
+
"text-center"
|
| 31 |
+
);
|
| 32 |
+
|
| 33 |
+
const p = document.createElement("p");
|
| 34 |
+
p.innerText = `Palabra ${index}`;
|
| 35 |
+
|
| 36 |
+
const select = document.createElement("select");
|
| 37 |
+
select.attributes["id"] = `palabra-${index}`;
|
| 38 |
+
select.name = `palabra-${index}`;
|
| 39 |
+
select.required = true;
|
| 40 |
+
select.classList.add(
|
| 41 |
+
"ct-select-op",
|
| 42 |
+
"p-1",
|
| 43 |
+
"rounded",
|
| 44 |
+
"bg-gray-500",
|
| 45 |
+
"[*]:capitalize",
|
| 46 |
+
"[*]:text-white"
|
| 47 |
+
);
|
| 48 |
+
|
| 49 |
+
const emtpyOption = document.createElement("option");
|
| 50 |
+
emtpyOption.value = "";
|
| 51 |
+
emtpyOption.innerText = "Seleccione palabra";
|
| 52 |
+
emtpyOption.attributes["selected"] = true;
|
| 53 |
+
emtpyOption.attributes["disabled"] = true;
|
| 54 |
+
|
| 55 |
+
select.appendChild(emtpyOption);
|
| 56 |
+
|
| 57 |
+
allWords.forEach((dataWord, i) => {
|
| 58 |
+
const option = document.createElement("option");
|
| 59 |
+
option.value = dataWord.id;
|
| 60 |
+
option.innerText = dataWord.name;
|
| 61 |
+
select.appendChild(option);
|
| 62 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
label.appendChild(p);
|
| 65 |
+
label.appendChild(select);
|
| 66 |
|
| 67 |
+
return label;
|
|
|
|
|
|
|
| 68 |
}
|
tecnicas/templates/tecnicas/create_sesion/configuracion-panel-codes.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
| 10 |
{% if error %}
|
| 11 |
<p class="text-2xl">{{ error }}</p>
|
| 12 |
{% endif %}
|
| 13 |
-
<form method="post" action="" class="ct-
|
| 14 |
{% csrf_token %}
|
| 15 |
<h2 class="text-2xl mb-2 font-bold">Codificar productos</h2>
|
| 16 |
<article class="flex flex-row flex-wrap gap-4 items-center justify-center">
|
|
@@ -51,5 +51,5 @@
|
|
| 51 |
{% endblock %}
|
| 52 |
|
| 53 |
{% block extra_js %}
|
| 54 |
-
<script src="{% static 'js/panel-
|
| 55 |
{% endblock %}
|
|
|
|
| 10 |
{% if error %}
|
| 11 |
<p class="text-2xl">{{ error }}</p>
|
| 12 |
{% endif %}
|
| 13 |
+
<form method="post" action="" class="ct-codes-form flex flex-col gap-5">
|
| 14 |
{% csrf_token %}
|
| 15 |
<h2 class="text-2xl mb-2 font-bold">Codificar productos</h2>
|
| 16 |
<article class="flex flex-row flex-wrap gap-4 items-center justify-center">
|
|
|
|
| 51 |
{% endblock %}
|
| 52 |
|
| 53 |
{% block extra_js %}
|
| 54 |
+
<script src="{% static 'js/panel-codes.js' %}"></script>
|
| 55 |
{% endblock %}
|
tecnicas/templates/tecnicas/create_sesion/configuracion-panel-words.html
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends 'tecnicas/layouts/base.html' %}
|
| 2 |
+
{% load static %}
|
| 3 |
+
|
| 4 |
+
{% block title %}Panel Configuracion{% endblock %}
|
| 5 |
+
|
| 6 |
+
{% block content %}
|
| 7 |
+
<article class="w-full flex flex-col justify-center items-center bg-gray-600 my-10">
|
| 8 |
+
<section class="w-fit h-fit relative">
|
| 9 |
+
<article class="flex flex-col gap-4 bg-gray-400 md:p-10 p-5 rounded-2xl lg:w-4xl w-full">
|
| 10 |
+
<ul class="all-words hidden">
|
| 11 |
+
{% for word in words %}
|
| 12 |
+
<li class="word">
|
| 13 |
+
<p>{{ word.nombre_palabra }}</p>
|
| 14 |
+
<p>{{ word.id }}</p>
|
| 15 |
+
</li>
|
| 16 |
+
{% endfor %}
|
| 17 |
+
</ul>
|
| 18 |
+
<h1 class="text-center font-bold text-4xl">Panel de configuración</h1>
|
| 19 |
+
<hr>
|
| 20 |
+
{% if error %}
|
| 21 |
+
<p class="bg-red-400 font-bold text-lg tracking-wide text-white capitalize text-center py-2">
|
| 22 |
+
{{ error }}
|
| 23 |
+
</p>
|
| 24 |
+
{% endif %}
|
| 25 |
+
|
| 26 |
+
<article class="flex flex-col md:flex-row gap-5 justify-between items-center">
|
| 27 |
+
<section class="flex-1/3 bg-gray-600 text-white p-4 rounded-lg text-center">
|
| 28 |
+
<p>Soy una palabra</p>
|
| 29 |
+
</section>
|
| 30 |
+
<section class="flex-2/3 w-full">
|
| 31 |
+
<form action="" method="get" class="h-full w-full">
|
| 32 |
+
{% csrf_token %}
|
| 33 |
+
<label for="search">
|
| 34 |
+
<input type="text" name="search" id="search" placeholder="Buscar palabra"
|
| 35 |
+
class="p-2 px-4 bg-gray-200 rounded-lg w-full text-lg">
|
| 36 |
+
</label>
|
| 37 |
+
</form>
|
| 38 |
+
</section>
|
| 39 |
+
</article>
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
<form action="" method="post" class="flex flex-col gap-5">
|
| 43 |
+
{% csrf_token %}
|
| 44 |
+
<article class="p-4 flex flex-col items-center gap-2 rounded">
|
| 45 |
+
<h2 class="text-2xl mb-2 text-center font-bold">Estilo Atributos<br>Seleccion de palabras</h2>
|
| 46 |
+
<div class="ct-words-select flex flex-row flex-wrap justify-center items-center gap-5 text-lg">
|
| 47 |
+
</div>
|
| 48 |
+
<hr>
|
| 49 |
+
<button type="button"
|
| 50 |
+
class="ct-gen-or text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 active:border-blue-500 border-blue-800 transition-all rounded-xl bg-blue-500 text-white w-fit capitalize">
|
| 51 |
+
Agregar otra palabra
|
| 52 |
+
</button>
|
| 53 |
+
</article>
|
| 54 |
+
</form>
|
| 55 |
+
</article>
|
| 56 |
+
</section>
|
| 57 |
+
</article>
|
| 58 |
+
{% endblock %}
|
| 59 |
+
|
| 60 |
+
{% block extra_js %}
|
| 61 |
+
<script src="{% static 'js/panel-words.js' %}"></script>
|
| 62 |
+
{% endblock %}
|
tecnicas/urls.py
CHANGED
|
@@ -9,11 +9,12 @@ urlpatterns = [
|
|
| 9 |
path("autenticacion", views.autentication, name="autenticacion"),
|
| 10 |
path("catador-login", views.catadorLogin, name="catador_login"),
|
| 11 |
path("panel-catadores", views.managementCatadores, name="panel_catadores"),
|
| 12 |
-
path("panel-sesiones", views.
|
| 13 |
path("seleccion-tecnica", views.selecionTecnica, name="seleccion_tecnica"),
|
| 14 |
-
path("panel-configuracion-basic", views.
|
| 15 |
-
path("panel-configuracion-tags", views.
|
| 16 |
-
path("panel-configuracion-codes", views.
|
|
|
|
| 17 |
path("nueva-etiqueta", views.newTag, name="nueva_etiqueta"),
|
| 18 |
path("crear-catador", views.testerCreate, name="crear_catador"),
|
| 19 |
path("buscar-catador", views.testerSearch, name="buscar_catador"),
|
|
|
|
| 9 |
path("autenticacion", views.autentication, name="autenticacion"),
|
| 10 |
path("catador-login", views.catadorLogin, name="catador_login"),
|
| 11 |
path("panel-catadores", views.managementCatadores, name="panel_catadores"),
|
| 12 |
+
path("panel-sesiones", views.sesionsPanel, name="panel_sesiones"),
|
| 13 |
path("seleccion-tecnica", views.selecionTecnica, name="seleccion_tecnica"),
|
| 14 |
+
path("panel-configuracion-basic", views.configurationPanelBasic, name="panel_configuracion_basic"),
|
| 15 |
+
path("panel-configuracion-tags", views.configurationPanelTags, name="panel_configuracion_tags"),
|
| 16 |
+
path("panel-configuracion-codes", views.configurationPanelCodes, name="panel_configuracion_codes"),
|
| 17 |
+
path("panel-configuracion-words", views.configurationPanelWords, name="panel_configuracion_words"),
|
| 18 |
path("nueva-etiqueta", views.newTag, name="nueva_etiqueta"),
|
| 19 |
path("crear-catador", views.testerCreate, name="crear_catador"),
|
| 20 |
path("buscar-catador", views.testerSearch, name="buscar_catador"),
|
tecnicas/views/__init__.py
CHANGED
|
@@ -5,8 +5,9 @@ from .management_catadores import managementCatadores
|
|
| 5 |
from .sessions_panel import sesionsPanel
|
| 6 |
from .seleccion_tecnica import selecionTecnica
|
| 7 |
from .configuration_panel_basic import configurationPanelBasic
|
| 8 |
-
from .configuration_panel_tags import
|
| 9 |
from .configuration_panel_codes import configurationPanelCodes
|
|
|
|
| 10 |
from .api_tag import newTag
|
| 11 |
from .tester_create import testerCreate
|
| 12 |
from .tester_search import testerSearch
|
|
|
|
| 5 |
from .sessions_panel import sesionsPanel
|
| 6 |
from .seleccion_tecnica import selecionTecnica
|
| 7 |
from .configuration_panel_basic import configurationPanelBasic
|
| 8 |
+
from .configuration_panel_tags import configurationPanelTags
|
| 9 |
from .configuration_panel_codes import configurationPanelCodes
|
| 10 |
+
from .configuration_panel_words import configurationPanelWords
|
| 11 |
from .api_tag import newTag
|
| 12 |
from .tester_create import testerCreate
|
| 13 |
from .tester_search import testerSearch
|
tecnicas/views/configuration_panel_codes.py
CHANGED
|
@@ -2,7 +2,7 @@ from django.http import HttpRequest
|
|
| 2 |
from django.shortcuts import render, redirect
|
| 3 |
from django.urls import reverse
|
| 4 |
from ..utils import generarCodigos
|
| 5 |
-
from ..forms import
|
| 6 |
import json
|
| 7 |
|
| 8 |
|
|
@@ -20,7 +20,7 @@ def configurationPanelCodes(req: HttpRequest):
|
|
| 20 |
if req.method == "GET":
|
| 21 |
codes_products = generarCodigos(num_products)
|
| 22 |
|
| 23 |
-
form_worlds =
|
| 24 |
|
| 25 |
context_worlds_form = {
|
| 26 |
"form_worlds": form_worlds,
|
|
@@ -37,7 +37,7 @@ def configurationPanelCodes(req: HttpRequest):
|
|
| 37 |
if name.__contains__("producto_"):
|
| 38 |
codes.append(value)
|
| 39 |
|
| 40 |
-
form_worlds =
|
| 41 |
|
| 42 |
context_worlds_form = {
|
| 43 |
"form_worlds": form_worlds,
|
|
@@ -51,9 +51,8 @@ def configurationPanelCodes(req: HttpRequest):
|
|
| 51 |
codes_sort["product_codes"].append({name: value})
|
| 52 |
|
| 53 |
codes_sort["sort_codes"] = sorts_code
|
| 54 |
-
|
| 55 |
req.session["form_codes"] = codes_sort
|
| 56 |
-
|
| 57 |
else:
|
| 58 |
context_worlds_form["error"] = "error en los datos recibidos"
|
| 59 |
|
|
|
|
| 2 |
from django.shortcuts import render, redirect
|
| 3 |
from django.urls import reverse
|
| 4 |
from ..utils import generarCodigos
|
| 5 |
+
from ..forms import CodesForm
|
| 6 |
import json
|
| 7 |
|
| 8 |
|
|
|
|
| 20 |
if req.method == "GET":
|
| 21 |
codes_products = generarCodigos(num_products)
|
| 22 |
|
| 23 |
+
form_worlds = CodesForm(codes=codes_products)
|
| 24 |
|
| 25 |
context_worlds_form = {
|
| 26 |
"form_worlds": form_worlds,
|
|
|
|
| 37 |
if name.__contains__("producto_"):
|
| 38 |
codes.append(value)
|
| 39 |
|
| 40 |
+
form_worlds = CodesForm(req.POST, codes=codes)
|
| 41 |
|
| 42 |
context_worlds_form = {
|
| 43 |
"form_worlds": form_worlds,
|
|
|
|
| 51 |
codes_sort["product_codes"].append({name: value})
|
| 52 |
|
| 53 |
codes_sort["sort_codes"] = sorts_code
|
|
|
|
| 54 |
req.session["form_codes"] = codes_sort
|
| 55 |
+
return redirect(reverse("cata_system:panel_configuracion_words"))
|
| 56 |
else:
|
| 57 |
context_worlds_form["error"] = "error en los datos recibidos"
|
| 58 |
|
tecnicas/views/configuration_panel_words.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
-
from
|
|
|
|
| 3 |
|
| 4 |
def configurationPanelWords(req: HttpRequest):
|
| 5 |
if req.method == "GET":
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
+
from django.shortcuts import render
|
| 3 |
+
from ..models.palabra import Palabra
|
| 4 |
|
| 5 |
def configurationPanelWords(req: HttpRequest):
|
| 6 |
if req.method == "GET":
|
| 7 |
+
allWords = Palabra.objects.all()
|
| 8 |
+
context = {
|
| 9 |
+
"words": allWords
|
| 10 |
+
}
|
| 11 |
+
return render(req, "tecnicas/create_sesion/configuracion-panel-words.html", context)
|