Permalink
Browse files

Attempt to show nicer destinations when rendering timetable RTI

  • Loading branch information...
cnorthwood committed Jul 7, 2011
1 parent 8c0d315 commit c633fffd4b691b5a6c45ea251c3374bb19b965ff
@@ -238,8 +238,7 @@ def add_stop(self, meta, entity_type, source):
else:
title = common_name
- if street != None and street != '-' \
- and street not in common_name:
+ if street != None and street != '-':
# Deal with all-caps street names
if street.upper() == street:
fixedstreet = ''
@@ -257,7 +256,8 @@ def add_stop(self, meta, entity_type, source):
fixedstreet += letter.lower()
street = fixedstreet
- title += ', ' + street
+ if street not in title:
+ title += ', ' + street
locality_lang = self.nptg_localities.get(locality)
if locality_lang != None:
@@ -2,6 +2,7 @@
from datetime import datetime, time
from logging import getLogger
from operator import itemgetter
+
from django.db.models import Q
from molly.apps.places.providers import BaseMapsProvider
@@ -43,18 +44,26 @@ def midnight_4am(left, right):
if not stop.journey.runs_on(today.date()):
continue
- services[(stop.journey.route.service_id, stop.journey.route.service_name)].append((stop.journey, stop.std if stop.std else stop.sta))
+ service_id = stop.journey.route.service_id
+ destination = stop.journey.scheduledstop_set.all().reverse()[0].entity.title
+
+ # Now try and tidy up destination
+ destination = destination.split(', ')[-1]
+ if '(' in destination:
+ destination = destination[:destination.find('(')].strip()
+
+ services[(service_id, destination)].append((stop.journey, stop.std or stop.sta))
services = ((route, sorted(ss, key=itemgetter(1), cmp=midnight_4am))
for route, ss in services.items())
services = [{
'service': service_id,
- 'destination': service_name,
+ 'destination': destination,
'next': ss[0][1].strftime('%H:%M'),
'following': map(lambda t: t[1].strftime('%H:%M'), ss[1:4]),
'journey': ss[0][0]
- } for (service_id, service_name), ss in sorted(services, key=lambda x: x[1][0][1])]
+ } for (service_id, destination), ss in sorted(services, key=lambda x: x[1][0][1])]
entity.metadata['real_time_information'] = {
'services': services,
@@ -689,7 +689,6 @@ def initial_context(self, request, scheme, value):
else:
- print stop.sta, stop.std
calling_point = {
'entity': stop.entity,
# Show arrival time (if it exists, else departure time)
@@ -93,8 +93,9 @@ <h2>{% trans data.results_type %} {{ data.type.verbose_name_plural }} - {% now "
<tr>
<td class="center"><big>
{% if service.route %}<a href="{{ entity.get_absolute_url }}service?route={{ service.service|urlencode }}" class="subtle-link">{% endif %}
+ {% if service.journey %}<a href="{{ entity.get_absolute_url }}service?journey={{ service.journey.id }}" class="subtle-link">{% endif %}
{{ service.service }}
- {% if service.route %}</a>{% endif %}
+ {% if service.route or service.journey %}</a>{% endif %}
</big></td>
<td>{{ service.destination }}</td>
<td>{{ service.next }}{% if service.following %}<small>, {{ service.following.0 }}{% if service.following.1 %}, &hellip;{% endif %}</small>{% endif %}</td>

0 comments on commit c633fff

Please sign in to comment.