Skip to content

Commit

Permalink
Allow course attendees without surname (#1471)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpirix authored Nov 18, 2024
1 parent 80cd0a9 commit 4f24450
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.13 on 2024-11-12 10:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('certification', '0024_auto_20220605_0612'),
]

operations = [
migrations.AlterField(
model_name='attendee',
name='surname',
field=models.CharField(blank=True, help_text='Surname of the attendee.', max_length=200, null=True),
),
]
7 changes: 4 additions & 3 deletions django_project/certification/models/attendee.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class Attendee(models.Model):
surname = models.CharField(
help_text=_('Surname of the attendee.'),
max_length=200,
null=False,
blank=False
null=True,
blank=True
)

email = models.CharField(
Expand Down Expand Up @@ -96,7 +96,8 @@ def __unicode__(self):
return '%s %s' % (self.firstname, self.surname)

def __str__(self):
return '%s %s' % (self.firstname, self.surname)
surname = self.surname if self.surname else ''
return '%s %s' % (self.firstname, surname)

def get_absolute_url(self):
"""Return URL to attendee detail page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h3>Certificate: {{ certificate.certificateID }}</h3>
<div class="row">
<div class="col-lg-8" style="font-size: 12pt">
<span class="col-lg-3">Course</span><span class="col-lg-9">: {{ certificate.course.course_type.name }} ({{ certificate.course.start_date }} to {{ certificate.course.end_date }})<br/></span>
<span class="col-lg-3">Attendee</span><span class="col-lg-9">: {{ certificate.attendee.firstname }} {{ certificate.attendee.surname }}<br/></span>
<span class="col-lg-3">Attendee</span><span class="col-lg-9">: {{ certificate.attendee.firstname }} {{ certificate.attendee.surname|default_if_none:"" }}<br/></span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ <h4>Course: {{ course.certifying_organisation.project }} - {{ course.course_type
<th>Attendee</th>
</tr>
{% for key, value in certificates.items %}
<tr><td>{{ value.certificateID }}</td><td>{{ key.firstname }} {{ key.surname }}</td></tr>
<tr>
<td>{{ value.certificateID}}</td>
<td>{{ key.firstname}} {{ key.surname|default_if_none:"" }}</td>
</tr>
{% endfor %}
</table>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h4 style="font-size: 16pt">Are you sure you want to regenerate pdf of this cert
<span>Course</span></div>
<div class="col-lg-10">
<span>{{ id }}</span><br/>
<span>{{ attendee.firstname }} {{ attendee.surname }}</span><br/>
<span>{{ attendee.firstname }} {{ attendee.surname |default_if_none:"" }}</span><br/>
<span>{{ course.certifying_organisation.project }} - {{ course.course_type.name }} ({{ course.start_date }} to {{ course.end_date }})</span></div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1>Course Attendee Deleted</h1>
<a class="btn btn-danger btn-sm tooltip-toggle"
href="#"
onClick="$('#delete-confirmation').submit()"
data-title="Delete {{ courseattendee.attendee.firstname }} {{ courseattendee.attendee.surname }}">
data-title="Delete {{ courseattendee.attendee.firstname }} {{ courseattendee.attendee.surname |default_if_none:"" }}">
<span class="glyphicon glyphicon-minus"></span>
</a>
<a class="btn btn-default btn-sm tooltip-toggle"
Expand Down
4 changes: 2 additions & 2 deletions django_project/certification/views/certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def generate_pdf(
page.drawCentredString(
center, 400, '%s %s' % (
attendee.firstname,
attendee.surname))
attendee.surname if attendee.surname else ''))
page.setFont('Noto-Regular', 16)
page.drawCentredString(
center, 370, wording)
Expand Down Expand Up @@ -605,7 +605,7 @@ def email_all_attendees(request, **kwargs):
# Send email to each attendee with the link to his certificate.
data = {
'firstname': attendee.firstname,
'lastname': attendee.surname,
'lastname': attendee.surname if attendee.surname else '',
'coursetype': course.course_type,
'start_date': course.start_date.strftime('%d %B %Y'),
'end_date': course.end_date.strftime('%d %B %Y'),
Expand Down

0 comments on commit 4f24450

Please sign in to comment.