projects_controller.rb revision 5a17792f701eb630315dfc43937f8af386a52bc7
8900b9eb2514c07047541833286428572493a9fdStéphane Graberclass ProjectsController < InheritedResources::Base
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi belongs_to :ontology, optional: true
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi before_filter :check_read_permissions
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi def create
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi create! do |format|
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if parent
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi parent.projects << resource
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi parent.save
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi end
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi format.html { redirect_to [*resource_chain, :projects] }
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi end
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi end
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi def update
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi update! do |format|
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi format.html { redirect_to [*resource_chain, :projects] }
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi end
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi end
a5ba96715d4ef264c43d4f187251de491ba198c0KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi def destroy
8900b9eb2514c07047541833286428572493a9fdStéphane Graber destroy! do |format|
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi format.html { redirect_to [*resource_chain, :projects] }
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi end
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi end
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
faefa7f8584a7d1567df2e6f1f9240a28a6466abStéphane Graber
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi private
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi def check_read_permissions
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi authorize! :show, parent.repository if parent.is_a? Ontology
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi end
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiend
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi