Skip to content

Commit ac0ea48

Browse files
authored
Merge pull request #54 from Xpirix/download_certifying_orgs_certificate
Allow issuing orgs certificate
2 parents 00dd406 + dc68709 commit ac0ea48

File tree

4 files changed

+111
-93
lines changed

4 files changed

+111
-93
lines changed

django_project/certification/forms.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
CertifyingOrganisationCertificate, Checklist, OrganisationChecklist
3333
)
3434

35+
from crispy_forms.layout import Submit
36+
from datetime import datetime
37+
3538
from crispy_bulma.widgets import FileUploadInput
3639

3740
FileUploadInput.template_name = 'widgets/file_upload_input.html'
@@ -714,17 +717,28 @@ def __init__(self, *args, **kwargs):
714717
self.fields['certifying_organisation'].initial = \
715718
self.certifying_organisation
716719
self.fields['certifying_organisation'].widget = forms.HiddenInput()
717-
# self.helper.layout.append(
718-
# HTML(
719-
# '<button type="submit" class="button is-success mt-5" name="submit">'
720-
# ' <span class="icon"><i class="fas fa-check"></i></span>'
721-
# ' <span>Issue Certificate</span>'
722-
# '</button>'
723-
# )
724-
# )
720+
self.helper.add_input(
721+
Submit(
722+
'submit',
723+
'Issue Certificate',
724+
css_class='button is-success pt-2 mt-5'
725+
)
726+
)
725727

726728
def save(self, commit=True):
727729
instance = super(OrganisationCertificateForm, self).save(commit=False)
730+
existing = CertifyingOrganisationCertificate.objects.filter(
731+
certifying_organisation=self.certifying_organisation
732+
).first()
733+
734+
if existing:
735+
existing.issued = datetime.now()
736+
existing.author = self.user
737+
if commit:
738+
existing.save()
739+
return existing
740+
728741
instance.author = self.user
729-
instance.save()
742+
if commit:
743+
instance.save()
730744
return instance

django_project/certification/templates/certificate_organisation/create.html

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,35 @@
33
{% load crispy_forms_tags %}
44

55
{% block page_title %}
6-
<h1>Add Certificate</h1>
6+
<h1 class="title is-3">Add Certificate</h1>
77
{% endblock page_title %}
88

99
{% block content %}
1010

11-
<div class="col-lg-10">
11+
12+
<div>
13+
<a class="button is-light"
14+
href='{% url 'certifyingorganisation-detail' slug=certifying_organisation.slug %}'
15+
title="Cancel">
16+
<span class="icon">
17+
<i class="fas fa-arrow-left"></i>
18+
</span>
19+
<span>Cancel</span>
20+
</a>
21+
</div>
22+
<div class="box-content mt-3">
1223
<div class="container">
13-
<h3>Are you sure you want to issue a certificate for this organisation?</h3>
14-
<div style="border: 2px solid #f5f5f5; padding: 15px; width: 60%; font-size: 12pt">
15-
<span class="col-lg-2" style="color: grey">Organisation: </span><span class="col-lg-10"> {{ certifying_organisation.name }}</span></br>
16-
</div>
24+
<h3 class="subtitle is-5">Are you sure you want to issue a certificate for {{ certifying_organisation.name }}?</h3>
1725
</div>
1826

19-
2027
<section id="forms">
21-
<div class='box-content' style="margin-top: 30px">
28+
<div>
2229
{% csrf_token %}
2330
{% crispy form %}
2431
{% for form in inlines %}
2532
{% crispy form %}
2633
{% endfor %}
2734
</div>
2835
</section>
29-
</div>
30-
31-
<div class="col-lg-2" style="margin-top: 20px">
32-
<a class="btn btn-default btn-sm tooltip-toggle pull-right"
33-
href='{% url 'certifyingorganisation-list' %}'
34-
data-title="Cancel">
35-
<span class="glyphicon glyphicon-arrow-left"></span>
36-
</a>
37-
</div>
36+
</div>
3837
{% endblock %}

django_project/certification/templates/certifying_organisation/detail.html

