projects_controller.rb revision a5473c6aa130f70a4682a52e38a8a7d0677254b9
507d7a7d023f6fd78445d1d965af26d59523c6eeEugen Kuksaclass ProjectsController < InheritedResources::Base
507d7a7d023f6fd78445d1d965af26d59523c6eeEugen Kuksa
507d7a7d023f6fd78445d1d965af26d59523c6eeEugen Kuksa belongs_to :ontology, optional: true
9b931be64b810ef562077d173028ffbe847be914Eugen Kuksa before_filter :check_read_permissions
9b931be64b810ef562077d173028ffbe847be914Eugen Kuksa load_and_authorize_resource
507d7a7d023f6fd78445d1d965af26d59523c6eeEugen Kuksa
507d7a7d023f6fd78445d1d965af26d59523c6eeEugen Kuksa def create
507d7a7d023f6fd78445d1d965af26d59523c6eeEugen Kuksa create! do |success, failure|
507d7a7d023f6fd78445d1d965af26d59523c6eeEugen Kuksa if parent
507d7a7d023f6fd78445d1d965af26d59523c6eeEugen Kuksa parent.projects << resource
9b931be64b810ef562077d173028ffbe847be914Eugen Kuksa parent.save
9b931be64b810ef562077d173028ffbe847be914Eugen Kuksa end
9b931be64b810ef562077d173028ffbe847be914Eugen Kuksa success.html { redirect_to [*resource_chain, :projects] }
507d7a7d023f6fd78445d1d965af26d59523c6eeEugen Kuksa end
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa end
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa def update
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa update! do |success, failure|
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa success.html { redirect_to [*resource_chain, :projects] }
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa end
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa end
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa def destroy
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa destroy! do |success, failure|
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa success.html { redirect_to [*resource_chain, :projects] }
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa end
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa end
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa private
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa def check_read_permissions
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa authorize! :show, parent.repository if parent.is_a? Ontology
b03747916bb00f7f1d3677cf02d244d25af4ba96Eugen Kuksa end
end