mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Add authorization for toggle_favorite and rename route
This commit is contained in:
parent
2485923319
commit
91629d9b92
5 changed files with 11 additions and 5 deletions
|
|
@ -6,7 +6,8 @@ class ProposalsController < ApplicationController
|
|||
load_resource :program, through: :conference, singleton: true
|
||||
load_and_authorize_resource :event, parent: false, through: :program
|
||||
# We authorize manually in these actions
|
||||
skip_authorize_resource :event, only: [:confirm, :restart, :toogle_favorite, :withdraw]
|
||||
skip_authorize_resource :event, only: [:confirm, :restart, :withdraw]
|
||||
|
||||
|
||||
def index
|
||||
@event = @program.events.new
|
||||
|
|
@ -85,7 +86,8 @@ class ProposalsController < ApplicationController
|
|||
render action: 'edit'
|
||||
end
|
||||
end
|
||||
def toogle_favorite
|
||||
|
||||
def toggle_favorite
|
||||
user = User.find(params[:favourite_user_id])
|
||||
users = @event.favourite_users
|
||||
if users.include? user
|
||||
|
|
|
|||
|
|
@ -108,6 +108,10 @@ class Ability
|
|||
event.users.include?(user)
|
||||
end
|
||||
|
||||
can :toggle_favorite, Event do |event|
|
||||
event.scheduled?
|
||||
end
|
||||
|
||||
# can manage the commercials of their own events
|
||||
can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
= link_to('#', onClick: 'starClicked();') do
|
||||
%span#star-events{ class: "fa fa-lg #{ event.favourite_users.exists?(current_user.id) ? 'fa-star' : 'fa-star-o' }", |
|
||||
"aria-hidden" => "true", |
|
||||
"data-url" => toogle_favorite_conference_program_proposal_path(@conference.short_title, event.id), |
|
||||
"data-url" => toggle_favorite_conference_program_proposal_path(@conference.short_title, event.id), |
|
||||
"data-user" => current_user.id }
|
||||
%span.h3
|
||||
= event.title
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
= link_to('#', onClick: 'starClicked();') do
|
||||
%span#star{ class: "fa fa-lg #{ event.favourite_users.exists?(current_user.id) ? 'fa-star' : 'fa-star-o' }", |
|
||||
"aria-hidden" =>"true", |
|
||||
"data-url" => toogle_favorite_conference_program_proposal_path(@conference.short_title, event.id), |
|
||||
"data-url" => toggle_favorite_conference_program_proposal_path(@conference.short_title, event.id), |
|
||||
"data-user" => current_user.id }
|
||||
= event.title
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ Osem::Application.routes.draw do
|
|||
patch '/withdraw' => 'proposals#withdraw'
|
||||
patch '/confirm' => 'proposals#confirm'
|
||||
patch '/restart' => 'proposals#restart'
|
||||
patch :toogle_favorite
|
||||
patch :toggle_favorite
|
||||
end
|
||||
end
|
||||
resources :tracks, except: :destroy do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue