diff --git a/app/controllers/fetprofiles_controller.rb b/app/controllers/fetprofiles_controller.rb
index ad61588..83af41c 100644
--- a/app/controllers/fetprofiles_controller.rb
+++ b/app/controllers/fetprofiles_controller.rb
@@ -12,9 +12,12 @@ class FetprofilesController < ApplicationController
@gremientabs = Gremium.tabs
respond_to do |format|
format.html # index.html.erb
- format.json { render json: @fetprofiles }
- end
+ end
end
+ def internlist
+ @fetprofiles = Fetprofile.order(:vorname,:nachname)
+ end
+
# GET /fetprofiles/1
# GET /fetprofiles/1.json
diff --git a/app/models/fetprofile.rb b/app/models/fetprofile.rb
index 787c175..143b672 100644
--- a/app/models/fetprofile.rb
+++ b/app/models/fetprofile.rb
@@ -15,7 +15,7 @@
#
class Fetprofile < ActiveRecord::Base
- attr_accessible :active, :desc, :fetmailalias, :nachname, :picture, :short, :vorname, :memberships_attributes, :remove_picture, :picture_cache
+ attr_accessible :active, :desc, :fetmailalias, :nachname, :picture, :short, :vorname, :memberships_attributes, :remove_picture, :picture_cache, :plz, :street, :city, :instant,:skype, :telnr, :hdynr, :birth_day,:birth_month, :birth_year
has_many :memberships, dependent: :delete_all
has_many :gremien, :through=> :membership
mount_uploader :picture, PictureUploader
@@ -23,11 +23,18 @@ class Fetprofile < ActiveRecord::Base
validates :desc, :presence=>true
validates :nachname, length:{minimum: 3},:presence=>true
validates :vorname, length:{minimum: 3},:presence=>true
+ validate :validate_birthday
has_many :users
scope :search, ->(query) {where("nachname like ? or vorname like ? or short like ?", "%#{query}%", "%#{query}%", "%#{query}%")}
accepts_nested_attributes_for :memberships, :reject_if=>lambda{|a| a[:typ].blank?|| a[:start].blank? ||a[:gremium_id].blank?}, :allow_destroy=>true
has_many :nlinks, as: :link
+ def validate_birthday
+ unless Date.valid_date?(birth_year, birth_month, birth_day)
+ errors.add(:birth_month, "Invalides Datum")
+ errors.add(:birth_day, "Invalides Datum")
+ end
+ end
def title
self.name
@@ -39,4 +46,15 @@ validates :desc, :presence=>true
def fetmail
(fetmailalias.nil? || fetmailalias.empty?) ? short.to_s + "@fet.at" : fetmailalias.to_s + "@fet.at"
end
+ def adress
+ connector= (self.street.nil?||self.street.empty?||(self.city.empty? && self.plz.empty?)) ? '' : ', '
+ self.plz.to_s + ' ' + self.city.to_s + connector.to_s + self.street.to_s
+ end
+ def birthday
+ if self.birth_year.nil? || self.birth_year.zero?
+ Date.new( Date.today.year,self.birth_month,self.birth_day)
+ else
+ Date.new( self.birth_year,self.birth_month,self.birth_day)
+ end
+ end
end
diff --git a/app/views/fetprofiles/_form.html.erb b/app/views/fetprofiles/_form.html.erb
index 8143c08..3714148 100644
--- a/app/views/fetprofiles/_form.html.erb
+++ b/app/views/fetprofiles/_form.html.erb
@@ -28,6 +28,29 @@
<%= f.input :fetmailalias %>
+
+
+Adresse:
+
+<%=f.input :street %>
+<%=f.input :plz %>
+<%=f.input :city %>
+KOntakt:
+<%=f.input :instant %>
+<%=f.input :skype %>
+<%=f.input :telnr %>
+<%=f.input :hdynr %>
+
+
+
+Geburtstag:
+<%=f.input :birth_day %>
+<%=f.input :birth_month %>
+<%=f.input :birth_year %>
+
+
+
+
<% @memberships.each do |m| %>
<%= f.semantic_fields_for :memberships, m do |membership| %>
diff --git a/app/views/fetprofiles/_interninfo.html.erb b/app/views/fetprofiles/_interninfo.html.erb
new file mode 100644
index 0000000..b85b608
--- /dev/null
+++ b/app/views/fetprofiles/_interninfo.html.erb
@@ -0,0 +1,13 @@
+
+ Adresse:
+ <%= interninfo.plz %>
+ <%= interninfo.city %>,
+ <%= interninfo.street %>
+
+
+ <%= raw("Telefon: ")+ interninfo.telnr + "
" unless interninfo.telnr.empty?%>
+ <%= raw("Handy: ") +interninfo.hdynr unless interninfo.hdynr.empty? %>
+<%= raw("Skype: ") +interninfo.skype unless interninfo.skype.empty? %>
+<%= raw("Instant Messaging: ") +interninfo.instant unless interninfo.instant.empty? %>
+
+
diff --git a/app/views/fetprofiles/_internrow.html.erb b/app/views/fetprofiles/_internrow.html.erb
new file mode 100644
index 0000000..63fbb75
--- /dev/null
+++ b/app/views/fetprofiles/_internrow.html.erb
@@ -0,0 +1,12 @@
+
+| <%= link_to internrow.name, internrow %>
+ |
+ <%= internrow.adress %> |
+
+ <%= raw("Telefon: ")+ internrow.telnr + " " unless internrow.telnr.nil? || internrow.telnr.empty?%>
+ <%= raw("Handy: ") +internrow.hdynr + raw(" ") unless internrow.hdynr.nil? || internrow.hdynr.empty? %>
+<%= raw("Skype: ") +internrow.skype + raw(" ") unless internrow.skype.nil? || internrow.skype.empty? %>
+<%= raw("Instant Messaging: ") +internrow.instant + raw(" ") unless internrow.instant.nil? || internrow.instant.empty? %>
+ |
+<%= internrow.fetmail %> |
+
diff --git a/app/views/fetprofiles/internlist.html.erb b/app/views/fetprofiles/internlist.html.erb
new file mode 100644
index 0000000..5d8f566
--- /dev/null
+++ b/app/views/fetprofiles/internlist.html.erb
@@ -0,0 +1,5 @@
+
+<% @fetprofiles.each do |item| %>
+<%= render partial: "internrow", object: item %>
+<% end %>
+
diff --git a/app/views/fetprofiles/show.html.erb b/app/views/fetprofiles/show.html.erb
index ded2659..b62caae 100644
--- a/app/views/fetprofiles/show.html.erb
+++ b/app/views/fetprofiles/show.html.erb
@@ -10,10 +10,15 @@
<%= @fetprofile.fetmail %>
-
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @fetprofiles }
+ end
+
+
<%= @fetprofile.desc %>
-
+ <%= render partial: "interninfo", object: @fetprofile if can?(:seeintern, @fetprofile) %>
<% @memberships.each do |m| %>
-
diff --git a/app/views/home/intern.html.erb b/app/views/home/intern.html.erb
index b419c02..2948dfa 100644
--- a/app/views/home/intern.html.erb
+++ b/app/views/home/intern.html.erb
@@ -1,10 +1,20 @@
FET Intern NEU
-Neuigkeiten
-
- <% @neuigkeiten.each do |n| %>
- - <%= render n if can?(:show, n) %>
- <% end %>
-
+
+
+
+ <%= link_to "Adressliste", internlist_fetprofiles_path %>
+ <%= link_to "Internes Nachschlagewerk" %>
+
+
+
Neuigkeiten
+
+ <% @neuigkeiten.each do |n| %>
+ - <%= render n if can?(:show, n) %>
+ <% end %>
+
+
+
+
diff --git a/config/routes.rb b/config/routes.rb
index 4e8a1aa..a3d5cd6 100755
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -57,6 +57,7 @@
resources :fetprofiles do
collection do
get 'verwalten'
+ get 'internlist'
end
resources :memberships, :only => [:new, :edit, :update,:destroy,:create]
end
diff --git a/db/migrate/20140522094444_add_adress_to_fetprofile.rb b/db/migrate/20140522094444_add_adress_to_fetprofile.rb
new file mode 100644
index 0000000..6a01af2
--- /dev/null
+++ b/db/migrate/20140522094444_add_adress_to_fetprofile.rb
@@ -0,0 +1,15 @@
+class AddAdressToFetprofile < ActiveRecord::Migration
+ def change
+ add_column :fetprofiles, :street, :string
+ add_column :fetprofiles, :plz, :string
+ add_column :fetprofiles, :telnr, :string
+ add_column :fetprofiles, :hdynr, :string
+ add_column :fetprofiles, :skype, :string
+ add_column :fetprofiles, :instant, :string
+ add_column :fetprofiles, :city, :string
+ add_column :fetprofiles, :birth_day, :integer
+ add_column :fetprofiles, :birth_month, :integer
+ add_column :fetprofiles, :birth_year, :integer
+ add_column :fetprofiles, :public_birthday, :boolean
+ end
+end