diff --git a/casepro/cases/tests.py b/casepro/cases/tests.py index 4f88d6200..8196dc140 100644 --- a/casepro/cases/tests.py +++ b/casepro/cases/tests.py @@ -819,7 +819,7 @@ def test_fetch(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json, { 'id': self.case.pk, - 'contact': {'id': self.ann.pk, 'name': "Ann"}, + 'contact': {'id': self.ann.pk, 'display': "Ann"}, 'assignee': {'id': self.moh.pk, 'name': "MOH"}, 'labels': [{'id': self.aids.pk, 'name': "AIDS"}], 'summary': "Summary", @@ -870,12 +870,12 @@ def test_timeline(self, mock_fetch_contact_messages): self.assertEqual(len(response.json['results']), 3) self.assertEqual(response.json['results'][0]['type'], 'I') self.assertEqual(response.json['results'][0]['item']['text'], "What is AIDS?") - self.assertEqual(response.json['results'][0]['item']['contact'], {'id': self.ann.pk, 'name': "Ann"}) + self.assertEqual(response.json['results'][0]['item']['contact'], {'id': self.ann.pk, 'display': "Ann"}) self.assertEqual( response.json['results'][0]['item']['case']['user_assignee'], {'id': self.user1.pk, 'name': "Evan"}) self.assertEqual(response.json['results'][1]['type'], 'O') self.assertEqual(response.json['results'][1]['item']['text'], "Non casepro message...") - self.assertEqual(response.json['results'][1]['item']['contact'], {'id': self.ann.pk, 'name': "Ann"}) + self.assertEqual(response.json['results'][1]['item']['contact'], {'id': self.ann.pk, 'display': "Ann"}) self.assertEqual(response.json['results'][2]['type'], 'A') self.assertEqual(response.json['results'][2]['item']['action'], 'O') @@ -975,10 +975,10 @@ def test_timeline(self, mock_fetch_contact_messages): self.assertEqual(len(items), 7) self.assertEqual(items[0]['type'], 'I') self.assertEqual(items[0]['item']['text'], "What is AIDS?") - self.assertEqual(items[0]['item']['contact'], {'id': self.ann.pk, 'name': "Ann"}) + self.assertEqual(items[0]['item']['contact'], {'id': self.ann.pk, 'display': "Ann"}) self.assertEqual(items[1]['type'], 'O') self.assertEqual(items[1]['item']['text'], "Non casepro message...") - self.assertEqual(items[1]['item']['contact'], {'id': self.ann.pk, 'name': "Ann"}) + self.assertEqual(items[1]['item']['contact'], {'id': self.ann.pk, 'display': "Ann"}) self.assertEqual(items[1]['item']['sender'], None) self.assertEqual(items[2]['type'], 'A') self.assertEqual(items[2]['item']['action'], 'O') @@ -1030,7 +1030,7 @@ def test_search(self): 'id': case2.pk, 'assignee': {'id': self.who.pk, 'name': "WHO"}, 'user_assignee': None, - 'contact': {'id': self.ann.pk, 'name': "Ann"}, + 'contact': {'id': self.ann.pk, 'display': "Ann"}, 'labels': [], 'summary': "", 'opened_on': format_iso8601(case2.opened_on), @@ -1040,7 +1040,7 @@ def test_search(self): 'id': self.case.pk, 'assignee': {'id': self.moh.pk, 'name': "MOH"}, 'user_assignee': {'id': self.user1.pk, 'name': "Evan"}, - 'contact': {'id': self.ann.pk, 'name': "Ann"}, + 'contact': {'id': self.ann.pk, 'display': "Ann"}, 'labels': [{'id': self.aids.pk, 'name': "AIDS"}], 'summary': "Summary", 'opened_on': format_iso8601(self.case.opened_on), @@ -1057,7 +1057,7 @@ def test_search(self): 'id': self.case.pk, 'assignee': {'id': self.moh.pk, 'name': "MOH"}, 'user_assignee': {'id': self.user1.pk, 'name': "Evan"}, - 'contact': {'id': self.ann.pk, 'name': "Ann"}, + 'contact': {'id': self.ann.pk, 'display': "Ann"}, 'labels': [{'id': self.aids.pk, 'name': "AIDS"}], 'summary': "Summary", 'opened_on': format_iso8601(self.case.opened_on), diff --git a/casepro/cases/views.py b/casepro/cases/views.py index aa8cf7214..23c7864a6 100644 --- a/casepro/cases/views.py +++ b/casepro/cases/views.py @@ -74,7 +74,6 @@ def get_context_data(self, **kwargs): 'all_labels': [l.as_json() for l in labels] }) - context['anon_contacts'] = getattr(settings, 'SITE_ANON_CONTACTS', False) context['max_msg_chars'] = MAX_MESSAGE_CHARS context['can_update'] = can_update context['alert'] = self.request.GET.get('alert', None) diff --git a/casepro/contacts/models.py b/casepro/contacts/models.py index 1d0df8486..dfde782d4 100644 --- a/casepro/contacts/models.py +++ b/casepro/contacts/models.py @@ -261,6 +261,10 @@ class Contact(models.Model): """ A contact in RapidPro """ + DISPLAY_NAME = 'name' + DISPLAY_URNS = 'urns' + DISPLAY_ANON = 'uuid' + SAVE_GROUPS_ATTR = '__data__groups' org = models.ForeignKey(Org, verbose_name=_("Organization"), related_name="contacts") @@ -330,18 +334,24 @@ def get_or_create_from_urn(cls, org, urn, name=None): def lock(cls, org, uuid): return get_redis_connection().lock(CONTACT_LOCK_KEY % (org.pk, uuid), timeout=60) - def get_display_name(self): + def get_display(self): """ - Gets the display name of this contact. If name is empty or site uses anonymous contacts, this is generated from - the backend UUID. If no UUID is set for the contact, an empty string is returned. + Gets the display of this contact. If the site uses anonymous contacts this is generated from the backend UUID. + If the display setting is recognised and set then that field is returned, otherwise the name is returned. + If no name is set an empty string is returned. """ - if not self.name or getattr(settings, 'SITE_ANON_CONTACTS', False): - if self.uuid: - return self.uuid[:6].upper() - return "" - else: + display_format = getattr(settings, 'SITE_CONTACT_DISPLAY', self.DISPLAY_NAME) + + if display_format == self.DISPLAY_ANON and self.uuid: + return self.uuid[:6].upper() + elif display_format == self.DISPLAY_URNS and self.urns: + _scheme, path = URN.to_parts(self.urns[0]) + return path + elif display_format == self.DISPLAY_NAME and self.name: return self.name + return "---" + def get_fields(self, visible=None): fields = self.fields if self.fields else {} @@ -421,9 +431,12 @@ def as_json(self, full=True): """ Prepares a contact for JSON serialization """ - result = {'id': self.pk, 'name': self.get_display_name()} + result = {'id': self.pk, 'display': self.get_display()} if full: + hidden_fields = getattr(settings, 'SITE_HIDE_CONTACT_FIELDS', []) + result['urns'] = self.urns if "urns" not in hidden_fields else [] + result['name'] = self.name if "name" not in hidden_fields else None result['groups'] = [g.as_json(full=False) for g in self.groups.all()] result['fields'] = self.get_fields(visible=True) result['language'] = self.get_language() @@ -433,4 +446,4 @@ def as_json(self, full=True): return result def __str__(self): - return self.get_display_name() + return self.get_display() diff --git a/casepro/contacts/tests.py b/casepro/contacts/tests.py index 20a430cae..f065ff87b 100644 --- a/casepro/contacts/tests.py +++ b/casepro/contacts/tests.py @@ -118,16 +118,21 @@ def test_save(self): self.assertEqual(set(contact.groups.all()), {spammers, boffins}) - def test_get_display_name(self): - self.assertEqual(self.ann.get_display_name(), "Ann") - - # if site uses anon contacts then obscure this - with override_settings(SITE_ANON_CONTACTS=True): - self.assertEqual(self.ann.get_display_name(), "7B7DD8") - - # likewise if name if empty - self.ann.name = "" - self.assertEqual(self.ann.get_display_name(), "7B7DD8") + def test_get_display(self): + # if the site uses 'uuid' for the display + with override_settings(SITE_CONTACT_DISPLAY="uuid"): + self.assertEqual(self.ann.get_display(), "7B7DD8") + + # if the site uses 'urns' for the display + self.ann.urns = ['tel:+2345'] + with override_settings(SITE_CONTACT_DISPLAY="urns"): + self.assertEqual(self.ann.get_display(), "+2345") + self.ann.refresh_from_db() + + # if the site uses 'name' or something unrecognised for the display + self.assertEqual(self.ann.get_display(), "Ann") + self.ann.name = None + self.assertEqual(self.ann.get_display(), "---") def test_get_fields(self): self.assertEqual(self.ann.get_fields(), {'age': "32", 'state': "WA"}) # what is stored on the contact @@ -144,12 +149,14 @@ def test_release(self): self.assertEqual(self.ann.incoming_messages.filter(is_active=False, is_handled=True).count(), 2) def test_as_json(self): - self.assertEqual(self.ann.as_json(full=False), {'id': self.ann.pk, 'name': "Ann"}) + self.assertEqual(self.ann.as_json(full=False), {'id': self.ann.pk, 'display': "Ann"}) # full=True means include visible contact fields and laanguage etc self.assertEqual(self.ann.as_json(full=True), { 'id': self.ann.pk, + 'display': "Ann", 'name': "Ann", + 'urns': [], 'language': {'code': 'eng', 'name': "English"}, 'groups': [{'id': self.reporters.pk, 'name': "Reporters"}], 'fields': {'nickname': None, 'age': "32"}, @@ -158,11 +165,14 @@ def test_as_json(self): }) self.ann.language = None + self.ann.urns = ["tel:+2345678", "mailto:ann@test.com"] self.ann.save() self.assertEqual(self.ann.as_json(full=True), { 'id': self.ann.pk, + 'display': "Ann", 'name': "Ann", + 'urns': ["tel:+2345678", "mailto:ann@test.com"], 'language': None, 'groups': [{'id': self.reporters.pk, 'name': "Reporters"}], 'fields': {'nickname': None, 'age': "32"}, @@ -170,9 +180,20 @@ def test_as_json(self): 'stopped': False }) - # if site uses anon contacts then name is obscured - with override_settings(SITE_ANON_CONTACTS=True): - self.assertEqual(self.ann.as_json(full=False), {'id': self.ann.pk, 'name': "7B7DD8"}) + # If the urns and name fields are hidden they should not be returned + # SITE_CONTACT_DISPLAY overrules this for the 'display' attr + with override_settings(SITE_HIDE_CONTACT_FIELDS=["urns", "name"], SITE_CONTACT_DISPLAY="uuid"): + self.assertEqual(self.ann.as_json(full=True), { + 'id': self.ann.pk, + 'display': "7B7DD8", + 'urns': [], + 'name': None, + 'language': None, + 'groups': [{'id': self.reporters.pk, 'name': "Reporters"}], + 'fields': {'nickname': None, 'age': "32"}, + 'blocked': False, + 'stopped': False + }) @patch('casepro.test.TestBackend.push_contact') def test_get_or_create_from_urn(self, mock_push_contact): @@ -260,7 +281,9 @@ def test_fetch(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json, { 'id': self.ann.pk, + 'display': "Ann", 'name': "Ann", + 'urns': [], 'language': {'code': 'eng', 'name': "English"}, 'fields': {'age': '32', 'nickname': None}, 'groups': [{'id': self.reporters.pk, 'name': "Reporters"}], diff --git a/casepro/msgs/tests.py b/casepro/msgs/tests.py index 93320f2d2..d5a26f4b2 100644 --- a/casepro/msgs/tests.py +++ b/casepro/msgs/tests.py @@ -1076,7 +1076,7 @@ def test_as_json(self): self.assertEqual(msg.as_json(), { 'id': msg.backend_id, - 'contact': {'id': self.ann.pk, 'name': "Ann"}, + 'contact': {'id': self.ann.pk, 'display': "Ann"}, 'text': "Hello", 'time': msg.created_on, 'labels': [{'id': self.aids.pk, 'name': "AIDS"}], @@ -1135,7 +1135,7 @@ def test_search(self): self.assertEqual(len(response.json['results']), 3) self.assertEqual(response.json['results'][0]['id'], 103) self.assertEqual(response.json['results'][1]['id'], 102) - self.assertEqual(response.json['results'][1]['contact'], {'id': self.bob.pk, 'name': "Bob"}) + self.assertEqual(response.json['results'][1]['contact'], {'id': self.bob.pk, 'display': "Bob"}) self.assertEqual(response.json['results'][1]['text'], "I ♡ RapidPro") self.assertEqual(response.json['results'][1]['labels'], [{'id': self.pregnancy.pk, 'name': "Pregnancy"}]) self.assertEqual(response.json['results'][2]['id'], 101) @@ -1148,7 +1148,7 @@ def test_search(self): self.assertEqual(len(response.json['results']), 2) self.assertEqual(response.json['results'][0]['id'], 105) - self.assertEqual(response.json['results'][0]['contact'], {'id': cat.pk, 'name': "Cat"}) + self.assertEqual(response.json['results'][0]['contact'], {'id': cat.pk, 'display': "Cat"}) self.assertEqual(response.json['results'][0]['text'], "AIDS??") self.assertEqual(response.json['results'][0]['labels'], [{'id': self.aids.pk, 'name': "AIDS"}]) self.assertEqual(response.json['results'][0]['case'], { @@ -1503,7 +1503,7 @@ def test_as_json(self): self.assertEqual(outgoing.as_json(), { 'id': outgoing.pk, - 'contact': {'id': self.ann.pk, 'name': "Ann"}, + 'contact': {'id': self.ann.pk, 'display': "Ann"}, 'urn': None, 'text': "That's great", 'time': outgoing.created_on, @@ -1538,7 +1538,7 @@ def test_search(self): self.assertEqual(response.json['results'], [ { 'id': out2.pk, - 'contact': {'id': self.ann.pk, 'name': "Ann"}, + 'contact': {'id': self.ann.pk, 'display': "Ann"}, 'urn': None, 'text': "Hello 2", 'case': None, @@ -1547,7 +1547,7 @@ def test_search(self): }, { 'id': out1.pk, - 'contact': {'id': self.ann.pk, 'name': "Ann"}, + 'contact': {'id': self.ann.pk, 'display': "Ann"}, 'urn': None, 'text': "Hello 1", 'case': None, @@ -1563,7 +1563,7 @@ def test_search(self): self.assertEqual(response.json['results'], [ { 'id': out2.pk, - 'contact': {'id': self.ann.pk, 'name': "Ann"}, + 'contact': {'id': self.ann.pk, 'display': "Ann"}, 'urn': None, 'text': "Hello 2", 'case': None, @@ -1598,7 +1598,7 @@ def test_search_replies(self): self.assertEqual(response.json['results'], [ { 'id': out2.pk, - 'contact': {'id': self.bob.pk, 'name': "Bob"}, + 'contact': {'id': self.bob.pk, 'display': "Bob"}, 'urn': None, 'text': "Hello 2", 'case': None, @@ -1613,7 +1613,7 @@ def test_search_replies(self): }, { 'id': out1.pk, - 'contact': {'id': self.ann.pk, 'name': "Ann"}, + 'contact': {'id': self.ann.pk, 'display': "Ann"}, 'urn': None, 'text': "Hello 1", 'case': {'id': case.pk, 'assignee': {'id': self.moh.pk, 'name': "MOH"}, 'user_assignee': None}, diff --git a/casepro/orgs_ext/tests.py b/casepro/orgs_ext/tests.py index 035452fe3..6fbb5093f 100644 --- a/casepro/orgs_ext/tests.py +++ b/casepro/orgs_ext/tests.py @@ -1,5 +1,7 @@ from __future__ import absolute_import, unicode_literals +import pytz + from dash.orgs.models import TaskState from django.core.urlresolvers import reverse @@ -58,7 +60,7 @@ def test_edit(self): form = response.context['form'] self.assertEqual(form.initial['name'], "UNICEF") - self.assertEqual(form.initial['timezone'], "Africa/Kampala") + self.assertEqual(form.initial['timezone'], pytz.timezone("Africa/Kampala")) self.assertEqual(form.fields['banner_text'].initial, "Howdy (U)Partner!") self.assertEqual(form.fields['contact_fields'].choices, [(self.age.pk, "Age (age)"), @@ -82,7 +84,7 @@ def test_edit(self): self.unicef._config = None self.assertEqual(self.unicef.name, "UNIZEFF") - self.assertEqual(self.unicef.timezone, "Africa/Kigali") + self.assertEqual(self.unicef.timezone, pytz.timezone("Africa/Kigali")) self.assertEqual(self.unicef.get_banner_text(), "Chill") self.assertEqual(set(Group.get_suspend_from(self.unicef)), {self.males}) diff --git a/casepro/settings_common.py b/casepro/settings_common.py index 37fa94d50..512e6da60 100644 --- a/casepro/settings_common.py +++ b/casepro/settings_common.py @@ -53,8 +53,9 @@ SITE_ORGS_STORAGE_ROOT = 'orgs' SITE_EXTERNAL_CONTACT_URL = 'http://localhost:8001/contact/read/%s/' SITE_BACKEND = 'casepro.backend.NoopBackend' -SITE_ANON_CONTACTS = False SITE_CASE_RESPONSE_REQUIRED_TIME = None # specified in minutes, None to disable +SITE_HIDE_CONTACT_FIELDS = [] # Listed fields should not be displayed +SITE_CONTACT_DISPLAY = "name" # Overrules SITE_HIDE_CONTACT_FIELDS Options: 'name', 'uuid' or 'urns' SITE_ALLOW_CASE_WITHOUT_MESSAGE = True # junebug configuration diff --git a/casepro/statistics/models.py b/casepro/statistics/models.py index 62d727fb1..ed144e6b9 100644 --- a/casepro/statistics/models.py +++ b/casepro/statistics/models.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals -import pytz import six from dash.orgs.models import Org @@ -21,7 +20,7 @@ def datetime_to_date(dt, org): """ Convert a datetime to a date using the given org's timezone """ - return dt.astimezone(pytz.timezone(org.timezone)).date() + return dt.astimezone(org.timezone).date() class BaseCount(models.Model): diff --git a/casepro/test.py b/casepro/test.py index b2cf83944..6da20baad 100644 --- a/casepro/test.py +++ b/casepro/test.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals import json +import pytz from dash.test import DashTest from datetime import datetime, date, time @@ -37,8 +38,8 @@ def setUp(self): settings.SITE_ORGS_STORAGE_ROOT = 'test_orgs' # some orgs - self.unicef = self.create_org("UNICEF", timezone="Africa/Kampala", subdomain="unicef") - self.nyaruka = self.create_org("Nyaruka", timezone="Africa/Kigali", subdomain="nyaruka") + self.unicef = self.create_org("UNICEF", timezone=pytz.timezone("Africa/Kampala"), subdomain="unicef") + self.nyaruka = self.create_org("Nyaruka", timezone=pytz.timezone("Africa/Kigali"), subdomain="nyaruka") # some admins for those orgs self.admin = self.create_admin(self.unicef, "Kidus", "kidus@unicef.org") diff --git a/karma/test-controllers.coffee b/karma/test-controllers.coffee index 0993303e7..54e59994b 100644 --- a/karma/test-controllers.coffee +++ b/karma/test-controllers.coffee @@ -45,7 +45,7 @@ describe('controllers:', () -> ureporters: {id: 703, name: "U-Reporters"}, # contacts - ann: {id: 401, name: "Ann", fields: {'age': 35}, groups: [{id: 701, name: "Females"}, {id: 703, name: "U-Reporters"}]}, + ann: {id: 401, name: "Ann", fields: {'age': 35}, groups: [{id: 701, name: "Females"}, {id: 703, name: "U-Reporters"}], urns: []}, bob: {id: 402, name: "Bob", fields: {}, groups: []} } ) diff --git a/karma/test-services.coffee b/karma/test-services.coffee index b94a5b55f..a9e343835 100644 --- a/karma/test-services.coffee +++ b/karma/test-services.coffee @@ -218,9 +218,9 @@ describe('services:', () -> describe('fetch', () -> it('gets contact from fetch endpoint', () -> - $httpBackend.expectGET('/contact/fetch/401/').respond('{"id":401, "name":"Ann", "fields":{}}') + $httpBackend.expectGET('/contact/fetch/401/').respond('{"id":401, "name":"Ann", "fields":{}, "urns": []}') ContactService.fetch(401).then((contact) -> - expect(contact).toEqual({id: 401, name: "Ann", fields:{}}) + expect(contact).toEqual({id: 401, name: "Ann", fields:{}, urns:[]}) ) $httpBackend.flush() ) diff --git a/karma/test-utils.coffee b/karma/test-utils.coffee index 245623644..24b8eb241 100644 --- a/karma/test-utils.coffee +++ b/karma/test-utils.coffee @@ -61,4 +61,15 @@ describe('utils:', () -> expect(utils.trap(Foo, ((v) -> v), (-> null))(bar)).toEqual(null) ) ) + + describe('formatUrns', () -> + it('formats urn arrays for display', () -> + urns = ['tel:+273456712', 'mailto:test@testing.com', 'twitter:tester'] + + expect(utils.formatUrns(urns)).toEqual([ + {scheme: 'Phone', path: '+273456712'}, {scheme: 'Email', path: 'test@testing.com'}, + {scheme: 'Twitter', path: 'tester'} + ]) + ) + ) ) diff --git a/pip-freeze.txt b/pip-freeze.txt index 7bb368d6b..0be0a52a1 100644 --- a/pip-freeze.txt +++ b/pip-freeze.txt @@ -41,7 +41,7 @@ psycopg2==2.6.1 pycountry==1.12 python-dateutil==2.4.2 pytz==2015.7 -rapidpro-dash==1.0.1 +rapidpro-dash==1.0.2 rapidpro-python==2.1.1 raven==5.27.1 redis==2.10.3 @@ -50,7 +50,7 @@ requests==2.7.0 responses==0.5.1 six==1.10.0 smartmin==1.9.2 -sorl-thumbnail==12.3 +sorl-thumbnail==12.4a1 sqlparse==0.1.15 xlrd==1.0.0 xlutils==2.0.0 diff --git a/static/coffee/controllers.coffee b/static/coffee/controllers.coffee index d99349db9..db18a1939 100644 --- a/static/coffee/controllers.coffee +++ b/static/coffee/controllers.coffee @@ -706,7 +706,8 @@ controllers.controller('CaseTimelineController', ['$scope', '$timeout', 'CaseSer # Contact dashboard controller #============================================================================ controllers.controller('ContactController', ['$scope', '$window', 'ContactService', ($scope, $window, ContactService) -> - + contact = $window.contextData.contact + contact.urns = utils.formatUrns(contact.urns) $scope.contact = $window.contextData.contact $scope.fields = $window.contextData.fields diff --git a/static/coffee/services.coffee b/static/coffee/services.coffee index 80031e9fd..c307db74a 100644 --- a/static/coffee/services.coffee +++ b/static/coffee/services.coffee @@ -17,6 +17,7 @@ services.factory('ContactService', ['$http', ($http) -> #---------------------------------------------------------------------------- fetch: (id) -> return $http.get('/contact/fetch/' + id + '/').then((response) -> + response.data.urns = utils.formatUrns(response.data.urns) return response.data ) diff --git a/static/coffee/utils.coffee b/static/coffee/utils.coffee index 5c063a1d8..a19ac204a 100644 --- a/static/coffee/utils.coffee +++ b/static/coffee/utils.coffee @@ -50,4 +50,12 @@ namespace('utils', (exports) -> acceptFn(v) else rejectFn(v) + + exports.formatUrns = (urns) -> + scheme_names = {'tel': "Phone", 'mailto': "Email", 'twitter': "Twitter"} + formatted_urns = [] + for urn in urns + urn_parts = urn.split(':') + formatted_urns.push({'scheme': scheme_names[urn_parts[0]], 'path': urn_parts[1]}) + return formatted_urns ) diff --git a/templates/cases/case_read.haml b/templates/cases/case_read.haml index 55bdc82dd..497a319dd 100644 --- a/templates/cases/case_read.haml +++ b/templates/cases/case_read.haml @@ -164,11 +164,16 @@ - trans "Contact" .panel-body .container-fluid - .row + .row{ ng-if:"contact.name" } .contact-field-label.col-sm-6 - trans "Name" .contact-field-value.col-sm-6 - [[ caseObj.contact.name ]] + [[ contact.name ]] + .row{ ng-repeat:"urn in contact.urns" } + .contact-field-label.col-sm-6 + [[ urn.scheme ]] + .contact-field-value.col-sm-6 + [[ urn.path ]] .row{ ng-if:"contact.language" } .contact-field-label.col-sm-6 - trans "Language" diff --git a/templates/cases/inbox_base.haml b/templates/cases/inbox_base.haml index 268c606ed..97e4fd6d5 100644 --- a/templates/cases/inbox_base.haml +++ b/templates/cases/inbox_base.haml @@ -25,15 +25,14 @@ %i.glyphicon.glyphicon-tag   [[ activeLabel.name | deunderscore ]] - - if allow_case_without_message - .btn-group.page-header-buttons - %button.btn.btn-default{ type:"button", ng-click:"onCaseWithoutMessage()"} - - trans "Open Case" - .page-header-buttons{ ng-if:"activeLabel" } + .page-header-buttons.btn-group - if perms.msgs.label_read or org_perms.msgs.label_read - %a.btn.btn-default{ ng-href:"/label/read/[[ activeLabel.id ]]/" } + %a.btn.btn-default{ ng-href:"/label/read/[[ activeLabel.id ]]/", ng-if:"activeLabel" } - trans "View Label" + - if allow_case_without_message + %button.btn.btn-default{ type:"button", ng-click:"onCaseWithoutMessage()"} + - trans "Open Case" .row .col-md-3 diff --git a/templates/cases/inbox_messages.haml b/templates/cases/inbox_messages.haml index 47882b91d..aebe1feaa 100644 --- a/templates/cases/inbox_messages.haml +++ b/templates/cases/inbox_messages.haml @@ -9,7 +9,7 @@ %span.contact-info Messages for contact %strong - [[ activeContact.name ]] + [[ activeContact.display ]] .pull-away .btn-group - if user_is_admin diff --git a/templates/cases/inbox_outgoing.haml b/templates/cases/inbox_outgoing.haml index 0cec2aaf3..d7d1385c4 100644 --- a/templates/cases/inbox_outgoing.haml +++ b/templates/cases/inbox_outgoing.haml @@ -10,7 +10,7 @@ %span.contact-info Messages for contact %strong - [[ activeContact.name ]] + [[ activeContact.display ]] - if user_is_admin   diff --git a/templates/contacts/contact_read.haml b/templates/contacts/contact_read.haml index f99ffff67..32a1c46e1 100644 --- a/templates/contacts/contact_read.haml +++ b/templates/contacts/contact_read.haml @@ -17,7 +17,7 @@ %h2 %span.glyphicon.glyphicon-phone - [[ contact.name ]] + [[ contact.display ]] %ul.header-details %li{ ng-if:"contact.blocked || contact.stopped" } @@ -58,6 +58,16 @@ - trans "Details" .panel-body .container-fluid + .row{ ng-if:"contact.name" } + .contact-field-label.col-sm-6 + - trans "Name" + .contact-field-value.col-sm-6 + [[ contact.name ]] + .row{ ng-repeat:"urn in contact.urns" } + .contact-field-label.col-sm-6 + [[ urn.scheme ]] + .contact-field-value.col-sm-6 + [[ urn.path ]] .row .contact-field-label.col-sm-6 - trans "Language" diff --git a/templates/partials/directive_contact.haml b/templates/partials/directive_contact.haml index a4ff2be1d..6120debc4 100644 --- a/templates/partials/directive_contact.haml +++ b/templates/partials/directive_contact.haml @@ -1,3 +1,3 @@ -.{ ng-mouseenter:"openPopover()", ng-mouseleave:"closePopover()", uib-popover-template:"popoverTemplateUrl", popover-is-open:"popoverIsOpen", popover-append-to-body:"true", popover-placement:"auto bottom-left", popover-title:"[[ contact.name ]]" } +.{ ng-mouseenter:"openPopover()", ng-mouseleave:"closePopover()", uib-popover-template:"popoverTemplateUrl", popover-is-open:"popoverIsOpen", popover-append-to-body:"true", popover-placement:"auto bottom-left", popover-title:"[[ contact.display ]]" } %span.glyphicon.glyphicon-phone> - [[ contact.name ]] \ No newline at end of file + [[ contact.display ]] \ No newline at end of file