From 92e9517b7e7b960d3eef895b56cdf02277f191fe Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 14 Mar 2024 19:18:19 +0100 Subject: [PATCH] add langs pdf and split from file-scheme --- ...Model_Certificat_html_941e7b967953b3f3.jpg | Bin 0 -> 6245 bytes .../certificates/course-credential_ca.html | 126 ++++++++++++++++++ .../certificates/course-credential_es.html | 126 ++++++++++++++++++ .../federation-membership_ca.html | 122 +++++++++++++++++ .../federation-membership_es.html | 122 +++++++++++++++++ idhub/templates/idhub/user/credential.html | 23 ++-- idhub/urls.py | 2 +- idhub/user/views.py | 66 +++++---- 8 files changed, 551 insertions(+), 36 deletions(-) create mode 100644 idhub/static/images/4_Model_Certificat_html_941e7b967953b3f3.jpg create mode 100644 idhub/templates/certificates/course-credential_ca.html create mode 100644 idhub/templates/certificates/course-credential_es.html create mode 100644 idhub/templates/certificates/federation-membership_ca.html create mode 100644 idhub/templates/certificates/federation-membership_es.html diff --git a/idhub/static/images/4_Model_Certificat_html_941e7b967953b3f3.jpg b/idhub/static/images/4_Model_Certificat_html_941e7b967953b3f3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..12e9a3ea3555b618f8c349d9be41e24ccc6fff22 GIT binary patch literal 6245 zcmb7J2{hYVw@<{}R#CK7Du|jILx>?Y&xuP2+M4Q;1VIv!n1`y;Q4KNlwl!2MrlPHR zDB3EDqD83~u9~T-YG|u?(L22FTkpPay?3&*R`&kyy?=ZBpLI_5KJ1MH_)%s^GXM|> z1pLbS0QNotL`*{no&bQA6+i(10C2OuthM(Mbl;ms^G7Hvlc-AWII;&`2}>p_hq(JI zt177|19bF5{N1s>cpBIP??oW#O0Cp4Nr4GCU8!?$D-|n$W4t%PA}j!J7iMjb4fDln zjz=c|=ZV0W znEi>yqI9MHj4L=eSSeUdi5%ditg5Z8t*io5hQXjL2`Dv`L~{>;lBm)@ZTw-x1W&~V z5d3KbG6}qI)ZK#|NYj;Kx%)>PM1L!*zit0x&WObQ;C@O|X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G-1HuzhGB4;OS6q(s zB6qpoNZ5o5Kek>-L)KB~#6YtyOGN*CYw<)s{#~5Yedv|*_FB_<_9DFpu!jo7Vv?r} zzdSZA*6(w4|SoeBU5}v7FR>${CXeGt{aqbw-rsW89i4UG^!~t zAZnNiIUW3(XuxTg6%c`VI-cDm=7}cOn$*Aap~=#}9F{HQMenW}j$a-(Q#^F0$l=ud zOJwEy;|oIr3~RWT$U~+0PKLZQ=aYZ91^Ku09gE;NSGxIP3)d7>#g8uhl)rX}^s66LpK7V)wOsujIZt87LPF(bW6WzN>M#|94bu32WY^0BB<*-EyR{Pi zXWDJman##PzHdLa3B=o9-Y(Equ8SisUae2~O53?O@8-1iz>a`Y3ThqOpv0|buVw53 zRGo9ly2-{fS1E?;a)!I8;saOOD;S=?2UDJYPpmll!|>SlEg!L=`Zb5IwLu$+4)VY5 z0gxr=JH_u7E9>8m($+Kk^2%q?uW-f4KczB#oCUq7Sw9^U8{yz=54Ayb<69>yjKvlUb1L!NK;-uT}3AuN8J zdM^ETpRIc3Qxy;4#|ny+mXj`y&t-?7A3Tg2Dr>gAYxzsXm3sy+F_)sb@;D+DTJPoB zl{?pUzKVO~oA!8Y@YPY%-5vtUAwcf`P`Ll)mWx$VuDzk{;{bpO>t^qd#rkW&9UuY$ S9)$prp8I!h!1UDr!T2wU()I)Z literal 0 HcmV?d00001 diff --git a/idhub/templates/certificates/course-credential_ca.html b/idhub/templates/certificates/course-credential_ca.html new file mode 100644 index 0000000..1d1913f --- /dev/null +++ b/idhub/templates/certificates/course-credential_ca.html @@ -0,0 +1,126 @@ +{% load i18n static %} + + + +Certificat + + + + + + + + + +
+
+
+ +
+
+
+
+ + LAFEDE.CAT – ORGANITZACIONS PER A LA JUSTÍCIA GLOBAL
CERTIFICA QUE:

+ {{ firstName }} {{ lastName }} amb DNI {{ document_id|default:"falta el dni" }}
+ Ha realitzat el curs {{ courseName }}, a {{ address|default:"falta address" }} / de manera {{ modeOfInstruction }}, els dies {{ date_course|default:"falta fecha del curso" }}
+ La durada del curs ha estat de {{ courseDuration }} hores lectives corresponents a {{ courseDays }} sessions.
+
+
+
+
+
+ I per deixar-ne constància als efectes oportuns, signo el present certificat en data de {{ issuedDate }} +
+
+ +
+
+ +
+
+ +
+
+ Pepa Martínez Peyrats
+ Directora
+ Lafede.cat - Federació d'Organitzacions per a la Justícia Global +
+
+ {% if qr %} +
+
+ +
+
+ {% endif %} +
+
+ Organitza: + Amb el suport de: + Amb la col·laboració de: +
+
+
+ +
+
+
+
+ + diff --git a/idhub/templates/certificates/course-credential_es.html b/idhub/templates/certificates/course-credential_es.html new file mode 100644 index 0000000..32056c6 --- /dev/null +++ b/idhub/templates/certificates/course-credential_es.html @@ -0,0 +1,126 @@ +{% load i18n static %} + + + +Certificado + + + + + + + + + +
+
+
+ +
+
+
+
+ + LAFEDE.CAT – ORGANIZACIONES PARA LA JUSTÍCIA GLOBAL
CERTIFICA QUE:

+ {{ firstName }} {{ lastName }} con DNI {{ document_id|default:"falta el dni" }}
+ Ha realizado el curso {{ courseName }}, en {{ address|default:"falta address" }} / de manera {{ modeOfInstruction }}, los días {{ date_course|default:"falta fecha del curso" }}
+ La duración del curso ha sido de {{ courseDuration }} horas lectivas correspondientes a {{ courseDays }} sessiones.
+
+
+
+
+
+ Y para dejar constancia a los efectos oportunos, firmo el presente certificado en fecha de {{ issuedDate }} +
+
+ +
+
+ +
+
+ +
+
+ Pepa Martínez Peyrats
+ Directora
+ Lafede.cat - Federación de Organizaciones por la Justícia Global +
+
+ {% if qr %} +
+
+ +
+
+ {% endif %} +
+
+ Organiza: + Con el soporte de: + Con la colaboración de: +
+
+
+ +
+
+
+
+ + diff --git a/idhub/templates/certificates/federation-membership_ca.html b/idhub/templates/certificates/federation-membership_ca.html new file mode 100644 index 0000000..3b83531 --- /dev/null +++ b/idhub/templates/certificates/federation-membership_ca.html @@ -0,0 +1,122 @@ +{% load i18n static %} + + + +Certificat + + + + + + + + + +
+
+
+ +
+
+
+
+

A qui correspongui,

+

+ Pepa Martínez Peyrats, com a directora de Lafede.cat - Federació d'Organitzacions per a la Justícia Global, +

+
+
+ +
+
+ CERTIFICA
+
    +
  • + Que l’entitat {{ legalName }}, amb NIF {{ registrationIdentifier }} i domicili a {{ streetAddress }} {{ postCode }} {{ city }} forma part com a entitat membre de {{ federation }} (ple dret/observadora) de Lafede.cat - Federació d'Organitzacions per a la Justícia Global, des de l’Assemblea General Ordinària celebrada el {{ membershipSince }} +
  • +
+
+
+
+ I per deixar-ne constància als efectes oportuns, signo el present certificat en data de {{ issue_date_now }} +
+
+ +
+
+ +
+
+ +
+
+ Pepa Martínez Peyrats
+ Directora
+ Lafede.cat - Federació d'Organitzacions per a la Justícia Global +
+
+ {% if qr %} +
+
+ +
+
+ {% endif %} +
+ + diff --git a/idhub/templates/certificates/federation-membership_es.html b/idhub/templates/certificates/federation-membership_es.html new file mode 100644 index 0000000..ef4a06f --- /dev/null +++ b/idhub/templates/certificates/federation-membership_es.html @@ -0,0 +1,122 @@ +{% load i18n static %} + + + +Certificado + + + + + + + + + +
+
+
+ +
+
+
+
+

A quién corresponda,

+

+ Pepa Martínez Peyrats, como directora de Lafede.cat - Federación de Organizaciones para la Justícia Global, +

+
+
+ +
+
+ CERTIFICA
+
    +
  • + Que la entidad {{ legalName }}, con NIF {{ registrationIdentifier }} y domicilio {{ streetAddress }} {{ postCode }} {{ city }} forma parte como entidad miembro de {{ federation }} (por el derecho/observadora) de Lafede.cat - Federación de Organizaciones para la Justícia Global, desde la Asamblea General Ordinaria celebrada el {{ membershipSince }} +
  • +
+
+
+
+ Y para dejar constancia a los efectos oportunos, firmo el presente certificado en fecha de {{ issue_date_now }} +
+
+ +
+
+ +
+
+ +
+
+ Pepa Martínez Peyrats
+ Directora
+ Lafede.cat - Federació d'Organitzacions per a la Justícia Global +
+
+ {% if qr %} +
+
+ +
+
+ {% endif %} +
+ + diff --git a/idhub/templates/idhub/user/credential.html b/idhub/templates/idhub/user/credential.html index 9e1e0f4..6362a5e 100644 --- a/idhub/templates/idhub/user/credential.html +++ b/idhub/templates/idhub/user/credential.html @@ -9,19 +9,24 @@ {{ subtitle }} -
- {% if object.get_status == 'Issued' %} -
- {% if object.eidas1_did and admin_validated %} - {% trans 'Download as PDF' %} - {% endif %} - {% trans 'Download as JSON' %} + {% if object.get_status == 'Issued' %} + {% if object.eidas1_did and admin_validated %} + + {% endif %} + {% endif %} +
+ {% if object.get_status == 'Issued' %} + {% if object.eidas1_did and admin_validated %} + {% endif %} + {% trans 'Download as JSON' %} + {% endif %} {% if object.get_status == 'Enabled' %} - {% endif %}
diff --git a/idhub/urls.py b/idhub/urls.py index d0230c9..9ecc8d0 100644 --- a/idhub/urls.py +++ b/idhub/urls.py @@ -73,7 +73,7 @@ urlpatterns = [ name='user_credentials'), path('user/credentials/', views_user.CredentialView.as_view(), name='user_credential'), - path('user/credentials//pdf', views_user.CredentialPdfView.as_view(), + path('user/credentials//pdf/', views_user.CredentialPdfView.as_view(), name='user_credential_pdf'), path('credentials//', views_user.CredentialJsonView.as_view(), name='user_credential_json'), diff --git a/idhub/user/views.py b/idhub/user/views.py index 6db3500..50e0dd3 100644 --- a/idhub/user/views.py +++ b/idhub/user/views.py @@ -209,14 +209,19 @@ class CredentialView(MyWallet, TemplateView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) + url_ca = reverse_lazy('idhub:user_credential_pdf', args=[self.object.id, 'ca']) + url_es = reverse_lazy('idhub:user_credential_pdf', args=[self.object.id, 'es']) context.update({ 'object': self.object, + 'url_ca': url_ca, + 'url_es': url_es, }) return context class CredentialPdfView(MyWallet, TemplateView): - template_name = "certificates/4_Model_Certificat.html" + template_name = "certificates/{}_{}.html" + template_name = "certificates/{}_{}.html" subtitle = _('Credential management') icon = 'bi bi-patch-check-fill' file_name = "certificate.pdf" @@ -225,6 +230,7 @@ class CredentialPdfView(MyWallet, TemplateView): if not cache.get("KEY_DIDS"): return redirect(reverse_lazy('idhub:user_dashboard')) pk = kwargs['pk'] + lang = kwargs.get('lang', 'ca') self.user = self.request.user self.object = get_object_or_404( VerificableCredential, @@ -232,6 +238,11 @@ class CredentialPdfView(MyWallet, TemplateView): eidas1_did__isnull=False, user=self.request.user ) + self.credential_type = self.object.schema.file_schema.split(".json")[0] + self.template_name = self.template_name.format( + self.credential_type, + lang + ) self.url_id = "{}://{}/public/credentials/{}".format( self.request.scheme, self.request.get_host(), @@ -247,49 +258,52 @@ class CredentialPdfView(MyWallet, TemplateView): response['Content-Disposition'] = 'attachment; filename={}'.format(self.file_name) return response - def get_context_data(self, **kwargs): - context = super().get_context_data(**kwargs) - # this_folder = str(Path.cwd()) + def get_img_sign(self): path_img_sig = "idhub/static/images/4_Model_Certificat_html_58d7f7eeb828cf29.jpg" img_signature = next(Path.cwd().glob(path_img_sig)) with open(img_signature, 'rb') as _f: img_sig = base64.b64encode(_f.read()).decode('utf-8') + return img_sig - path_img_head = "idhub/static/images/4_Model_Certificat_html_7a0214c6fc8f2309.jpg" + def get_img_header(self): + path_img_head = "idhub/static/images/4_Model_Certificat_html_7a0214c6fc8f2309.jpg" img_header= next(Path.cwd().glob(path_img_head)) with open(img_header, 'rb') as _f: img_head = base64.b64encode(_f.read()).decode('utf-8') + return img_head + def get_img_footer(self): + path_img_foot = "idhub/static/images/4_Model_Certificat_html_941e7b967953b3f3.jpg" + img_foot= next(Path.cwd().glob(path_img_foot)) + with open(img_foot, 'rb') as _f: + img_foot = base64.b64encode(_f.read()).decode('utf-8') + return img_foot + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + img_sig = self.get_img_sign() + img_head = self.get_img_header() + img_foot = self.get_img_footer() qr = self.generate_qr_code(self.url_id) + issue_date_now = datetime.datetime.now() - first_name = self.user.first_name and self.user.first_name.upper() or "" - last_name = self.user.first_name and self.user.last_name.upper() or "" - document_id = "0000000-L" - course = "COURSE 1" - address = "ADDRESS" - date_course = datetime.datetime.now() - n_hours = 40 - n_lections = 5 - issue_date = datetime.datetime.now() + context.update(dict(self.object.get_datas())) context.update({ 'object': self.object, "image_signature": img_sig, "image_header": img_head, - "first_name": first_name, - "last_name": last_name, - "document_id": document_id, - "course": course, - "address": address, - "date_course": date_course, - "n_hours": n_hours, - "n_lections": n_lections, - "issue_date": issue_date, - "qr": qr + "image_footer": img_foot, + "issue_date_now": issue_date_now.strftime("%d/%m/%Y"), + "qr": qr, }) return context def build_certificate(self): - doc = self.render_to_response(context=self.get_context_data()) + try: + doc = self.render_to_response(context=self.get_context_data()) + except Exception: + self.template_name = "certificates/4_Model_Certificat_ca.html" + doc = self.render_to_response(context=self.get_context_data()) doc.render() pdf = weasyprint.HTML(string=doc.content) return pdf.write_pdf() @@ -340,7 +354,7 @@ class CredentialPdfView(MyWallet, TemplateView): w = IncrementalPdfFileWriter(_buffer) fields.append_signature_field( w, sig_field_spec=fields.SigFieldSpec( - 'Signature', box=(150, 100, 450, 150) + 'Signature', box=(150, 75, 450, 100) ) )