From 8357dafd2a1ccce60cef5cb572eaa8107d10f10b Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 21 Nov 2012 00:04:51 -0600 Subject: [PATCH 1/2] Added links to child and parent requests 12-01895485 and 12-01895489 as example seems to deal with duplicates badly --- app.py | 20 ++++++++++++++++++++ templates/service_request.html | 11 +++++++++++ 2 files changed, 31 insertions(+) diff --git a/app.py b/app.py index b43e9b5..fae50f4 100644 --- a/app.py +++ b/app.py @@ -143,8 +143,15 @@ def show_request(request_id): # add follow-on closure data, fix types, etc, etc by_id = {} + follow_on_open_count = 0 follow_on_close_count = 0 + + + serve_nm_lst = [s['service_name'] for s in + open311tools.services(app.config['OPEN311_SERVER'], + app.config['OPEN311_API_KEY'])] + for note in sr['notes']: if note['type'] in ('follow_on', 'follow_on_created', 'follow_on_closed'): note_sr_id = note['extended_attributes']['service_request_id'] @@ -158,6 +165,12 @@ def show_request(request_id): follow_on_open_count += 1 by_id[note_sr_id] = note + serv_nm = note['extended_attributes']['service_name'] + print serv_nm + print open311tools.services(app.config['OPEN311_SERVER'], app.config['OPEN311_API_KEY']) + if serv_nm in serve_nm_lst: + note['link_url'] = url_for('show_request', request_id=note_sr_id) + elif note['type'] == 'follow_on_closed' or note['description'].endswith('Closed'): follow_on_close_count += 1 note['type'] = 'follow_on_closed' @@ -169,6 +182,7 @@ def show_request(request_id): if follow_on_open_count >0: # remove the notes that claim the request is closed sr['notes'] = [n for n in sr['notes'] if not n['type'] == 'closed'] + # set the request to open sr['status'] = 'open' @@ -187,6 +201,12 @@ def show_request(request_id): # add the extra note sr['notes'].append(tmp_note) + + if 'parent_service_request_id' in sr['extended_attributes']: + p_req_id = sr['extended_attributes']['parent_service_request_id'] + sr['parent_url'] = url_for('show_request', request_id=p_req_id) + + # if there's no activity yet, show 'under review' if relevant_notes == 0: sr['notes'].append({ diff --git a/templates/service_request.html b/templates/service_request.html index 1ce2eae..2316f9d 100644 --- a/templates/service_request.html +++ b/templates/service_request.html @@ -70,9 +70,16 @@

Activity

+ {% if note.type == 'follow_on_created' %} Transferred to:
+ + {% if note.link_url %} + {{ note.extended_attributes.service_name }}
+ {% else %} + {{ note.extended_attributes.service_name }}
+ {% endif %} Department: {{ note.extended_attributes.agency_responsible }} {% if note.extended_attributes.closed_datetime %}

@@ -106,12 +113,16 @@

Activity

{{ sr.service_name }} + {% if sr.parent_url %} +
Parent + {% endif %} {% if sr.agency_responsible %}
Department: {{ sr.agency_responsible }} {% endif %} {% if sr.extended_attributes and sr.extended_attributes.channel %}
via {{ sr.extended_attributes.channel.title() }} {% endif %} +

From 5e1d4cfd873ffc50398ba7d0f8d72b349512e016 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 27 Nov 2012 18:37:16 -0600 Subject: [PATCH 2/2] added logic to label duplicates (see 12-01937676) which seem to be denoted by adding "parent_service_request_id" and "duplicate" to extended_attributes. --- templates/service_request.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/service_request.html b/templates/service_request.html index 2316f9d..a0d3be2 100644 --- a/templates/service_request.html +++ b/templates/service_request.html @@ -114,7 +114,11 @@

Activity

{{ sr.service_name }} {% if sr.parent_url %} -
Parent + {% if sr.extended_attributes.duplicate %} +
Duplicate + {% else %} +
Parent + {% endif %} {% endif %} {% if sr.agency_responsible %}
Department: {{ sr.agency_responsible }}