Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Cleanup file ; see previous commit for annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
emcoding committed May 17, 2018
1 parent bfaeb99 commit f6da595
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 441 deletions.
4 changes: 1 addition & 3 deletions app/controllers/conferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ def show
end

def create
byebug
# page_to_redirect = current_user.admin? ? conferences_path : edit_team_path(current_student.current_team)
page_to_redirect = conferences_path
page_to_redirect = current_user.admin? ? conferences_path : edit_team_path(current_student.current_team)
@conference = build_conference

respond_to do |format|
Expand Down
24 changes: 4 additions & 20 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ def initialize(user)
alias_action :create, :read, :update, :destroy, to: :crud

# guest user
can :read, Activity # pro forma ; Activity has no authorisation restriction, except for kind: :mailing
can :read, [User, Team, Project, Conference]
can :read, [Activity, User, Team, Project, Conference]

return unless signed_in?(user)

Expand All @@ -26,12 +25,6 @@ def initialize(user)
can :resend_confirmation_instruction, User, id: user.id
can :create, Project
can [:join, :create], Team
# the validation is tested in spec/models/team_spec.rb:33
# Should this be in ability at all?
# can :crud, Team do |team|
# team.new_record?
# end
# => delete
can :index, Mailing
can :read, Mailing do |mailing|
mailing.recipient? user
Expand All @@ -42,23 +35,15 @@ def initialize(user)
on_team?(user, team)
end

# Add / split restrictions for current season?

# current_student
if user.current_student? # TODO is this the best check?
if user.current_student? # TODO is this a valid check?
can :create, Team if user.teams.none?
can :create, Conference
end

# supervisor
if user.supervisor?
can :read, :users_info
# explanation for this simpler declaration:
# The unconfirmed user ^ above had this declaration:
# `can :read_email, User, hide_email: false`
# is defined for all users: all can read an email address that is not hidden
# Here, the hide_email attribute doesnt matter: a supervisor can read it anyway
# See specs added to check this behaviour
can :read_email, User do |other_user|
supervises?(other_user, user)
end
Expand All @@ -77,8 +62,7 @@ def initialize(user)
cannot :create, User # this only happens through GitHub
end

################# OLD FILE, # = moved to or rewritten above ############
# NOT everything moved yet #
################# REMAININGS FROM OLD FILE, # = rewritten above ############

# can :crud, Team do |team|
# user.admin? || signed_in?(user) && team.new_record? || on_team?(user, team)
Expand All @@ -99,7 +83,7 @@ def initialize(user)
# cannot :create, Team do |team|
# on_team_for_season?(user, team.season) || !user.confirmed?
# end
# todo join helpdesk team
# todo helpdesk team join
can :join, Team do |team|
team.helpdesk_team? and signed_in?(user) and user.confirmed? and not on_team?(user, team)
end
Expand Down
Loading

0 comments on commit f6da595

Please sign in to comment.