From ad279c6eaceb7888e774184a80d00fb955986355 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Fri, 22 Feb 2013 12:42:04 +0100 Subject: [PATCH] [#241] Use proper names in follower success flash messages Use user display names and group and package titles, not IDs, in "You are now following..." and "You are no longer following..." flash messages. --- ckan/controllers/group.py | 8 ++++++-- ckan/controllers/package.py | 8 ++++++-- ckan/controllers/user.py | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ckan/controllers/group.py b/ckan/controllers/group.py index b3a352fe2a3..170590bb42f 100644 --- a/ckan/controllers/group.py +++ b/ckan/controllers/group.py @@ -642,7 +642,9 @@ def follow(self, id): data_dict = {'id': id} try: get_action('follow_group')(context, data_dict) - h.flash_success(_("You are now following {0}").format(id)) + group_dict = get_action('group_show')(context, data_dict) + h.flash_success(_("You are now following {0}").format( + group_dict['title'])) except ValidationError as e: error_message = (e.extra_msg or e.message or e.error_summary or e.error_dict) @@ -659,7 +661,9 @@ def unfollow(self, id): data_dict = {'id': id} try: get_action('unfollow_group')(context, data_dict) - h.flash_success(_("You are no longer following {0}").format(id)) + group_dict = get_action('group_show')(context, data_dict) + h.flash_success(_("You are no longer following {0}").format( + group_dict['title'])) except ValidationError as e: error_message = (e.extra_msg or e.message or e.error_summary or e.error_dict) diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py index d7bd58728ea..e58bc6db36f 100644 --- a/ckan/controllers/package.py +++ b/ckan/controllers/package.py @@ -1216,7 +1216,9 @@ def follow(self, id): data_dict = {'id': id} try: get_action('follow_dataset')(context, data_dict) - h.flash_success(_("You are now following {0}").format(id)) + package_dict = get_action('package_show')(context, data_dict) + h.flash_success(_("You are now following {0}").format( + package_dict['title'])) except ValidationError as e: error_message = (e.extra_msg or e.message or e.error_summary or e.error_dict) @@ -1233,7 +1235,9 @@ def unfollow(self, id): data_dict = {'id': id} try: get_action('unfollow_dataset')(context, data_dict) - h.flash_success(_("You are no longer following {0}").format(id)) + package_dict = get_action('package_show')(context, data_dict) + h.flash_success(_("You are no longer following {0}").format( + package_dict['title'])) except ValidationError as e: error_message = (e.extra_msg or e.message or e.error_summary or e.error_dict) diff --git a/ckan/controllers/user.py b/ckan/controllers/user.py index b0e13dccd2c..fe75a550147 100644 --- a/ckan/controllers/user.py +++ b/ckan/controllers/user.py @@ -586,7 +586,9 @@ def follow(self, id): data_dict = {'id': id} try: get_action('follow_user')(context, data_dict) - h.flash_success(_("You are now following {0}").format(id)) + user_dict = get_action('user_show')(context, data_dict) + h.flash_success(_("You are now following {0}").format( + user_dict['display_name'])) except ValidationError as e: error_message = (e.extra_msg or e.message or e.error_summary or e.error_dict) @@ -603,7 +605,9 @@ def unfollow(self, id): data_dict = {'id': id} try: get_action('unfollow_user')(context, data_dict) - h.flash_success(_("You are no longer following {0}").format(id)) + user_dict = get_action('user_show')(context, data_dict) + h.flash_success(_("You are no longer following {0}").format( + user_dict['display_name'])) except (NotFound, NotAuthorized) as e: error_message = e.extra_msg or e.message h.flash_error(error_message)