Skip to content

Commit

Permalink
Created custom filter list subsets
Browse files Browse the repository at this point in the history
Aiming to filter whether current user is scheduled to an apointment
when the agenda has a restricted view.

Signed-off-by: Carlos Oliveira <carlospecter@gmail.com>
Signed-off-by: Cristovao Frinhani <cristovao.frinhani@gmail.com>
Signed-off-by: Vinicius Rangel <vinirmv23@gmail.com>
  • Loading branch information
chocoelho committed Jul 2, 2015
1 parent 50a28e8 commit 1fa27de
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Empty file.
15 changes: 15 additions & 0 deletions gestorpsi/schedule/templatetags/schedule_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django import template

register = template.Library()

@register.filter(name='in_list')
def in_list(value, arg):
value = list(value)
arg = list(arg)

for el1 in value:
for el2 in arg:
if el1.name == el2.person.name:
return True

return False
4 changes: 2 additions & 2 deletions gestorpsi/templates/schedule/schedule_week_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

{% endcomment %}

{% load i18n %}
{% load i18n schedule_filters %}

<p class="description">{% trans "This week have" %} <span id="occurrences_total">{{ occurrences_length }}</span> {% trans "occurrences(s)." %}</p>

Expand All @@ -40,7 +40,7 @@ <h2><span class="date_selected">{% trans "From" %} {{ first_week_day|date:"d" }}
{% for dict in day %}
{% with dict.data as o %}
<div class="tag clean place_{{o.room.place.pk}} room_{{o.room.pk}} {% for p in o.event.referral.professional.all %} professional_{{ p.pk }}{%endfor%} service_{{ o.event.referral.service.pk }}" style="background-color:#{{ o.event.referral.service.color }};" room="{{ o.room.pk }}" place="{{ o.room.place.pk }}">
{% if restrict_schedule %}
{% if restrict_schedule and not user.person_set.all|in_list:o.event.referral.professional.all %}
<b>{{ o.start_time|date:"H:i" }} - {{ o.room }}</b><br />
{% trans "Booked" %}
{% else %}
Expand Down

0 comments on commit 1fa27de

Please sign in to comment.