Skip to content

Commit

Permalink
[#241] Use proper names in follower success flash messages
Browse files Browse the repository at this point in the history
Use user display names and group and package titles, not IDs, in "You
are now following..." and "You are no longer following..." flash
messages.
  • Loading branch information
Sean Hammond committed Feb 22, 2013
1 parent 8744ea4 commit ad279c6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions ckan/controllers/group.py
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions ckan/controllers/package.py
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions ckan/controllers/user.py
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit ad279c6

Please sign in to comment.