Skip to content

Commit

Permalink
refs frab#124: filter conference list for crew
Browse files Browse the repository at this point in the history
  • Loading branch information
manno committed Mar 20, 2014
1 parent 1ca4efa commit 0da8819
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def setup_crew_user_abilities
when /orga/
can :manage, CallForPapers
can :manage, Conference
can :manage, Event
can :manage, Event, :conference_id => @conference.id
can :manage, EventFeedback
can :manage, EventRating
can :manage, Person
Expand All @@ -80,7 +80,7 @@ def setup_crew_user_abilities
can :manage, CallForPapers
cannot :destroy, CallForPapers
can :read, Conference
can :manage, Event
can :manage, Event, :conference_id => @conference.id
can :read, EventFeedback
can :manage, EventRating
can :manage, Person
Expand All @@ -91,7 +91,7 @@ def setup_crew_user_abilities
# everything from submitter
can :read, CallForPapers
can :read, Conference
can :read, Event
can :read, Event, conference_id: @conference.id
can :submit, Event
can :read, EventFeedback
can :manage, EventRating, :person_id => @user.person.id
Expand Down
4 changes: 4 additions & 0 deletions app/models/conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class Conference < ActiveRecord::Base

scope :creation_order, order("conferences.created_at DESC")

scope :accessible_by_crew, lambda { |user|
joins(:conference_users).where(conference_users: {user_id: user})
}

def self.current
self.order("created_at DESC").first
end
Expand Down
5 changes: 4 additions & 1 deletion app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
%li.dropdown
= link_to t("switch_conference", :default => "Switch conference"), "#", :class => "dropdown-toggle"
%ul.dropdown-menu
- conferences = Conference.order("created_at DESC")
- if current_user.role == 'crew'
- conferences = Conference.accessible_by_crew(current_user).order("created_at DESC")
- else
- conferences = Conference.order("created_at DESC")
- unless conferences.nil?
- conferences[0..19].each do |conference|
- unless @conference == conference
Expand Down

0 comments on commit 0da8819

Please sign in to comment.