djgentelella 0.4.3__py3-none-any.whl → 0.4.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- djgentelella/__init__.py +1 -1
- djgentelella/firmador_digital/forms.py +110 -0
- djgentelella/firmador_digital/models.py +21 -0
- djgentelella/firmador_digital/views.py +31 -0
- djgentelella/locale/es/LC_MESSAGES/django.mo +0 -0
- djgentelella/locale/es/LC_MESSAGES/django.po +48 -0
- djgentelella/static/gentelella/js/datatables.js +15 -0
- djgentelella/static/gentelella/js/obj_api_management.js +396 -343
- djgentelella/templates/gentelella/digital_signature/update_signature_settings.html +57 -0
- djgentelella/urls.py +2 -0
- {djgentelella-0.4.3.dist-info → djgentelella-0.4.5.dist-info}/METADATA +1 -1
- {djgentelella-0.4.3.dist-info → djgentelella-0.4.5.dist-info}/RECORD +16 -14
- {djgentelella-0.4.3.dist-info → djgentelella-0.4.5.dist-info}/AUTHORS +0 -0
- {djgentelella-0.4.3.dist-info → djgentelella-0.4.5.dist-info}/LICENSE.txt +0 -0
- {djgentelella-0.4.3.dist-info → djgentelella-0.4.5.dist-info}/WHEEL +0 -0
- {djgentelella-0.4.3.dist-info → djgentelella-0.4.5.dist-info}/top_level.txt +0 -0
djgentelella/__init__.py
CHANGED
|
@@ -4,6 +4,8 @@ from django import forms
|
|
|
4
4
|
from django.core.exceptions import ValidationError
|
|
5
5
|
from django.utils.translation import gettext_lazy as _
|
|
6
6
|
|
|
7
|
+
from djgentelella.firmador_digital.models import UserSignatureConfig, \
|
|
8
|
+
get_signature_default, FORMATS_DATE, FONT_ALIGNMENT, FONT_CHOICES
|
|
7
9
|
from djgentelella.firmador_digital.signvalue_utils import ValueDSParser
|
|
8
10
|
from djgentelella.forms.forms import GTForm
|
|
9
11
|
from djgentelella.widgets import core as genwidgets
|
|
@@ -26,3 +28,111 @@ class RenderValueForm(GTForm, ValueDSParser):
|
|
|
26
28
|
_("Invalid value not encoded as b64 o json parser error"),
|
|
27
29
|
code="invalid")
|
|
28
30
|
return jsondata
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class SignatureConfigForm(GTForm, forms.ModelForm):
|
|
34
|
+
backgroundColor = forms.CharField(
|
|
35
|
+
max_length=50,
|
|
36
|
+
widget=genwidgets.ColorInput,
|
|
37
|
+
required=True,
|
|
38
|
+
label=_("Background color")
|
|
39
|
+
)
|
|
40
|
+
contact = forms.CharField(
|
|
41
|
+
required=False,
|
|
42
|
+
max_length=100,
|
|
43
|
+
widget=genwidgets.TextInput,
|
|
44
|
+
label=_("Contact")
|
|
45
|
+
)
|
|
46
|
+
dateFormat = forms.ChoiceField(
|
|
47
|
+
widget=genwidgets.Select,
|
|
48
|
+
required=True,
|
|
49
|
+
choices=FORMATS_DATE,
|
|
50
|
+
label=_("Date format")
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
defaultSignMessage = forms.CharField(
|
|
54
|
+
widget=genwidgets.Textarea,
|
|
55
|
+
required=False,
|
|
56
|
+
max_length=100,
|
|
57
|
+
label=_("Signature message")
|
|
58
|
+
)
|
|
59
|
+
# font = forms.ChoiceField(
|
|
60
|
+
# required=True,
|
|
61
|
+
# widget=genwidgets.Select,
|
|
62
|
+
# label=_("Font"),
|
|
63
|
+
# choices=FONT_CHOICES
|
|
64
|
+
# )
|
|
65
|
+
fontAlignment = forms.ChoiceField(
|
|
66
|
+
choices=FONT_ALIGNMENT,
|
|
67
|
+
widget=genwidgets.Select,
|
|
68
|
+
required=True,
|
|
69
|
+
label=_("Font alignment")
|
|
70
|
+
)
|
|
71
|
+
fontColor = forms.CharField(
|
|
72
|
+
max_length=50,
|
|
73
|
+
widget=genwidgets.ColorInput,
|
|
74
|
+
required=True,
|
|
75
|
+
label=_("Font color"),
|
|
76
|
+
)
|
|
77
|
+
fontSize = forms.IntegerField(
|
|
78
|
+
min_value=5,
|
|
79
|
+
max_value=28,
|
|
80
|
+
initial=7,
|
|
81
|
+
widget=genwidgets.NumberInput,
|
|
82
|
+
label=_("Font size")
|
|
83
|
+
)
|
|
84
|
+
place = forms.CharField(
|
|
85
|
+
required=False,
|
|
86
|
+
max_length=100,
|
|
87
|
+
widget=genwidgets.TextInput,
|
|
88
|
+
label=_("Place")
|
|
89
|
+
)
|
|
90
|
+
reason = forms.CharField(
|
|
91
|
+
required=False,
|
|
92
|
+
max_length=100,
|
|
93
|
+
widget=genwidgets.TextInput,
|
|
94
|
+
label=_("Reason")
|
|
95
|
+
)
|
|
96
|
+
isVisibleSignature = forms.BooleanField(
|
|
97
|
+
required=False,
|
|
98
|
+
widget=genwidgets.YesNoInput,
|
|
99
|
+
label=_("Visible signature")
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
default_render_type = "as_grid"
|
|
103
|
+
|
|
104
|
+
grid_representation = [
|
|
105
|
+
[["contact"]],
|
|
106
|
+
[["place"]],
|
|
107
|
+
[["reason"]],
|
|
108
|
+
# [["dateFormat"], ["font"]],
|
|
109
|
+
[["dateFormat"], ["isVisibleSignature"]],
|
|
110
|
+
[["fontSize"], ["fontColor"], ["backgroundColor"], ["fontAlignment"]],
|
|
111
|
+
# [["isVisibleSignature"]],
|
|
112
|
+
[["defaultSignMessage"]],
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
class Meta:
|
|
116
|
+
model = UserSignatureConfig
|
|
117
|
+
fields = []
|
|
118
|
+
|
|
119
|
+
def __init__(self, *args, **kwargs):
|
|
120
|
+
super().__init__(*args, **kwargs)
|
|
121
|
+
|
|
122
|
+
cfg = self.instance.config if getattr(self.instance, "config",
|
|
123
|
+
None) else get_signature_default()
|
|
124
|
+
for key, value in cfg.items():
|
|
125
|
+
if key in self.fields:
|
|
126
|
+
self.fields[key].initial = value
|
|
127
|
+
|
|
128
|
+
def save(self, commit=True):
|
|
129
|
+
data = get_signature_default()
|
|
130
|
+
for key in data.keys():
|
|
131
|
+
if key in self.cleaned_data:
|
|
132
|
+
val = self.cleaned_data[key]
|
|
133
|
+
|
|
134
|
+
if isinstance(data[key], str) and not isinstance(val, str):
|
|
135
|
+
val = str(val)
|
|
136
|
+
data[key] = val
|
|
137
|
+
self.instance.config = data
|
|
138
|
+
return super().save(commit=commit)
|
|
@@ -1,6 +1,27 @@
|
|
|
1
|
+
from django.utils.translation import gettext_lazy as _
|
|
1
2
|
from django.contrib.auth import get_user_model
|
|
2
3
|
from django.db import models
|
|
3
4
|
|
|
5
|
+
FORMATS_DATE = [
|
|
6
|
+
("dd/MM/yyyy hh:mm:ss a", "dd/MM/yyyy hh:mm:ss a"),
|
|
7
|
+
("yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm:ss"),
|
|
8
|
+
("MM/dd/yyyy hh:mm:ss a", "MM/dd/yyyy hh:mm:ss a"),
|
|
9
|
+
("dd-MM-yyyy", "dd-MM-yyyy"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
FONT_ALIGNMENT = [
|
|
13
|
+
("LEFT", _("LEFT")),
|
|
14
|
+
("CENTER", _("CENTER")),
|
|
15
|
+
("RIGHT", _("RIGHT")),
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
FONT_CHOICES = [
|
|
19
|
+
("Nimbus Sans Regular", "Nimbus Sans Regular"),
|
|
20
|
+
("Nimbus Sans Bold", "Nimbus Sans Bold"),
|
|
21
|
+
("Nimbus Sans Italic", "Nimbus Sans Italic"),
|
|
22
|
+
("Nimbus Sans Bold Italic", "Nimbus Sans Bold Italic"),
|
|
23
|
+
]
|
|
24
|
+
|
|
4
25
|
def get_signature_default():
|
|
5
26
|
return {
|
|
6
27
|
"backgroundColor": "transparente",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from django.contrib import messages
|
|
2
|
+
from django.contrib.auth.decorators import login_required
|
|
3
|
+
from django.shortcuts import render, get_object_or_404, redirect
|
|
4
|
+
from django.utils.translation import gettext_lazy as _
|
|
5
|
+
|
|
6
|
+
from djgentelella.firmador_digital.forms import SignatureConfigForm
|
|
7
|
+
from djgentelella.firmador_digital.models import UserSignatureConfig
|
|
8
|
+
|
|
9
|
+
@login_required
|
|
10
|
+
def update_signature_settings(request):
|
|
11
|
+
|
|
12
|
+
config, is_created = UserSignatureConfig.objects.get_or_create(user=request.user)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
if request.method == "POST":
|
|
16
|
+
form = SignatureConfigForm(request.POST, instance=config, render_type="as_grid")
|
|
17
|
+
if form.is_valid():
|
|
18
|
+
form.save()
|
|
19
|
+
messages.success(request, _("Updated signature settings successfully."))
|
|
20
|
+
return redirect("signature_config")
|
|
21
|
+
else:
|
|
22
|
+
form = SignatureConfigForm(instance=config, render_type="as_grid")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
return render(
|
|
26
|
+
request,
|
|
27
|
+
"gentelella/digital_signature/update_signature_settings.html",
|
|
28
|
+
context={
|
|
29
|
+
"form": form
|
|
30
|
+
}
|
|
31
|
+
)
|
|
Binary file
|
|
@@ -616,3 +616,51 @@ msgstr "Iniciar"
|
|
|
616
616
|
|
|
617
617
|
msgid "Unknown"
|
|
618
618
|
msgstr "Desconocido"
|
|
619
|
+
|
|
620
|
+
msgid "LEFT"
|
|
621
|
+
msgstr "IZQUIERDA"
|
|
622
|
+
|
|
623
|
+
msgid "CENTER"
|
|
624
|
+
msgstr "CENTRO"
|
|
625
|
+
|
|
626
|
+
msgid "RIGHT"
|
|
627
|
+
msgstr "DERECHA"
|
|
628
|
+
|
|
629
|
+
msgid "Signature settings"
|
|
630
|
+
msgstr "Configuración de firma"
|
|
631
|
+
|
|
632
|
+
msgid "Updated signature settings successfully."
|
|
633
|
+
msgstr "Configuración de firma actualizada correctamente."
|
|
634
|
+
|
|
635
|
+
msgid "Background color"
|
|
636
|
+
msgstr "Color de fondo"
|
|
637
|
+
|
|
638
|
+
msgid "Contact"
|
|
639
|
+
msgstr "Contacto"
|
|
640
|
+
|
|
641
|
+
msgid "Date format"
|
|
642
|
+
msgstr "Formato de fecha"
|
|
643
|
+
|
|
644
|
+
msgid "Signature message"
|
|
645
|
+
msgstr "Mensaje de firma"
|
|
646
|
+
|
|
647
|
+
msgid "Font"
|
|
648
|
+
msgstr "Fuente"
|
|
649
|
+
|
|
650
|
+
msgid "Font alignment"
|
|
651
|
+
msgstr "Alineación de fuente"
|
|
652
|
+
|
|
653
|
+
msgid "Font color"
|
|
654
|
+
msgstr "Color de fuente"
|
|
655
|
+
|
|
656
|
+
msgid "Font size"
|
|
657
|
+
msgstr "Tamaño de fuente"
|
|
658
|
+
|
|
659
|
+
msgid "Place"
|
|
660
|
+
msgstr "Lugar"
|
|
661
|
+
|
|
662
|
+
msgid "Reason"
|
|
663
|
+
msgstr "Razón"
|
|
664
|
+
|
|
665
|
+
msgid "Visible signature"
|
|
666
|
+
msgstr "Firma visible"
|
|
@@ -274,3 +274,18 @@ function createDataTable(id, url, extraoptions={}, addfilter=false, formatDataTa
|
|
|
274
274
|
}, extraoptions);
|
|
275
275
|
return gtCreateDataTable(id, url, options);
|
|
276
276
|
}
|
|
277
|
+
|
|
278
|
+
function truncateTextRenderer(maxChars = 100) {
|
|
279
|
+
return (data, type, row, meta)=> {
|
|
280
|
+
if (type === 'display' && typeof data === 'string') {
|
|
281
|
+
const text = data.trim();
|
|
282
|
+
if (text.length > maxChars) {
|
|
283
|
+
return `<span title="${text.replace(/"/g, '"')}" style="display:inline; line-height:1; margin:0; padding:0;">${text.substring(0, maxChars)}...</span>`;
|
|
284
|
+
}
|
|
285
|
+
return text
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return data;
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|