Skip to content

Commit

Permalink
Merge pull request #8141 from avdata99/hide_invite_if_no_crete
Browse files Browse the repository at this point in the history
Hide invite user form if can't create users
  • Loading branch information
tino097 committed Apr 24, 2024
2 parents a638395 + 22f24ae commit 7287d62
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/8141.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hide invite user form if the user can't create users
2 changes: 1 addition & 1 deletion ckan/templates/group/member_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1 class="page-heading">
</div>
</div>
</div>
{% if not user %}
{% if not user and h.check_access('user_create') %}
<div class="col-md-2">
<div class="add-member-or">
{{ _('or') }}
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/organization/member_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h1 class="page-heading">
</div>
</div>
</div>
{% if not user %}
{% if not user and h.check_access('user_create') %}
<div class="col-md-2">
<div class="add-member-or">
{{ _('or') }}
Expand Down
17 changes: 17 additions & 0 deletions ckan/tests/controllers/test_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,23 @@ def test_organization_search_within_org_no_results(self, app):

@pytest.mark.usefixtures("non_clean_db")
class TestOrganizationMembership(object):

@pytest.mark.ckan_config("ckan.auth.create_user_via_web", False)
def test_admin_users_cannot_invite_members(self, app, user):
""" Org admin users can't invite users if they can't create users """
headers = {"Authorization": user["token"]}
organization = factories.Organization(
users=[{"name": user["name"], "capacity": "admin"}]
)

with app.flask_app.test_request_context():
response = app.get(
url_for("organization.member_new", id=organization["id"]),
headers=headers,
)
assert response.status_code == 200
assert "invite a new user" not in response

def test_editor_users_cannot_add_members(self, app, user):
headers = {"Authorization": user["token"]}
organization = factories.Organization(
Expand Down

0 comments on commit 7287d62

Please sign in to comment.