tasks_controller.rb revision 80bec0e081f3ea13eec9ef8ea50a9ccbb74fcb46
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chenclass TasksController < InheritedResources::Base
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen belongs_to :ontology, optional: true
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen before_filter :check_read_permissions
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen load_and_authorize_resource
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen def create
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen create! do |format|
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen if parent
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen parent.tasks << resource
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen parent.save
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen end
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen format.html { redirect_to [*resource_chain, :tasks] }
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen end
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen end
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen def update
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen update! do |format|
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen format.html { redirect_to [*resource_chain, :tasks] }
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen end
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen end
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen def destroy
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen destroy! do |format|
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen format.html { redirect_to [*resource_chain, :tasks] }
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen end
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen end
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen protected
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen def check_read_permissions
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen authorize! :show, parent.repository if parent
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen end
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chenend
0035018c6da861f1b758fb9bf6b50245c52b48e2Raymond Chen