Lines changed: 66 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -273,71 +273,73 @@ <h1>Certifying Organisation (all)</h1>
273273
</div>
274274
</div>
275275
<!-- End modal -->
276-
<div class="columns is-vcentered">
277-
<div class="column">
278-
<h1 class="title">{{ certifyingorganisation.name }}</h1>
279-
</div>
280-
281-
{# Only organisation owners or staff can edit #}
282-
<div class="column buttons has-text-right">
283-
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon about-link"
284-
data-tooltip="About Certification"
285-
href="https://qgis.org/community/certification/" target="_blank">
286-
<i class="fas fa-info-circle"></i>
287-
</a>
288-
{% if certifyingorganisation.approved %}
289-
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon"
290-
href='{% url "feed-training-center" organisation_slug=certifyingorganisation.slug %}' target="_blank"
291-
data-tooltip="GeoJSON Feed for List of Training Center">
292-
<i class="fas fa-rss-square"></i>
293-
</a>
294-
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon"
295-
href='{% url "feed-upcoming-course" organisation_slug=certifyingorganisation.slug %}' target="_blank"
296-
data-tooltip="Feed for List of Upcoming Courses">
297-
<i class="fas fa-rss"></i>
298-
</a>
299-
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon"
300-
href='{% url "feed-past-course" organisation_slug=certifyingorganisation.slug %}' target="_blank"
301-
data-tooltip="Feed for List of Past Courses">
302-
<i class="fas fa-rss"></i>
303-
</a>
304-
{% endif %}
305-
{% if user_can_delete %}
306-
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon"
307-
href='{% url "certifyingorganisation-update" slug=certifyingorganisation.slug %}'
308-
data-tooltip="Edit {{ certifyingorganisation.name }}">
309-
<i class="fas fa-pencil-alt"></i>
310-
</a>
311-
{% if certifyingorganisation.is_archived %}
312-
<a class="button is-outlined is-success has-tooltip-arrow has-tooltip-bottom icon"
313-
href='{% url "certifyingorganisation-toogle-archive" slug=certifyingorganisation.slug toogle_archive="unarchive" %}'
314-
data-tooltip="Activate {{ certifyingorganisation.name }}">
315-
<i class="fas fa-check-circle"></i>
316-
</a>
276+
<h1 class="title">{{ certifyingorganisation.name }}</h1>
277+
{# Only organisation owners or staff can edit #}
278+
<div class="buttons">
279+
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon"
280+
href='{% if certifyingorganisation.approved %}
281+
{% url "certifyingorganisation-list" %}
317282
{% else %}
318-
<a class="button is-danger is-light has-tooltip-arrow has-tooltip-bottom icon"
319-
href='{% url "certifyingorganisation-toogle-archive" slug=certifyingorganisation.slug toogle_archive="archive" %}'
320-
data-tooltip="Deactivate {{ certifyingorganisation.name }}">
321-
<i class="fas fa-archive"></i>
322-
</a>
323-
{% endif %}
324-
<a class="button is-danger is-light has-tooltip-arrow has-tooltip-bottom icon"
325-
href='{% url "certifyingorganisation-delete" slug=certifyingorganisation.slug %}'
326-
data-tooltip="Delete {{ certifyingorganisation.name }}">
327-
<i class="fas fa-trash"></i>
328-
</a>
329-
{% endif %}
330-
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon"
331-
href='{% if certifyingorganisation.approved %}
332-
{% url "certifyingorganisation-list" %}
333-
{% else %}
334-
{% url "pending-certifyingorganisation-list" %}?ready={% if certifyingorganisation.status.name == 'Pending' %}false{% else %}true{% endif %}
335-
{% endif %}'
336-
data-tooltip="Back">
337-
<i class="fas fa-arrow-left"></i>
338-
</a>
339-
</div>
340-
</div>
283+
{% url "pending-certifyingorganisation-list" %}?ready={% if certifyingorganisation.status.name == 'Pending' %}false{% else %}true{% endif %}
284+
{% endif %}'
285+
data-tooltip="Back">
286+
<i class="fas fa-arrow-left"></i>
287+
</a>
288+
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon about-link"
289+
data-tooltip="About Certification"
290+
href="https://qgis.org/community/certification/" target="_blank">
291+
<i class="fas fa-info-circle"></i>
292+
</a>
293+
{% if certifyingorganisation.approved %}
294+
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon"
295+
href='{% url "feed-training-center" organisation_slug=certifyingorganisation.slug %}' target="_blank"
296+
data-tooltip="GeoJSON Feed for List of Training Center">
297+
<i class="fas fa-rss-square"></i>
298+
</a>
299+
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon"
300+
href='{% url "feed-upcoming-course" organisation_slug=certifyingorganisation.slug %}' target="_blank"
301+
data-tooltip="Feed for List of Upcoming Courses">
302+
<i class="fas fa-rss"></i>
303+
</a>
304+
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon"
305+
href='{% url "feed-past-course" organisation_slug=certifyingorganisation.slug %}' target="_blank"
306+
data-tooltip="Feed for List of Past Courses">
307+
<i class="fas fa-rss"></i>
308+
</a>
309+
{% if user_can_delete %}
310+
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon"
311+
href='{% url "issue-certificate-organisation" organisation_slug=certifyingorganisation.slug %}'
312+
data-tooltip="Issue Certificate for {{ certifyingorganisation.name }}">
313+
<i class="fas fa-certificate"></i>
314+
</a>
315+
{% endif %}
316+
{% endif %}
317+
{% if user_can_delete %}
318+
<a class="button is-light has-tooltip-arrow has-tooltip-bottom icon"
319+
href='{% url "certifyingorganisation-update" slug=certifyingorganisation.slug %}'
320+
data-tooltip="Edit {{ certifyingorganisation.name }}">
321+
<i class="fas fa-pencil-alt"></i>
322+
</a>
323+
{% if certifyingorganisation.is_archived %}
324+
<a class="button is-outlined is-success has-tooltip-arrow has-tooltip-bottom icon"
325+
href='{% url "certifyingorganisation-toogle-archive" slug=certifyingorganisation.slug toogle_archive="unarchive" %}'
326+
data-tooltip="Activate {{ certifyingorganisation.name }}">
327+
<i class="fas fa-check-circle"></i>
328+
</a>
329+
{% else %}
330+
<a class="button is-danger is-light has-tooltip-arrow has-tooltip-bottom icon"
331+
href='{% url "certifyingorganisation-toogle-archive" slug=certifyingorganisation.slug toogle_archive="archive" %}'
332+
data-tooltip="Deactivate {{ certifyingorganisation.name }}">
333+
<i class="fas fa-archive"></i>
334+
</a>
335+
{% endif %}
336+
<a class="button is-danger is-light has-tooltip-arrow has-tooltip-bottom icon"
337+
href='{% url "certifyingorganisation-delete" slug=certifyingorganisation.slug %}'
338+
data-tooltip="Delete {{ certifyingorganisation.name }}">
339+
<i class="fas fa-trash"></i>
340+
</a>
341+
{% endif %}
342+
</div>
341343

342344
<div class="columns">
343345
<div class="column is-half">

django_project/certification/views/certificate_organisation.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ def generate_certificate_pdf(
131131
page.drawString(
132132
margin_left, (margin_bottom - 20),
133133
'You can verify this certificate by visiting '
134-
'https://{}/en/{}/organisationcertificate/{}/.'
135-
.format(current_site, project.slug, certificate.certificateID))
134+
'https://{}/en/organisationcertificate/{}/.'
135+
.format(current_site, certificate.certificateID))
136136

137137
# Close the PDF object cleanly.
138138
page.showPage()
@@ -157,7 +157,10 @@ def get_success_url(self):
157157
:rtype: HttpResponse
158158
"""
159159

160-
return reverse('certifyingorganisation-list', kwargs={})
160+
return reverse(
161+
'print-certificate-organisation',
162+
kwargs={'organisation_slug': self.certifying_organisation.slug}
163+
)
161164

162165
def get_context_data(self, **kwargs):
163166
"""Get the context data which is passed to a template.

0 commit comments

Comments
 (0)