projects_controller.rb revision 80bec0e081f3ea13eec9ef8ea50a9ccbb74fcb46
2326cfd02158fb9217ef3bb4419142f144aa3c0bSascha Graefclass ProjectsController < InheritedResources::Base
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller
b23869f9e7504049f5d28bbbc54d812c8ca36abbEugen Kuksa belongs_to :ontology, optional: true
3f2e11b6294f92d3434551cdbbf10d952a52d478Eugen Kuksa before_filter :check_read_permissions
80bec0e081f3ea13eec9ef8ea50a9ccbb74fcb46Eugen Kuksa load_and_authorize_resource
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller def create
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller create! do |format|
b23869f9e7504049f5d28bbbc54d812c8ca36abbEugen Kuksa if parent
b23869f9e7504049f5d28bbbc54d812c8ca36abbEugen Kuksa parent.projects << resource
b23869f9e7504049f5d28bbbc54d812c8ca36abbEugen Kuksa parent.save
b23869f9e7504049f5d28bbbc54d812c8ca36abbEugen Kuksa end
b23869f9e7504049f5d28bbbc54d812c8ca36abbEugen Kuksa format.html { redirect_to [*resource_chain, :projects] }
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller end
2326cfd02158fb9217ef3bb4419142f144aa3c0bSascha Graef end
3f2e11b6294f92d3434551cdbbf10d952a52d478Eugen Kuksa
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller def update
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller update! do |format|
b23869f9e7504049f5d28bbbc54d812c8ca36abbEugen Kuksa format.html { redirect_to [*resource_chain, :projects] }
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller end
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller end
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller def destroy
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller destroy! do |format|
b23869f9e7504049f5d28bbbc54d812c8ca36abbEugen Kuksa format.html { redirect_to [*resource_chain, :projects] }
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller end
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller end
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller
5b6f49391291b25c13e660ebdfcf80424cf941b2henning mueller private
3f2e11b6294f92d3434551cdbbf10d952a52d478Eugen Kuksa
3f2e11b6294f92d3434551cdbbf10d952a52d478Eugen Kuksa def check_read_permissions
3f2e11b6294f92d3434551cdbbf10d952a52d478Eugen Kuksa authorize! :show, parent.repository if parent.is_a? Ontology
3f2e11b6294f92d3434551cdbbf10d952a52d478Eugen Kuksa end
2326cfd02158fb9217ef3bb4419142f144aa3c0bSascha Graefend