Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Flash Messages #7996

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/7996.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adds more flash messages to Group views. Adds flash message to User API token revoke.
22 changes: 22 additions & 0 deletions ckan/views/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,15 @@ def post(

try:
get_action(action_functions[action])(context, data_dict)
if action == 'private':
h.flash_notice(_('Made %s dataset(s) private.')
% len(datasets))
elif action == 'public':
h.flash_notice(_('Made %s dataset(s) public.')
% len(datasets))
elif action == 'delete':
h.flash_notice(_('Deleted %s dataset(s).')
% len(datasets))
except NotAuthorized:
base.abort(403, _(u'Not authorized to perform bulk update'))
return h.redirect_to(u'{}.bulk_process'.format(group_type), id=id)
Expand Down Expand Up @@ -977,6 +986,10 @@ def post(self, group_type: str,
data_dict['users'] = [{u'name': user, u'capacity': u'admin'}]
try:
group = _action(u'group_create')(context, data_dict)
if is_organization:
h.flash_success(_('Organization created.'))
else:
h.flash_success(_('Group created.'))
except (NotFound, NotAuthorized):
base.abort(404, _(u'Group not found'))
except ValidationError as e:
Expand Down Expand Up @@ -1075,6 +1088,10 @@ def post(self,
group = _action(u'group_update')(context, data_dict)
if id != group['name']:
_force_reindex(group)
if is_organization:
h.flash_success(_('Organization updated.'))
else:
h.flash_success(_('Group updated.'))
except (NotFound, NotAuthorized):
base.abort(404, _(u'Group not found'))
except ValidationError as e:
Expand Down Expand Up @@ -1229,6 +1246,11 @@ def post(self,

try:
group_dict = _action(u'group_member_create')(context, data_dict)
messages = {'member': _('Assigned %s as a member.'),
'editor': _('Assigned %s as an editor.'),
'admin': _('Assigned %s as an admin.')}
h.flash_success(messages[data_dict['role']]
% data_dict['username'])
except NotAuthorized:
base.abort(403, _(u'Unauthorized to add member to group %s') % u'')
except NotFound:
Expand Down
3 changes: 3 additions & 0 deletions ckan/views/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,14 @@ def post(self,
if to_delete:
data[u'id'] = view_id
get_action(u'resource_view_delete')(context, data)
h.flash_notice(_('View deleted.'))
elif view_id:
data[u'id'] = view_id
data = get_action(u'resource_view_update')(context, data)
h.flash_success(_('View updated.'))
else:
data = get_action(u'resource_view_create')(context, data)
h.flash_success(_('View created.'))
except ValidationError as e:
# Could break preview if validation error
to_preview = False
Expand Down
2 changes: 2 additions & 0 deletions ckan/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ def post(self, id: str) -> Union[Response, str]:

def api_token_revoke(id: str, jti: str) -> Response:
try:
token = model.ApiToken.get(jti)
logic.get_action(u'api_token_revoke')({}, {u'jti': jti})
h.flash_notice(_('Deleted API token %s') % token.name if token else '')
except logic.NotAuthorized:
base.abort(403, _(u'Unauthorized to revoke API tokens.'))
return h.redirect_to(u'user.api_tokens', id=id)
Expand Down