Skip to content
Snippets Groups Projects
Commit 4cd7525f authored by Odin Johan Vatne's avatar Odin Johan Vatne
Browse files

Add group members to application component

parent a57e721c
Branches
No related tags found
No related merge requests found
...@@ -13,18 +13,11 @@ ...@@ -13,18 +13,11 @@
{% endif %} {% endif %}
</div> </div>
<div> <div>
<a href="/user/{{application.student.username}}" class="undecorated-link underline-hover"> {{application.student|name_link}}
<b>{{application.student.first_name}} {{application.student.last_name}}</b>
</a>
on {{application.date_created|date:"DATE_FORMAT"}} on {{application.date_created|date:"DATE_FORMAT"}}
{% if application.group_members.all|length > 0 %} {% if application.group_members.all|length > 0 %}
(with <br>
{% for groupmate in application.group_members.all %} with {{application.group_members.all|name_list:True}}
<a href="/user/{{groupmate.username}}" class="undecorated-link underline-hover">
{{groupmate.first_name}} {{groupmate.last_name}},
</a>
{% endfor %}
)
{% endif %} {% endif %}
<br> <br>
<hr> <hr>
......
...@@ -22,25 +22,17 @@ ...@@ -22,25 +22,17 @@
</a> </a>
<br> <br>
{% if application.student.username != user.username %} {% if application.student.username != user.username %}
<a href="/user/{{application.student.username}}" class="undecorated-link underline-hover"> {{application.student|name_link}}
{{application.student.first_name}} {{application.student.last_name}}
</a>
applied applied
{%else%} {%else%}
You applied You applied
{% endif %} {% endif %}
on {{application.date_created|date:"DATE_FORMAT"}} on {{application.date_created|date:"DATE_FORMAT"}}
{% if application.group_members.all|length > 0 %} {% if application.group_members.all|length > 0 %}
(with <br>
{% for groupmate in application.group_members.all %} with {{application.group_members.all|name_list}}
<a href="/user/{{groupmate.username}}" class="undecorated-link underline-hover">
{{groupmate.first_name}} {{groupmate.last_name}},
</a>
{% endfor %}
)
{% endif %} {% endif %}
{% if application.student.username != user.username %} {% if application.student.username != user.username %}
<br>
<button type="button" onclick="leaveGroup({{application.id}})">Leave group</button> <button type="button" onclick="leaveGroup({{application.id}})">Leave group</button>
{% endif %} {% endif %}
<br> <br>
......
from django import template from django import template
from django.utils.safestring import mark_safe
from django.utils.html import escape
register = template.Library() register = template.Library()
...@@ -7,7 +9,6 @@ register = template.Library() ...@@ -7,7 +9,6 @@ register = template.Library()
def is_professor(user): def is_professor(user):
return user.groups.filter(name='professor').exists() return user.groups.filter(name='professor').exists()
@register.filter(name='is_student') @register.filter(name='is_student')
def is_student(user): def is_student(user):
return user.groups.filter(name='student').exists() return user.groups.filter(name='student').exists()
...@@ -30,6 +31,20 @@ def is_closed(application): ...@@ -30,6 +31,20 @@ def is_closed(application):
closed = closed or application.professor_status == 'DECL' closed = closed or application.professor_status == 'DECL'
return closed return closed
@register.filter(name="name_link")
def name_link(user):
linked_name = f'<a href="/user/{escape(user.username)}" class="undecorated-link underline-hover">'
linked_name += f'{escape(user.first_name)} {escape(user.last_name)}</a>'
return mark_safe(linked_name)
@register.filter(name="name_list")
def name_list(users, clickable=False):
if clickable:
out = ', '.join([name_link(user) for user in users])
return mark_safe(out)
else:
return ', '.join([user.first_name + ' ' + user.last_name for user in users])
@register.filter(name='minify') @register.filter(name='minify')
def minify(label): def minify(label):
mapping = { mapping = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment