Skip to content

Commit

Permalink
Add usable but ugly and inefficient "facility list by region" views
Browse files Browse the repository at this point in the history
  • Loading branch information
christophmeissner committed Sep 29, 2015
1 parent 01d1b1a commit e0876a6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
5 changes: 5 additions & 0 deletions scheduler/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,8 @@ class Meta:

def __unicode__(self):
return u'{}'.format(self.name)

@property
def open_needs(self):
now = timezone.now()
return self.need_set.filter(ending_time__gte=now)
27 changes: 16 additions & 11 deletions scheduler/templates/facility_row.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,26 @@ <h5>{{ address_line }} <a
<p>{{ facility.additional_info|safe }}</p>
</div>


{% regroup facility.need_set.open by ending_time.date as shifts_by_time %}

<div class="pull-right">
<h3>{% trans "dates" %}</h3>

<p>
{% for shift_time in shifts_by_time %}
{% with shift_time.grouper as shift_date %}
<a href="{% url 'planner_by_location' pk=facility.pk year=shift_date.year month=shift_date.month day=shift_date.day %}">
{{ shift_date|date }}
</a>
<br/>
{% endwith %}
{% endfor %}
{% regroup facility.open_needs by ending_time.date as shifts_by_time %}
{% if shifts_by_time %}
{% for shift_time in shifts_by_time %}
{% with shift_time.grouper as shift_date %}
<a href="{% url 'planner_by_location' pk=facility.pk year=shift_date.year month=shift_date.month day=shift_date.day %}">
{{ shift_date|date }}
</a>
<br/>
{% endwith %}
{% endfor %}
{% else %}
{% trans "No shifts planned" %}
{% endif %}
</p>
</div>

</div>


14 changes: 3 additions & 11 deletions scheduler/templates/helpdesk_single.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
{% extends "helpdesk_base.html" %}

{% load i18n vpfilters %}

{% block title %}
{% blocktrans trimmed context "title with location" with location_name=location.name %}
Schedule for {{ location_name }}
{% endblocktrans %}
{% endblock %}

{% load i18n %}
{% load vpfilters %}


{% block title %}
{% blocktrans trimmed context "title with date" with schedule_date=schedule_date|date:"d.M.y" %}
Schedule for {{ schedule_date }}
{% endblocktrans %}
{% endblock %}

{% block helpdesk_content %}

{% include "partials/alert_messages.html" %}
Expand All @@ -28,7 +20,7 @@ <h2>
</h2>

<h3>
{% blocktrans trimmed context "title with date" with schedule_date=schedule_date|date %}
{% blocktrans trimmed context "title with date" with schedule_date=schedule_date|date %}
Schedule for {{ schedule_date }}
{% endblocktrans %}
</h3>
Expand Down

0 comments on commit e0876a6

Please sign in to comment.