Skip to content

Commit

Permalink
[#1873] setup template variables at start of member_new controller
Browse files Browse the repository at this point in the history
If a validation error was thrown, then the template would be rendered
before these variables had been setup.
  • Loading branch information
joetsoi committed Sep 15, 2014
1 parent f83332a commit 603fed0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ckan/controllers/group.py
Expand Up @@ -639,12 +639,19 @@ def member_new(self, id):

#self._check_access('group_delete', context, {'id': id})
try:
c.group_dict = self._action('group_show')(context, {'id': id})
group_type = 'organization' if c.group_dict['is_organization'] else 'group'
c.roles = self._action('member_roles_list')(
context, {'group_type': group_type}
)

if request.method == 'POST':
data_dict = clean_dict(dict_fns.unflatten(
tuplize_dict(parse_params(request.params))))
data_dict['id'] = id

email = data_dict.get('email')

if email:
user_data_dict = {
'email': email,
Expand All @@ -657,6 +664,8 @@ def member_new(self, id):
data_dict['username'] = user_dict['name']

c.group_dict = self._action('group_member_create')(context, data_dict)


self._redirect_to(controller='group', action='members', id=id)
else:
user = request.params.get('user')
Expand All @@ -665,11 +674,6 @@ def member_new(self, id):
c.user_role = new_authz.users_role_for_group_or_org(id, user) or 'member'
else:
c.user_role = 'member'
c.group_dict = self._action('group_show')(context, {'id': id})
group_type = 'organization' if c.group_dict['is_organization'] else 'group'
c.roles = self._action('member_roles_list')(
context, {'group_type': group_type}
)
except NotAuthorized:
abort(401, _('Unauthorized to add member to group %s') % '')
except NotFound:
Expand Down

0 comments on commit 603fed0

Please sign in to comment.