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 |
Import legacy manman source
Copied from www.ffgraz.net
Diffstat (limited to 'app')
52 files changed, 1276 insertions, 0 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb new file mode 100644 index 0000000..30f98da --- /dev/null +++ b/app/controllers/application.rb @@ -0,0 +1,16 @@ +# Filters added to this controller will be run for all controllers in the application. +# Likewise, all the methods added will be available for all controllers. +class ApplicationController < ActionController::Base + before_filter :authenticate, :except => [ :login, :sign_on, :register, :create, :revoke_pass, :do_revoke, :smokeping, :all ] + + +protected + def authenticate + #session[:url] = url_for + session[:url] = request.env["REQUEST_URI"] + unless session[:person] + redirect_to :controller => 'person', + :action => 'login' + end + end +end diff --git a/app/controllers/export_controller.rb b/app/controllers/export_controller.rb new file mode 100644 index 0000000..5d2ef85 --- /dev/null +++ b/app/controllers/export_controller.rb @@ -0,0 +1,38 @@ +class ExportController < ApplicationController + def smokeping + @locations = Location.find(:all, :order => "name") + if @locations != nil + text = "" + @locations.each do |location| + @nodes = Node.find(:all, :conditions => { :location_id => location.id, :smokeping => true } ) + if @nodes != nil and not @nodes.empty? + text += "++ #{location.name}\n" + text += "menu = #{location.name}\n" + text += "title = #{location.name} connectivity\n" + @nodes.each do |node| + text += "+++ #{node.name}\n" + text += "menu = #{node.name}\n" + text += "title = #{node.name} connectivity\n" + # prefer interfaces named wifi, even if they are not the first in the list + ip = Ip.find(:first, :conditions => ["node_id = ? AND name like ?", node.id, 'wifi%']) + if ip != nil + text += "host = #{ip.ip}\n" + else + # no 'wifi' interface found, use any old interface... + ip = Ip.find(:first, :conditions => ["node_id = ?", node.id]) + if ip != nil + text += "host = #{ip.ip}\n" + end + end + end + end + end + render_text text + end + end + + def all + @locations = Location.find(:all, :order => "name") + render :layout => false + end +end diff --git a/app/controllers/location_controller.rb b/app/controllers/location_controller.rb new file mode 100644 index 0000000..0d2a64c --- /dev/null +++ b/app/controllers/location_controller.rb @@ -0,0 +1,109 @@ +class LocationController < ApplicationController +# model :person, :location + + def index + redirect_to :action => "list" + end + + def list + @person = @params[:person] + if @person != nil + @locations = Location.find(:all, + :conditions => ["person_id = ?", Person.find(:first, + :conditions => { :email => @person }).id], + :order => "name" ) + else + @locations = Location.find(:all, :order => 'name' ) + end + end + + + def edit + @location = Location.find(params[:id]) + @persons = Person.find(:all) + if ( session[:person] != @location.person ) and ( session[:person].email != 'nine@wirdorange.org' ) + flash[:notice] = 'Sie haben nicht die Berechtigung hierfür.' + redirect_to :back + end + end + + def update + @location = Location.find(params[:id]) + values = params[:location] + values[:time] = DateTime.now + if @location.update_attributes(params[:location]) + flash[:notice] = 'Location wurde erfolgreich upgedatet.' + redirect_to :action => 'show', :id => @location + else + flash[:notice] = 'Keine Änderung möglich.' + redirect_to :action => 'edit', :id => @location + end + end + + def destroy + render_text 'aktion nicht verfügbar' + end + + # show inforomation of location + # parameters: + # id = location_id + def show + begin + + @location = Location.find(params[:id]) + @person = @location.person + @nodes = Node.find(:all, :conditions => ["location_id=?", params[:id]] ) + @nets = Nets.find(:all, :conditions => ["location_id=?", params[:id]] ) + @googlemap = 'https://karte.graz.funkfeuer.at/?' + @googlemap += "lng=#{@location.lon}" + @googlemap += "&lat=#{@location.lat}" + @googlemap += "&res=17" + @googlemap += "&marker=all" + + rescue ActiveRecord::RecordNotFound + flash[:notice] = "Error, Location with ID #{params[:id]} not found!" + redirect_to :action => 'list' + end + end + + # display 'new location' form + def new + begin + if params[:c] == nil or params[:r] == nil or params[:z_x] == nil or params[:z_y] == nil + @location = Location.new(:pixel_x => params[:x], :pixel_y => params[:y] ) + else + x = params[:c].to_i * 100 + params[:z_x].to_i; + if x < 0 + x += 100; + end + @location = Location.new(:pixel_x => x , + :pixel_y => params[:r].to_i * 100 + params[:z_y].to_i ) + end + end + end + + + # create new location + def create + begin + values = params[:location] + values[:time] = DateTime.now + values[:creator_ip] = @request.env["REMOTE_ADDR"] + + + values[:person_id] = session[:person].id + + @location = Location.new(values) + if @location.save + flash[:notice] = 'Location gespeichert' + redirect_to :action => 'show', :id => @location + else + flash[:notice] = 'Location nicht gespeichert, bitte ueberpruefen Sie Ihre Eingabe' + redirect_to :back + end + end + end +end + + + diff --git a/app/controllers/net_controller.rb b/app/controllers/net_controller.rb new file mode 100644 index 0000000..a65e7c1 --- /dev/null +++ b/app/controllers/net_controller.rb @@ -0,0 +1,3 @@ +class NetController < ApplicationController + model :person +end 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 + diff --git a/app/controllers/person_controller.rb b/app/controllers/person_controller.rb new file mode 100644 index 0000000..43cecb9 --- /dev/null +++ b/app/controllers/person_controller.rb @@ -0,0 +1,177 @@ + + +class PersonController < ApplicationController +# model :location, :person + +# before_filter :validate_person, :only => [:edit, :update, :do_change_pass] + + @person = '' + + def login + if session[:person] + reset_session + end + end + + def sign_on + person = Person.authenticate( params[:person][:email], + params[:person][:password]) + + if person + session[:person] = person + if session[:url] + redirect_to session[:url] + else + redirect_to :controller => "person", :action => "show", :id => session[:person].id + end + session[:url] = nil + else + flash[:notice] = "Login fehlgeschlagen." + redirect_to :action => "login" + end + end + + def logout + reset_session + redirect_to :action => "login" + end + def login + end + + def index + redirect_to :action => "list" + end + + # list all persons + def list + @persons = Person.find(:all, :order => :email ) + end + + # show information about a person + def show + begin + @person = Person.find(params[:id]) + + @locations = Location.find(:all, + :conditions => ["person_id = ?", params[:id]] ) + + rescue ActiveRecord::RecordNotFound + render_text "Error, Person not found" + end + end + + # edit a specific person identified by param person id + def edit + @person = Person.find(params[:id]) + if session[:person] != @person and session[:person].email != 'nine@wirdorange.org' + flash[:notice] = 'Sie haben nicht die Berechtigung hierfür.' + redirect_to :back + end + end + + # update the information about a person identified by person id + def update + @person = Person.find(params[:id]) + if session[:person] != @person and session[:person].email != 'nine@wirdorange.org' + flash[:notice] = 'Sie haben nicht die Berechtigung hierfür.' + redirect_to :back + else + if @person.update_attributes(params[:person]) + flash[:notice] = 'Person wurde erfolgreich upgedatet.' + redirect_to :action => 'show', :id => @person + else + flash[:notice] = 'Person wurde NICHT verändert.' + redirect_to :action => 'edit', :id => @person + end + end + end + + def register + end + + # create new person record + def create + if params[:password] == params[:password2] + values = params[:person] + values[:password] = params[:password] + @person = Person.new(values) + @person.password = params[:person][:password] + if @person.save + flash[:notice] = 'Person erfolgreich registriert' + redirect_to :action => 'show', :id => @person + else + params[:person][:password2] = ""; + params[:person][:password] = ""; + render :action => 'register', :person => params[:person] + end + else + flash[:notice] = 'Bitte überprüfen Sie ihre Eingabe' + render :action => 'register', :person => params[:person] + end + end + + # revoke password form + def revoke_pass + reset_session + end + + # generate new password and mail to the poor guy + def do_revoke + password = newpass( 8 ) + @person = Person.find( :first, + :conditions => [ "email = ?", params[:person][:email] ] ) + if @person == nil + flash[:notice] = 'Die angegebene Email Adresse ist nicht registriert.' + redirect_to :action => 'revoke_pass' + elsif @person.update_attribute( 'password', password ) + mail = PasswordMailer.deliver_password( @person, password ) + flash[:notice] = 'Ihr neues Passwort wird Ihnen via email zugesendet.' + redirect_to :action => 'login' + else + render :action => 'revoke_pass' + end + end + + def change_pass + @person = Person.find(params[:id]) + if session[:person] != @person + flash[:notice] = 'Sie haben nicht die Berechtigung hierfür.' + redirect_to :back + end + end + + def do_change_pass + person = Person.find( :first, :conditions => + [ "email = BINARY ? AND password = BINARY ?", + session[:person][:email], + Digest::MD5.hexdigest(params[:oldpassword]) ] ) + if person and params[:password] == params[:password2] + person.update_attribute( 'password', params[:password] ) + flash[:notice] = 'Ihr Passwort wurde geaendert.' + redirect_to :action => 'show', :id => session[:person][:id] + else + flash[:notice] = 'Ihr altes Passwort wurde falsch eingegeben.' + redirect_to :back + end + end + + +protected + # validate rights of person + def validate_person + if session[:person] != @person + flash[:notice] = 'Sie sind leider nicht berechtigt!' + redirect_to :back + end + end + +private + # generate alphanumeric password + def newpass( len ) + chars = ("a".."z").to_a + ("A".."Z").to_a + ("1".."9").to_a + newpass = "" + 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] } + return newpass + end + +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000..ebf937a --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,11 @@ +# Methods added to this helper will be available to all templates in the application. +module ApplicationHelper + def ifnil(value=nil) + yield + rescue NoMethodError + raise unless $!.message =~ /:NilClass$/ + value + end + + +end diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb new file mode 100644 index 0000000..34acf5f --- /dev/null +++ b/app/helpers/export_helper.rb @@ -0,0 +1,2 @@ +module ExportHelper +end diff --git a/app/helpers/location_helper.rb b/app/helpers/location_helper.rb new file mode 100644 index 0000000..16aee7c --- /dev/null +++ b/app/helpers/location_helper.rb @@ -0,0 +1,3 @@ +module LocationHelper + +end diff --git a/app/helpers/net_helper.rb b/app/helpers/net_helper.rb new file mode 100644 index 0000000..908cd46 --- /dev/null +++ b/app/helpers/net_helper.rb @@ -0,0 +1,2 @@ +module NetHelper +end diff --git a/app/helpers/node_helper.rb b/app/helpers/node_helper.rb new file mode 100644 index 0000000..ff049b0 --- /dev/null +++ b/app/helpers/node_helper.rb @@ -0,0 +1,2 @@ +module NodeHelper +end diff --git a/app/helpers/person_helper.rb b/app/helpers/person_helper.rb new file mode 100644 index 0000000..f5c74cd --- /dev/null +++ b/app/helpers/person_helper.rb @@ -0,0 +1,2 @@ +module PersonHelper +end diff --git a/app/models/admin.rb b/app/models/admin.rb new file mode 100644 index 0000000..7cd133e --- /dev/null +++ b/app/models/admin.rb @@ -0,0 +1,5 @@ +class Admin < ActiveRecord::Base + set_table_name "admin" + has_many :person + +end diff --git a/app/models/ip.rb b/app/models/ip.rb new file mode 100644 index 0000000..c647078 --- /dev/null +++ b/app/models/ip.rb @@ -0,0 +1,5 @@ +class Ip < ActiveRecord::Base + set_table_name "ip" + belongs_to :node, :foreign_key => "node_id" + belongs_to :nets, :foreign_key => 'net_id' +end diff --git a/app/models/location.rb b/app/models/location.rb new file mode 100644 index 0000000..5171e5d --- /dev/null +++ b/app/models/location.rb @@ -0,0 +1,38 @@ +class Location < ActiveRecord::Base + set_table_name "location" + belongs_to :person + belongs_to :town + belongs_to :nets + has_many :node + + validates_presence_of :name, :person_id + validates_uniqueness_of :name + + validates_format_of :name, + :with => /^([0-9a-z]*)$/, + :on => :create + validates_format_of :name, + :with => /^([0-9a-z]*)$/, + :on => :save + + @@x_zero = 4080 + @@lon_zero = 15.43844103813 + @@dx_dlon = 50675.5176 + @@y_zero = 4806 + @@lat_zero = 47.07177327969 + @@dy_dlat = 75505.521 + + def lon + @@lon_zero + (self.pixel_x.to_f - @@x_zero) / @@dx_dlon + end + + def lat + @@lat_zero + (@@y_zero - self.pixel_y.to_f) / @@dy_dlat + end + + def comment + # nl2br + read_attribute(:comment).gsub("\n\r","<br>").gsub("\r", "").gsub("\n", "<br />") + end + +end diff --git a/app/models/nets.rb b/app/models/nets.rb new file mode 100644 index 0000000..59f43c6 --- /dev/null +++ b/app/models/nets.rb @@ -0,0 +1,10 @@ +class Nets < ActiveRecord::Base + set_table_name "net" + belongs_to :location + belongs_to :nettype + has_many :ip + + validates_presence_of :netip, :netmask + #validates_uniqueness_of :netip + +end diff --git a/app/models/node.rb b/app/models/node.rb new file mode 100644 index 0000000..d57b6b9 --- /dev/null +++ b/app/models/node.rb @@ -0,0 +1,28 @@ +require "mysql" + +class Node < ActiveRecord::Base + set_table_name "node" + belongs_to :location + belongs_to :person + has_many :ip + + validates_presence_of :name, :location_id + validates_uniqueness_of :name, :scope => 'location_id' + + validates_format_of :name, + :with => /^([0-9a-z]*)$/, + :on => :create + validates_format_of :name, + :with => /^([0-9a-z]*)$/, + :on => :save + + + def comment + # nl2br + read_attribute(:comment).gsub("\n\r","<br>").gsub("\r", "").gsub("\n", "<br />") + end + + def self.create_node(params) + Node.create(params) + end +end diff --git a/app/models/password_mailer.rb b/app/models/password_mailer.rb new file mode 100644 index 0000000..bf2fe82 --- /dev/null +++ b/app/models/password_mailer.rb @@ -0,0 +1,12 @@ +class PasswordMailer < ActionMailer::Base + + def password(person, password, sent_at = Time.now) + @subject = 'New Password' + @body = { :person => person, :password => password } + @recipients = person.email + @from = 'noreply@graz.funkfeuer.at' + @sent_on = sent_at + @headers = {} + end + +end diff --git a/app/models/person.rb b/app/models/person.rb new file mode 100644 index 0000000..26fa61f --- /dev/null +++ b/app/models/person.rb @@ -0,0 +1,48 @@ +require "digest/md5" + +class Person < ActiveRecord::Base + set_table_name "person" + belongs_to :admin + has_many :location + + attr_protected :password + + validates_presence_of :email, :password, :firstname, :lastname + validates_uniqueness_of :email + + validates_format_of :email, + :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i , + :on => :create + + + # operator overloading for updating passwords + def password=(str) + write_attribute(:password, Digest::MD5.hexdigest(str)) + end + + + def self.authenticate(user_name, password) + return Person.find( :first, :conditions => + ["email = BINARY ? AND password = BINARY ?", + user_name, + Digest::MD5.hexdigest(password)] ) + end + + def self.revoke_pass(email) + password = newpass( 8 ) + person = Person.find( :first, + :conditions => [ "email = ?", email] ) + # + + end + +private + # generate alphanumeric password + def newpass( len ) + chars = ("a".."z").to_a + ("A".."Z").to_a + ("1".."9").to_a + newpass = "" + 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] } + return newpass + end + +end diff --git a/app/views/export/all.rxml b/app/views/export/all.rxml new file mode 100644 index 0000000..d1aa10e --- /dev/null +++ b/app/views/export/all.rxml @@ -0,0 +1,31 @@ +xml.instruct! :xml, :version=>"1.0" + +xml.network{ + for location in @locations + xml.location do + xml.name(location.name) + xml.street(location.street) + xml.streetnr(location.streetnr) + xml.comment(location.comment) + xml.gallery(location.gallery_link) + xml.lat(location.lat) + xml.lon(location.lon) + + for node in location.node + xml.node do + xml.name(node.name) + xml.comment(node.comment) + + for ip in node.ip + xml.ip do + xml.name(ip.name) + xml.address(ip.ip) + xml.dns("#{ip.name}.#{node.name}.#{location.name}") + end + end + + end + end + end + end +} diff --git a/app/views/layouts/ip.rhtml b/app/views/layouts/ip.rhtml new file mode 100644 index 0000000..ad4cb1b --- /dev/null +++ b/app/views/layouts/ip.rhtml @@ -0,0 +1,13 @@ +<html> +<head> + <title>Ip: <%= controller.action_name %></title> + <%= stylesheet_link_tag 'scaffold' %> +</head> +<body> + +<p style="color: green"><%= flash[:notice] %></p> + +<%= @content_for_layout %> + +</body> +</html> diff --git a/app/views/layouts/location.rhtml b/app/views/layouts/location.rhtml new file mode 100644 index 0000000..a3fb66d --- /dev/null +++ b/app/views/layouts/location.rhtml @@ -0,0 +1,13 @@ +<html> +<head> + <title>Location: <%= controller.action_name %></title> + <%= stylesheet_link_tag 'scaffold' %> +</head> +<body> + +<p style="color: green"><%= flash[:notice] %></p> + +<%= yield %> + +</body> +</html> diff --git a/app/views/layouts/nettype.rhtml b/app/views/layouts/nettype.rhtml new file mode 100644 index 0000000..46e2cf5 --- /dev/null +++ b/app/views/layouts/nettype.rhtml @@ -0,0 +1,13 @@ +<html> +<head> + <title>Nettype: <%= controller.action_name %></title> + <%= stylesheet_link_tag 'scaffold' %> +</head> +<body> + +<p style="color: green"><%= flash[:notice] %></p> + +<%= @content_for_layout %> + +</body> +</html> diff --git a/app/views/layouts/node.rhtml b/app/views/layouts/node.rhtml new file mode 100644 index 0000000..1a9af20 --- /dev/null +++ b/app/views/layouts/node.rhtml @@ -0,0 +1,13 @@ +<html> +<head> + <title>Node: <%= controller.action_name %></title> + <%= stylesheet_link_tag 'scaffold' %> +</head> +<body> + +<p style="color: green"><%= flash[:notice] %></p> + +<%= @content_for_layout %> + +</body> +</html> diff --git a/app/views/layouts/person.rhtml b/app/views/layouts/person.rhtml new file mode 100644 index 0000000..0e7102e --- /dev/null +++ b/app/views/layouts/person.rhtml @@ -0,0 +1,13 @@ +<html> +<head> + <title>Person: <%= controller.action_name %></title> + <%= stylesheet_link_tag 'scaffold' %> +</head> +<body> + +<p style="color: green"><%= flash[:notice] %></p> + +<%= yield %> + +</body> +</html> diff --git a/app/views/layouts/wlparm.rhtml b/app/views/layouts/wlparm.rhtml new file mode 100644 index 0000000..9dfd37a --- /dev/null +++ b/app/views/layouts/wlparm.rhtml @@ -0,0 +1,13 @@ +<html> +<head> + <title>Wlparm: <%= controller.action_name %></title> + <%= stylesheet_link_tag 'scaffold' %> +</head> +<body> + +<p style="color: green"><%= flash[:notice] %></p> + +<%= @content_for_layout %> + +</body> +</html> diff --git a/app/views/location/_form.rhtml b/app/views/location/_form.rhtml new file mode 100644 index 0000000..c391f62 --- /dev/null +++ b/app/views/location/_form.rhtml @@ -0,0 +1,34 @@ +<%= error_messages_for 'location' %> + +<!--[form:location]--> +<p><label for="location_pixel_x">Pixel x</label><br/> +<%= text_field 'location', 'pixel_x' %></p> + +<p><label for="location_pixel_y">Pixel y</label><br/> +<%= text_field 'location', 'pixel_y' %></p> + +<p><label for="location_gps_lon">Gps lon</label><br/> +<%= text_field 'location', 'gps_lon' %></p> + +<p><label for="location_gps_lat">Gps lat</label><br/> +<%= text_field 'location', 'gps_lat' %></p> + +<p><label for="location_name">Name</label><br/> +<%= text_field 'location', 'name' %></p> + +<p><label for="location_street">Street</label><br/> +<%= text_field 'location', 'street' %></p> + +<p><label for="location_number">Number</label><br/> +<%= text_field 'location', 'number' %></p> + +<p><label for="location_creator_ip">Creator ip</label><br/> +<%= text_field 'location', 'creator_ip' %></p> + +<p><label for="location_time">Time</label><br/> +<%= datetime_select 'location', 'time' %></p> + +<p><label for="location_comment">Comment</label><br/> +<%= text_field 'location', 'comment' %></p> +<!--[eoform:location]--> + diff --git a/app/views/location/_plist.rhtml b/app/views/location/_plist.rhtml new file mode 100644 index 0000000..be4d644 --- /dev/null +++ b/app/views/location/_plist.rhtml @@ -0,0 +1,19 @@ +<table> + <th>Name</th> + <th>Strasse</th> + <th>Hausnr.</th> + <th>Kommentar</th> + +<% @locations.each do |location| %> + <tr> + <td><%= location.name %></td> + <td><%= location.street %></td> + <td><%= location.streetnr %></td> + <td><%= location.comment %></td> + <td><%= link_to 'Show', :action => 'show', :controller => 'location', :id => location %></td> + <td><%= link_to 'Edit', :action => 'edit', :controller => 'location', :id => location %></td> + <td><%= link_to 'Destroy', { :action => 'destroy', :controller => 'location', :id => location }, :confirm => 'Are you sure?', :post => true %></td> + </tr> +<% end %> +</table> + diff --git a/app/views/location/_pshow.rhtml b/app/views/location/_pshow.rhtml new file mode 100644 index 0000000..b1b042a --- /dev/null +++ b/app/views/location/_pshow.rhtml @@ -0,0 +1,29 @@ + +<% if @location != nil %> +<table> + <tr> + <td>Name:</td><td><%= @location.name %></td> + </tr> + <tr> + <td>Strasse:</td><td><%= @location.street %></td> + <tr> + <td>Hausnr.:</td><td><%= @location.streetnr %></td> + </tr> + <tr> + <td>Kommentar:</td><td><%= @location.comment %></td> + </tr> + <tr> + <td>changed:</td><td><%= @location.time %></td> + </tr> + <tr> + <td>Links:</td> + <td> + <%= link_to('Smokeping','http://stats.ffgraz.net/smokeping/index.cgi?target=Funkfeuer.' + @location.name) %><br /> + <% if @location.gallery_link != nil %> + <%= link_to 'Gallery', @location.gallery_link %><br /> + <% end %> + <%= link_to 'google maps', @googlemap %><br /></td> + </tr> +</table> +<p><%= link_to 'Edit', { :action => 'edit', :id => @location.id } %> +<% end %> diff --git a/app/views/location/edit.rhtml b/app/views/location/edit.rhtml new file mode 100644 index 0000000..20796b7 --- /dev/null +++ b/app/views/location/edit.rhtml @@ -0,0 +1,40 @@ +<%= render :partial => "person/nav" %> + +<h1>Location</h1> +<%= form_tag :action => 'update', :id => @location %> + <table> + <tr> + <td>Name</td><td><%= text_field 'location', 'name' %></td> + </tr> + <tr> + <td>Strasse</td><td><%= text_field 'location', 'street' %></td> + </tr> + <tr> + <td>Hausnummer</td><td><%= text_field 'location', 'streetnr' %></td> + </tr> + <tr> + <td>Kommentar</td><td><%= text_field 'location', 'comment' %></td> + </tr> + <tr> + <td>Administrator</td><td> + <select name="location[person_id]"> + <option value="0"> - </option + <% @persons.each do |person| %> + <option value="<%= person.id %>" + <%= ' selected' if @location.person != nil && person.id == @location.person.id %>> + <%= person.email %> + </option> + <% end %> + </select> + </td> + </tr> + <tr> + <td>Gallery</td><td><%= text_field 'location', 'gallery_link' %></td> + </tr> + </table> + <%= submit_tag 'Edit' %> +<%= end_form_tag %> + +<%= link_to 'Show', :action => 'show', :id => @location %> | +<%= link_to 'Back', :action => 'list' %> + diff --git a/app/views/location/list.rhtml b/app/views/location/list.rhtml new file mode 100644 index 0000000..1307dfa --- /dev/null +++ b/app/views/location/list.rhtml @@ -0,0 +1,4 @@ +<%= render :partial => "person/nav" %> +<h1>Locations</h1> +<%= render :partial => "plist", :object => @locations %> + diff --git a/app/views/location/new.rhtml b/app/views/location/new.rhtml new file mode 100644 index 0000000..60b5d2a --- /dev/null +++ b/app/views/location/new.rhtml @@ -0,0 +1,25 @@ +<%= render :partial => "person/nav" %> + +<h1>New Location</h1> + +<%= start_form_tag :action => 'create', :id => @location %> + <table> + <tr> + <td>Name</td><td><%= text_field 'location', 'name' %>*</td> + </tr> + <tr> + <td>Strasse</td><td><%= text_field 'location', 'street' %></td> + </tr> + <tr> + <td>Hausnr.</td><td><%= text_field 'location', 'streetnr' %></td> + </tr> +<td>Kommentar</td><td><%= text_area 'location', 'comment' %></td> + <%= hidden_field 'location', 'pixel_x' %> + <%= hidden_field 'location', 'pixel_y' %> + </tr> + </table> + <%= submit_tag 'Create' %> +<%= end_form_tag %> + +<p>Bitte Felder mit <strong>*</strong> eintragen</p> +<p>Unter <strong>Name</strong> bitte nur Kleinbuchstaben und Ziffern <strong>ohne</ohne> Leerzeichen eintragen</p> diff --git a/app/views/location/show.rhtml b/app/views/location/show.rhtml new file mode 100644 index 0000000..2666ff0 --- /dev/null +++ b/app/views/location/show.rhtml @@ -0,0 +1,21 @@ +<%= render :partial => "person/nav" %> + +<h1>Location</h1> +<%= render :partial => "location/pshow", :object => { @location, @mappe } %> + +<hr> +<h2>Nodes</h2> +<%= render :partial => "node/pshow", :object => @nodes %> +<%= link_to 'New Node', :controller => 'node', :action => 'new', :location => @location.id %> + +<hr> +<h2>IP Netze</h2> +<%= render :partial => "net/plist", :object => @nets %> + +<hr> +<h2>Administrator</h2> +<% if @person != nil %> + <%= render :partial => "person/pshow", :object => @person %> +<% end %> +<hr> +<a href="https://db.ffgraz.net/cgi-bin/funkfeuer/index.cgi?conf=conf/ff_location&q_id=<%= @location.id %>">edit location in DBMS</a> diff --git a/app/views/net/_plist.rhtml b/app/views/net/_plist.rhtml new file mode 100644 index 0000000..11bb8f4 --- /dev/null +++ b/app/views/net/_plist.rhtml @@ -0,0 +1,16 @@ + +<table> + <tr> + <th>Netz IP</th> + <th>Netmask</th> + <th>Kommentar</th> + </tr> + <% @nets.each do |net| %> + <tr> + <td><%= net.netip %></td> + <td><%= net.netmask %></td> + <td><%= net.comment %></td> + </tr> + <% end %> +</table> +<p></p> diff --git a/app/views/node/_plist.rhtml b/app/views/node/_plist.rhtml new file mode 100644 index 0000000..c329d4c --- /dev/null +++ b/app/views/node/_plist.rhtml @@ -0,0 +1,17 @@ +<table> + <th>Name</th> + <th>Location</th> + <th>Kommentar</th> + +<% @nodes.each do |node| %> + <tr> + <td><%= node.name %></td> + <td><%= node.location.name %></td> + <td><%= node.comment %></td> + <td><%= link_to 'Show', :action => 'show', :controller => 'node', :id => node %></td> + <td><%= link_to 'Edit', :action => 'edit', :controller => 'node', :id => node %></td> + <td><%= link_to 'Destroy', { :action => 'destroy', :controller => 'node', :id => node }, :confirm => 'Are you sure?', :post => true %></td> + </tr> +<% end %> +</table> + diff --git a/app/views/node/_pshow.rhtml b/app/views/node/_pshow.rhtml new file mode 100644 index 0000000..df7b132 --- /dev/null +++ b/app/views/node/_pshow.rhtml @@ -0,0 +1,54 @@ + +<% @nodes.each do |node| %> +<table border="1" width="600"> + <tr> + <td width="120"><strong>Name</strong></td> + <td colspan="5"><%= node.name %></td> + </tr> + <tr> + <td><strong>Kommentar</strong></td> + <td colspan="5"><%= node.comment %></td> + </tr> + <tr> + <% if node.person %> + <td><strong>Administrator</strong></td> + <td colspan="5"><%= node.person.email %></td> + <% end %> + <tr> + <td rowspan="<%= node.ip.length()+1 %>"><strong>Interfaces</strong></td> + <td><strong>Name</strong></td> + <td><strong>IP</strong></td> + <td><strong>Netmask</strong></td> + <td colspan="2"><strong>Link</strong></td> + <% node.ip.each do |ip| %> + <tr> + <td><%= ip.name %></td> + <td><%= link_to ip.ip, "http://#{ip.ip}" %></td> + <% if ip.nets != nil %> + <% if ip.nets.netmask != '255.255.255.255' %> + <td><%= ip.nets.netmask %></td> + <% else %> + <td><%= '255.255.0.0' %></td> + <% end %> + <% else %> + <td><%= ip.net_id %></td> + <% end %> + <td><%= link_to "intern", "http://#{ip.name}.#{node.name}.#{node.location.name}.graz.funkfeuer.at" %> | <%= link_to "extern", "http://#{ip.name}.#{node.name}.#{node.location.name}.ext.graz.funkfeuer.at" %></td> + </tr> + <% end %> + </tr> + <tr> + <td><strong>Smokeping</strong></td> + <% if node.smokeping %> + <td colspan="5">enabled</td> + <% else %> + <td colspan="5">disabled</td> + <% end %> + </tr> +</table> +<p> + <%= link_to 'Edit', { :controller =>'node', :action => 'edit' , :id => node.id } %> | + <%= link_to 'Destroy', { :controller => 'node', :action => 'destroy', :id => node.id } %> +</p> +<p></p> +<% end %> diff --git a/app/views/node/edit.rhtml b/app/views/node/edit.rhtml new file mode 100644 index 0000000..3686853 --- /dev/null +++ b/app/views/node/edit.rhtml @@ -0,0 +1,34 @@ +<%= render :partial => "person/nav" %> + +<h1>Node</h1> +<%= start_form_tag :action => 'update', :id => @node %> + <table> + <tr> + <td>Name</td><td><%= text_field 'node', 'name' %></td> + </tr> + <tr> + <td>Kommentar</td><td><%= text_area('node', 'comment', :cols => 40, :rows => 5) %></td> + </tr> + <tr> + <td>Administrator</td> + <td> + <select name="node[person_id]"> + <option value="0"> - </option + <% @persons.each do |person| %> + <option value="<%= person.id %>" + <%= ' selected' if @node.person != nil && @node.person.id == person.id %>> + <%= person.email %> + </option> + <% end %> + </select> + </td> + </tr> + <tr> + <td>Smokeping</td> + <td><%= check_box "node", "smokeping" %></td> + </tr> + </table> + <%= submit_tag 'Edit' %> +<%= end_form_tag %> +<hr /> +<%= link_to 'Back', { :controller => 'location', :action => 'show', :id => @node.location.id } %> diff --git a/app/views/node/edit.rhtml.bak b/app/views/node/edit.rhtml.bak new file mode 100644 index 0000000..c14bd94 --- /dev/null +++ b/app/views/node/edit.rhtml.bak @@ -0,0 +1,25 @@ +<h1>Node</h1> +<%= start_form_tag :action => 'update', :id => @node %> + <table> + <tr> + <td>Name</td><td><%= text_field 'node', 'name' %></td> + </tr> + <tr> + <td>Kommentar</td><td><%= text_field 'location', 'comment' %></td> + </tr> + <tr> + <td>Administrator</td><td> + <select name="node[person_id]"> + <option value="0"> - </option + <% @persons.each do |person| %> + <option value="<%= person.id %>" + <%= ' selected' if @node.person != nil && person.id == @node.person.id %>> + <%= person.email %> + </option> + <% end %> + </select> + </td> + </tr> + </table> + <%= submit_tag 'Edit' %> +<%= end_form_tag %> diff --git a/app/views/node/list.rhtml b/app/views/node/list.rhtml new file mode 100644 index 0000000..a6f4ed4 --- /dev/null +++ b/app/views/node/list.rhtml @@ -0,0 +1,2 @@ +<h1>Nodes</h1> +<%= render :partial => "plist", :object => @nodes %> diff --git a/app/views/node/new.rhtml b/app/views/node/new.rhtml new file mode 100644 index 0000000..a1585fc --- /dev/null +++ b/app/views/node/new.rhtml @@ -0,0 +1,44 @@ +<%= render :partial => "person/nav" %> + +<h1>Neuer Router</h1> + +<%= start_form_tag :action => 'do_new' %> + <table> + <tr> + <td>Location:</td> + <td> + <%= @node.location.name %> + </td> + </tr> + <tr> + <td>Name:</td><td><%= text_field 'node', 'name' %></td> + </tr> + <tr> + <td>Kommentar:</td><td><%= text_area 'node', 'comment', 'rows' => 4 %></td> + </tr> + <tr> + <td>Administrator</td> + <td> + <select name="node[person_id]"> + <option value="0"> - </option + <% @persons.each do |person| %> + <option value="<%= person.id %>" + <%= ' selected' if @session[:person].id == person.id %>> + <%= person.email %> + </option> + <% end %> + </select> + </td> + </tr> + <tr> + <td>Smokeping</td> + <td><%= check_box "node", "smokeping" %></td> + </tr> + </table> + <%= hidden_field 'node', 'location_id' %> + <%= submit_tag "Create" %> +<%= end_form_tag %> + + +<h2>Hinweise</h2> +<p>Als <strong>Name</strong> bitte z.B <strong>'omni'</strong> oder einen anden anderen, die Abstrahlcharakteristik bezeichenden Namen.</p> diff --git a/app/views/password_mailer/password.rhtml b/app/views/password_mailer/password.rhtml new file mode 100644 index 0000000..44a43c4 --- /dev/null +++ b/app/views/password_mailer/password.rhtml @@ -0,0 +1,14 @@ +Neues Passwort: +--------------- + +Person: <%= @person.firstname + ' ' + @person.lastname %> +Email: <%= @person.email %> +neues Passwort: <%= @password %> + +mfg +Funkfeuer Graz Admin + +-- +admin@graz.funkfeuer.at +http://graz.funkfeuer.at + diff --git a/app/views/person/_form.rhtml b/app/views/person/_form.rhtml new file mode 100644 index 0000000..a640109 --- /dev/null +++ b/app/views/person/_form.rhtml @@ -0,0 +1,25 @@ +<%= error_messages_for 'person' %> + +<!--[form:person]--> +<p><label for="person_name">Name</label><br/> +<%= text_field 'person', 'name' %></p> + +<p><label for="person_nick">Nick</label><br/> +<%= text_field 'person', 'nick' %></p> + +<p><label for="person_firstname">Firstname</label><br/> +<%= text_field 'person', 'firstname' %></p> + +<p><label for="person_lastname">Lastname</label><br/> +<%= text_field 'person', 'lastname' %></p> + +<p><label for="person_email">Email</label><br/> +<%= text_field 'person', 'email' %></p> + +<p><label for="person_tel">Tel</label><br/> +<%= text_field 'person', 'tel' %></p> + +<p><label for="person_password">Password</label><br/> +<%= password_field 'person', 'password' %></p> +<!--[eoform:person]--> + diff --git a/app/views/person/_nav.rhtml b/app/views/person/_nav.rhtml new file mode 100644 index 0000000..bcde756 --- /dev/null +++ b/app/views/person/_nav.rhtml @@ -0,0 +1,11 @@ +<div> + <p> + <strong>Navigation:</strong> + <%= link_to "Locations", :action => "list", :controller => "location" %> | + <%= link_to "Persons", :action => 'list', :controller => 'person' %> <br /> + <strong>Benutzer:</strong> + <%= link_to session[:person].email , :action => 'show', :controller => 'person', :id => session[:person].id %> | + <%= link_to 'Logout', :action => 'logout', :controller => 'person' %> + </p> +</div> +<hr /> diff --git a/app/views/person/_pshow.rhtml b/app/views/person/_pshow.rhtml new file mode 100644 index 0000000..61a1f32 --- /dev/null +++ b/app/views/person/_pshow.rhtml @@ -0,0 +1,20 @@ +<% if @person != nil %> +<table> + <tr> + <td>Nick:</td><td><%= @person.nick %></td> + </tr> + <tr> + <td>Email:</td><td><%= mail_to @person.email, @person.email, :encode => 'hex' %></td> + </tr> + <tr> + <td>Tel:</td><td><%= @person.tel %></td> + </tr> +</table> +<p> + <%= link_to 'Show', { :action => 'show', :controller => 'person', :id => @person.id } %> | + <%= link_to 'Edit', { :action => 'edit', :controller => 'person', :id => @person.id } %> | + <%= link_to 'Change Password', { :action => 'change_pass', + :controller => 'person', + :id => @person.id } %> +</p> +<% end %> diff --git a/app/views/person/change_pass.rhtml b/app/views/person/change_pass.rhtml new file mode 100644 index 0000000..f1d62fa --- /dev/null +++ b/app/views/person/change_pass.rhtml @@ -0,0 +1,22 @@ +<%= render :partial => "person/nav" %> +<h1>Passwort aendern</h1> + +<%= form_tag :action => "do_change_pass", :id => @person.id %> +<table> + <tr> + <td>altes Passwort:</td> + <td><%= password_field_tag 'oldpassword' %></td> + </tr> + <tr> + <td>neues Passwort:</td> + <td><%= password_field_tag 'password' %></td> + </tr> + <tr> + <td>nochmals:</td> + <td><%= password_field_tag 'password2' %></td> + </tr> +</table> + +<%= submit_tag 'Change' %> +<%= end_form_tag %> + diff --git a/app/views/person/edit.rhtml b/app/views/person/edit.rhtml new file mode 100644 index 0000000..7c0f1da --- /dev/null +++ b/app/views/person/edit.rhtml @@ -0,0 +1,26 @@ +<%= render :partial => "person/nav" %> +<h1>Person</h1> +<%= start_form_tag :action => 'update', :id => @person %> + <table> + <tr> + <td>nick</td><td><%= text_field 'person', 'nick' %></td> + </tr> + <tr> + <td>Vorname</td><td><%= text_field 'person', 'firstname' %></td> + </tr> + <tr> + <td>Nachname</td><td><%= text_field 'person', 'lastname' %></td> + </tr> + <tr> + <td>Email:</td><td><%= text_field 'person', 'email' %></td> + </tr> + <tr> + <td>Tel:</td><td><%= text_field 'person', 'tel' %></td> + </tr> + </table> + <%= submit_tag 'Edit' %> +<%= end_form_tag %> + +<%= link_to 'Show', :action => 'show', :id => @person %> | +<%= link_to 'Back', :action => 'list' %> + diff --git a/app/views/person/list.rhtml b/app/views/person/list.rhtml new file mode 100644 index 0000000..37b8128 --- /dev/null +++ b/app/views/person/list.rhtml @@ -0,0 +1,20 @@ + +<%= render :partial => "person/nav" %> +<h1>Personen</h1> +<table> + <th>Nickname</th> + <th>Email</th> + <th>Tel.</th> + +<% @persons.each do |person| %> + <tr> + <td><%= person.nick %></td> + <td><%= mail_to person.email, person.email, :encode => "hex" %></td> + <td><%= person.tel %></td> + <td><%= link_to 'Show', :action => 'show', :id => person %></td> + <td><%= link_to 'Edit', :action => 'edit', :id => person %></td> + <td><%= link_to 'Destroy', { :action => 'destroy', :id => person }, :confirm => 'Are you sure?', :post => true %></td> + </tr> +<% end %> +</table> + diff --git a/app/views/person/login.rhtml b/app/views/person/login.rhtml new file mode 100644 index 0000000..a8d8fc3 --- /dev/null +++ b/app/views/person/login.rhtml @@ -0,0 +1,19 @@ +<% %> +<h1>Login</h1> +<%= form_tag :action => "sign_on" %> +<table> + <tr> + <td>Email:</td> + <td><%= text_field 'person', 'email' %> + </tr> + <tr> + <td>Passwort:</td> + <td><%= password_field 'person', 'password' %></td> + </tr> +</table> + +<%= submit_tag 'Login' %> +<%= end_form_tag %> +<hr /> +<%= link_to 'Passwort vergessen', :action => 'revoke_pass' %> | +<%= link_to 'Registrieren', :action => 'register' %> diff --git a/app/views/person/new.rhtml b/app/views/person/new.rhtml new file mode 100644 index 0000000..0e79d24 --- /dev/null +++ b/app/views/person/new.rhtml @@ -0,0 +1,8 @@ +<h1>New person</h1> + +<%= start_form_tag :action => 'create' %> + <%= render :partial => 'form' %> + <%= submit_tag "Create" %> +<%= end_form_tag %> + +<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/person/register.rhtml b/app/views/person/register.rhtml new file mode 100644 index 0000000..4c670a4 --- /dev/null +++ b/app/views/person/register.rhtml @@ -0,0 +1,35 @@ +<h1>register Person</h1> +<p>Hier kannst du dich fuer FunkFeuer Graz registrieren damit wir dir IP Adressen und + Locations zuordnen koennen. +</p> +<%= start_form_tag :action => 'create', :id => @person %> + <table> + <tr> + <td>Nickname</td><td><%= text_field 'person', 'nick' %></td> + </tr> + <tr> + <td>Vorname</td><td><%= text_field 'person', 'firstname' %>*</td> + </tr> + <tr> + <td>Nachname</td><td><%= text_field 'person', 'lastname' %>*</td> + </tr> + <tr> + <td>Email:</td><td><%= text_field 'person', 'email' %>*</td> + </tr> + <tr> + <td>Tel:</td><td><%= text_field 'person', 'tel' %></td> + </tr> + <tr> + <td>Passwort</td><td><%= password_field_tag 'password' %>*</td> + </tr> + <tr> + <td>Passwort</td><td><%= password_field_tag 'password2' %>*</td> + </tr> + + </table> + <%= submit_tag 'Create' %> +<%= end_form_tag %> + +<p>Bitte mindestens Felder mit <strong>*</strong> eintragen</p> +<p>Die Felder <strong>Nickname</strong>, <strong>Email</strong> und <strong>Tel</strong> + koennen von allen angemeldeten Benutzern eingesehen werden.</p> diff --git a/app/views/person/revoke_pass.rhtml b/app/views/person/revoke_pass.rhtml new file mode 100644 index 0000000..99c3a27 --- /dev/null +++ b/app/views/person/revoke_pass.rhtml @@ -0,0 +1,15 @@ +<h1>Revoke Passwort</h1> +<p>Bitte geben Sie Ihre email Adresse ein.<br/> +Ein neues Passwort wird Ihnen dann zugesendet.</p> + +<%= form_tag :action => "do_revoke" %> +<table> + <tr> + <td>Email:</td> + <td><%= text_field 'person', 'email' %> + </tr> +</table> + +<%= submit_tag 'Revoke' %> +<%= end_form_tag %> + diff --git a/app/views/person/show.rhtml b/app/views/person/show.rhtml new file mode 100644 index 0000000..be5541f --- /dev/null +++ b/app/views/person/show.rhtml @@ -0,0 +1,8 @@ +<%= render :partial => "person/nav" %> +<h1>Person</h1> +<%= render :partial => "person/pshow", :object => @person %> +<hr> +<h2>Locations</h2> +<%= render :partial => "location/plist", + :object => @locations %> + |