Skip to content

Commit

Permalink
Merge pull request #172 from DMPRoadmap/issue2511
Browse files Browse the repository at this point in the history
fixed issue with being unable to grant user specific permission to ch…
  • Loading branch information
briri authored May 13, 2020
2 parents be2a7de + 1a2c48e commit 592fe47
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/controllers/org_admin/templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def organisational
.where(customization_of: nil, org_id: current_user.org.id)
published = templates.select { |t| t.published? || t.draft? }.length

@orgs = current_user.can_super_admin? ? Org.all : nil
@orgs = current_user.can_change_org? ? Org.all : nil
@title = if current_user.can_super_admin?
_("%{org_name} Templates") % { org_name: current_user.org.name }
else
Expand Down
15 changes: 9 additions & 6 deletions app/javascript/views/usage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ $(() => {

// attach listener to separator select menu
// on change look for "stat" elements and chnage their query param
document.getElementById('csv-field-sep').addEventListener('click', (e) => {
const statElems = document.getElementsByClassName('stat');
const newSep = 'sep='.concat(encodeURIComponent(e.target.value));
const changeStatFn = changeStatFnGen(newSep);
Array.from(statElems).forEach(changeStatFn);
});
const fieldSep = document.getElementById('csv-field-sep');
if (fieldSep !== null) {
fieldSep.addEventListener('click', (e) => {
const statElems = document.getElementsByClassName('stat');
const newSep = 'sep='.concat(encodeURIComponent(e.target.value));
const changeStatFn = changeStatFnGen(newSep);
Array.from(statElems).forEach(changeStatFn);
});
}

initializeCharts();

Expand Down
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ def identifier_for(scheme)
user_identifiers.where(identifier_scheme: scheme).first
end

# Checks if the user is a super admin. If the user has any privelege which requires
# Checks if the user is a super admin. If the user has ALL privelege which requires
# them to see the super admin page then they are a super admin.
#
# Returns Boolean
def can_super_admin?
self.can_add_orgs? || self.can_grant_api_to_orgs? || self.can_change_org?
can_add_orgs? && can_grant_api_to_orgs? && can_change_org?
end

# Checks if the user is an organisation admin if the user has any privlege which
Expand Down
2 changes: 1 addition & 1 deletion app/policies/user_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def admin_update_permissions?

# Allows the user to swap their org affiliation on the fly
def org_swap?
signed_in_user.can_super_admin?
signed_in_user.can_change_org?
end

def activate?
Expand Down
4 changes: 2 additions & 2 deletions app/views/org_admin/templates/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h1><%= _('Templates') %></h1>
</div>

<% if current_user.can_super_admin? %>
<% if current_user.can_change_org? %>
<div class="col-md-12">
<p>
<%= _('If you would like to modify one of the templates below, you must first change your organisation affiliation.') %>
Expand Down Expand Up @@ -117,4 +117,4 @@
</a>

</div>
</div>
</div>

0 comments on commit 592fe47

Please sign in to comment.