Commit f39cbbb9 authored by gijs's avatar gijs

Activated with / by labels

parent a69549bf
......@@ -96,6 +96,9 @@ msgstr "Documentatie"
msgid "with"
msgstr "met"
msgid "by"
msgstr "door"
#: contour/templates/contour/home.beta.html:51
#: contour/templates/contour/home.html:52
#: contour/templates/contour/page.html:81
......
......@@ -90,7 +90,7 @@ class Participant(models.Model):
if attrname in ['name', 'sort_name', 'bio']:
return getattr(self, attrname + '_' + get_language())
return super().__getattr__(attrname)
return getattr(super(), attrname)
class Project(models.Model):
slug = models.SlugField(unique=True, max_length=255)
......@@ -128,7 +128,7 @@ class ProjectCredit(models.Model):
if attrname in ['title', 'value']:
return getattr(self, attrname + '_' + get_language())
return super().__getattr__(attrname)
return getattr(super(), attrname)
class EventType(models.Model):
class Meta:
......@@ -224,12 +224,12 @@ class ProjectParticipant(models.Model):
return self.participant.__str__()
LABEL_CHOICES = (
('with', 'with'),
('by', 'by'))
('by', 'by'),
('with', 'with'))
participant = models.ForeignKey(Participant, on_delete=models.CASCADE)
project = SortableForeignKey(Project, on_delete=models.CASCADE)
label = models.CharField(max_length=10, choices=LABEL_CHOICES, default=LABEL_CHOICES[0][0])
label = models.CharField(max_length=10, choices=LABEL_CHOICES, default=LABEL_CHOICES[1][0])
role_nl = models.CharField(max_length=255)
role_en = models.CharField(max_length=255, verbose_name="Role (English)")
position = models.PositiveIntegerField(default=0, editable=True, db_index=True)
......@@ -237,7 +237,7 @@ class ProjectParticipant(models.Model):
def __getattr__ (self, attrname):
if attrname in ['role', 'title', 'content']:
return getattr(self, attrname + '_' + get_language())
return super().__getattr__(attrname)
# class ParticipantImage(SortableMixin):
......
......@@ -26,10 +26,12 @@
{% for event in entry.events %}
{% if forloop.first %}
<h4 class="title"><a href="{% url 'contour:event' event.pk %}">{{ event.project.title }}</a></h4>
{% for participant in event.project|sorted_participants %}
{% if forloop.first %}{% trans "with" %}:&nbsp;{% endif %}
{% for label, participants in event.project|grouped_participants %}
{% for participant in participants %}
{% if forloop.first %}{% trans label %}:&nbsp;{% endif %}
<span class="contributor">{% if participant.published %}<a href="{% url 'contour:contributor' participant.pk %}">{{ participant.name }}</a>{% else %}{{ participant.name }}{% endif %}</span>
{% endfor %}
{% endfor %}
{% endif %}
<section class="event-data--event">
<time class="hour" datetime="{{ event.start|date:'c' }}">
......
......@@ -41,8 +41,10 @@
<h4 class="title"><a href="{% url 'contour:event' event.pk %}">{{ event.project.title }}</a></h4>
<span class="type">{{ event.event_type }} </span>
<span class="venue">{% trans "at" %}&nbsp;{% if event.venue.published %}<a href="{% url 'contour:venue' event.venue.pk %}">{{ event.venue }}</a>{% else %}{{ event.venue }}{% endif %}</span>
{% for participant in event.project|sorted_participants %}
{% if forloop.first %}{% trans "with" %}:&nbsp;{% endif %}<span class="contributor">{% if participant.published %}<a href="{% url 'contour:contributor' participant.pk %}">{{ participant.name }}</a>{% else %}{{ participant.name }}{% endif %}</span>
{% for label, participants in event.project|grouped_participants %}
{% for participant in participants %}
{% if forloop.first %}{% trans label %}:&nbsp;{% endif %}<span class="contributor">{% if participant.published %}<a href="{% url 'contour:contributor' participant.pk %}">{{ participant.name }}</a>{% else %}{{ participant.name }}{% endif %}</span>
{% endfor %}
{% endfor %}
</section>
</article>
......@@ -80,8 +82,10 @@
<h4 class="title"><a href="{% url 'contour:event' event.pk %}">{{ event.project.title }}</a></h4>
<span class="type">{{ event.event_type }} </span>
<span class="venue">{% trans "at" %}&nbsp;{% if event.venue.published %}<a href="{% url 'contour:venue' event.venue.pk %}">{{ event.venue }}</a>{% else %}{{ event.venue }}{% endif %}</span>
{% for participant in event.project|sorted_participants %}
{% if forloop.first %}{% trans "with" %}:&nbsp;{% endif %}<span class="contributor">{% if participant.published %}<a href="{% url 'contour:contributor' participant.pk %}">{{ participant.name }}</a>{% else %}{{ participant.name }}{% endif %}</span>
{% for label, participants in event.project|grouped_participants %}
{% for participant in participants %}
{% if forloop.first %}{% trans label %}:&nbsp;{% endif %}<span class="contributor">{% if participant.published %}<a href="{% url 'contour:contributor' participant.pk %}">{{ participant.name }}</a>{% else %}{{ participant.name }}{% endif %}</span>
{% endfor %}
{% endfor %}
</section>
</article>
......@@ -111,8 +115,10 @@
<span class="type">{{ event.event_type }} </span>
<span class="venue">{% trans "at" %}&nbsp;{% if event.venue.published %}<a href="{% url 'contour:venue' event.venue.pk %}">{{ event.venue }}</a>{% else %}{{ event.venue }}{% endif %}</span>
<h4 class="title"><a href="{% url 'contour:event' event.pk %}">{{ event.project.title }}</a></h4>
{% for participant in event.project|sorted_participants %}
{% if forloop.first %}{% trans "with" %}:&nbsp;{% endif %}<span class="contributor">{% if participant.published %}<a href="{% url 'contour:contributor' participant.pk %}">{{ participant.name }}</a>{% else %}{{ participant.name }}{% endif %}</span>
{% for label, participants in event.project|grouped_participants %}
{% for participant in participants %}
{% if forloop.first %}{% trans label %}:&nbsp;{% endif %}<span class="contributor">{% if participant.published %}<a href="{% url 'contour:contributor' participant.pk %}">{{ participant.name }}</a>{% else %}{{ participant.name }}{% endif %}</span>
{% endfor %}
{% endfor %}
</section>
</article>
......
......@@ -10,6 +10,8 @@ from django.utils.safestring import mark_safe
from django.utils.encoding import force_text
from datetime import date
from contour.models import ProjectParticipant
from contour.views import TemplateLoop, Interbellum
register = template.Library()
......@@ -34,6 +36,22 @@ def sorted_events(project):
def sorted_participants(project):
return project.participants.all().order_by('projectparticipant__participant_order')
@register.filter
def grouped_participants(project):
labels, _ = zip(*ProjectParticipant.LABEL_CHOICES)
grouped = [ (label, project.participants.filter(projectparticipant__label=label).order_by('projectparticipant__participant_order')) for label in labels ]
# print(project.participants.all().order_by('projectparticipant__participant_order'))
# for participant in project.participants.all().order_by('projectparticipant__participant_order'):
# print(participant)
# if participant.label in keys:
# grouped[keys.index(participant.label)][1].append(participant)
# print(grouped)
return grouped
@register.filter
def first_participant(project):
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment