diff options
author | Nicolas Braud-Santoni <nicoo@ffgraz.net> | 2016-08-07 16:39:42 +0200 |
---|---|---|
committer | Nicolas Braud-Santoni <nicoo@ffgraz.net> | 2016-08-07 16:39:42 +0200 |
commit | b6ca062670b342344df08b53fb216db619ef42bc (patch) | |
tree | 7680ac6b407239f6b7272c937e42f688b8de542c /app/controllers/node_controller.rb |
Import legacy manman source
Copied from www.ffgraz.net
Diffstat (limited to 'app/controllers/node_controller.rb')
-rw-r--r-- | app/controllers/node_controller.rb | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/app/controllers/node_controller.rb b/app/controllers/node_controller.rb new file mode 100644 index 0000000..6f827e3 --- /dev/null +++ b/app/controllers/node_controller.rb @@ -0,0 +1,69 @@ +class NodeController < ApplicationController + model :person + + def index + redirect_to :action => "list" + end + + def list + @location = @params[:location] + if @location != nil + @nodes = Node.find(:all, + :conditions => ["location_id = ?", Location.find_by_name(@params[:location]).id], + :order => 'location_id') + else + @nodes = Node.find(:all, :order => 'location_id') + end + end + + def destroy + end + + def edit + @persons = Person.find(:all) + @node = Node.find(params[:id]) + end + + def update + @node = Node.find(params[:id]) + values = params[:node] + if ( session[:person] != @node.location.person ) and ( session[:person].email != 'nine@wirdorange.org' ) + flash[:notice] = 'Sie sind nicht berechtigt.' + redirect_to :back + else if @node.update_attributes(params[:node]) + flash[:notice] = 'Node erfolgreich geaendert' + redirect_to :action => 'show', :controller => 'location', :id => @node.location + else + flash[:notice] = 'Ă„nderung fehlgeschlagen' + redirect_to :action => 'show', :controller => 'location', :id => @node.location + end + end + end + + def new + @persons = Person.find(:all) + @location = Location.find(params[:location]) + @node = Node.new( :location_id => @location.id ) + end + + def do_new + node_values = params[:node] + node_values[:time] = DateTime.now + node_values[:creator_ip] = @request.env["REMOTE_ADDR"] + +# Nets.find(:first, :conditions => + + location = Location.find(node_values[:location_id]) + if ( session[:person] != location.person ) and ( session[:person].email != 'nine@wirdorange.org' ) + flash[:notice] = 'Sie sind nicht berechtigt.' + redirect_to :action => 'show', :controller => 'person', :id => session[:person].id + elsif Node.create_node(node_values) + flash[:notice] = 'Node erfolgreich erzeugt' + redirect_to :action => "show", :controller => "location", :id => node_values[:location_id] + else + flash[:notice] = 'error' + render_text 'error' + end + end +end + |