SQL optimisation rolled back. It lead to access problems.

This commit is contained in:
Christoph Haas 2021-03-01 02:07:55 +01:00
parent 7227f769c0
commit 2b24083653
5 changed files with 15 additions and 19 deletions

View file

@ -33,6 +33,12 @@ class Ability
# https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
if user.present? # Logged-in users
# Allow to view all public/approved screenshots
can :view, Screenshot, approved: true
# Allow to view any own uploads (even not-yet-approved)
can :view, Screenshot, user_id: user.id
can :destroy, Screenshot, user_id: user.id
if user.admin_role?
can :approve, Screenshot
can :destroy, Screenshot
@ -45,12 +51,6 @@ class Ability
can :view, Screenshot
can :destroy, Screenshot
end
if user.pseudo?
# Allow to view all public/approved screenshots
can :view, Screenshot, approved: true
# Allow to view any own uploads (even not-yet-approved)
can :view, Screenshot, user_id: user.id
end
else # Nobody logged in
can :view, Screenshot, approved: true
end

View file

@ -57,7 +57,7 @@ class Package < ApplicationRecord
end
# Return a query of all packages that have screenshots
# Return a query of all packages that do not have screenshots
def self.without_screenshots
# Query for all packages who's ID does not appear in a screenshot's "package_id" field
subselect = Screenshot.select(:package_id)