axioms_controller.rb revision 7ea3e78d7552d1ec2d21efac4e14ace1a20f3975
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa#
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa# Lists axioms of an ontology
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa#
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksaclass AxiomsController < InheritedResources::Base
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa belongs_to :ontology
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa actions :index
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa has_pagination
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa respond_to :html, only: %i(index)
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa before_filter :check_read_permissions
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa protected
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa def check_read_permissions
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa authorize! :show, parent.repository
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa end
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa def collection
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa @collection ||=
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa if display_all?
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa axioms =
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa if logically_translated?
2451e29ef5965551cab4c1f0cb579b87506f71e1Eugen Kuksa parent.axioms
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa else
bb90b28cdc65a2e18bda6ae833d16fc0bd48a823Eugen Kuksa parent.translated_axioms
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa end
7ea3e78d7552d1ec2d21efac4e14ace1a20f3975Eugen Kuksa Kaminari.paginate_array(axioms).page(params[:page]).
7ea3e78d7552d1ec2d21efac4e14ace1a20f3975Eugen Kuksa per(params[:per_page])
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa else
7ea3e78d7552d1ec2d21efac4e14ace1a20f3975Eugen Kuksa Kaminari.paginate_array(parent.axioms.original).page(params[:page]).
7ea3e78d7552d1ec2d21efac4e14ace1a20f3975Eugen Kuksa per(params[:per_page])
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa end
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa end
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa def logically_translated?
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa parent.contains_logic_translations?
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa end
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksa helper_method :logically_translated?
9682ce7cd0be309474550ba9d8fb97585d3facc3Eugen Kuksaend