Skip to content

Commit

Permalink
[#2366] Only display authz options for Authz Groups if there are some.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed May 7, 2012
1 parent e2e2578 commit 4049826
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ckan/controllers/admin.py
Expand Up @@ -234,6 +234,8 @@ def action_add_form(users_or_authz_groups):
c.authz_groups = authz_groups
c.authz_groups_role_dict = authz_groups_role_dict

c.are_any_authz_groups = bool(model.Session.query(model.AuthorizationGroup).count())

return render('admin/authz.html')

def trash(self):
Expand Down
2 changes: 1 addition & 1 deletion ckan/lib/base.py
Expand Up @@ -541,7 +541,7 @@ def _prepare_authz_info_for_render(self, user_object_roles):
c.user_role_dict = user_role_dict
c.authz_groups = authz_groups
c.authz_groups_role_dict = authz_groups_role_dict

c.are_any_authz_groups = bool(model.Session.query(model.AuthorizationGroup).count())

# Include the '_' function in the public names
__all__ = [__name for __name in locals().keys() if not __name.startswith('_') \
Expand Down
3 changes: 2 additions & 1 deletion ckan/templates/admin/authz.html
Expand Up @@ -26,6 +26,7 @@ <h3>Add Roles for Any User</h3>

<hr/>

<py:if test="c.are_any_authz_groups">
<h3>Existing Roles for Authorization Groups</h3>

<form id="authzgroup_form" method="POST">
Expand All @@ -41,7 +42,7 @@ <h3>Add Roles for Any Authorization Group</h3>
<button type="submit" name="authz_add" class="btn btn-primary">Add Role</button>
<div class="clear"></div>
</form>

</py:if>



Expand Down
2 changes: 2 additions & 0 deletions ckan/templates/group/authz.html
Expand Up @@ -25,6 +25,7 @@ <h3>Add Roles for Any User</h3>

<hr/>

<py:if test="c.are_any_authz_groups">
<h3>Update Existing Roles for Authorization Groups</h3>

<form id="authzgroup_form" method="POST">
Expand All @@ -40,6 +41,7 @@ <h3>Add Roles for Any Authorization Group</h3>
<button type="submit" name="authz_add" class="btn btn-primary">Add Role</button>
<div class="clear"></div>
</form>
</py:if>

</div>

Expand Down
2 changes: 2 additions & 0 deletions ckan/templates/package/authz.html
Expand Up @@ -25,6 +25,7 @@ <h3>Add Roles for Any User</h3>

<hr/>

<py:if test="c.are_any_authz_groups">
<h3>Update Existing Roles for Authorization Groups</h3>

<form id="authzgroup_form" method="POST">
Expand All @@ -40,6 +41,7 @@ <h3>Add Roles for Any Authorization Group</h3>
<button type="submit" name="authz_add" class="btn btn-primary">Add Role</button>
<div class="clear"></div>
</form>
</py:if>

</div>

Expand Down

0 comments on commit 4049826

Please sign in to comment.