fetprofileprivate data
This commit is contained in:
@@ -12,9 +12,12 @@ class FetprofilesController < ApplicationController
|
|||||||
@gremientabs = Gremium.tabs
|
@gremientabs = Gremium.tabs
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
format.json { render json: @fetprofiles }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def internlist
|
||||||
|
@fetprofiles = Fetprofile.order(:vorname,:nachname)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# GET /fetprofiles/1
|
# GET /fetprofiles/1
|
||||||
# GET /fetprofiles/1.json
|
# GET /fetprofiles/1.json
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
class Fetprofile < ActiveRecord::Base
|
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 :memberships, dependent: :delete_all
|
||||||
has_many :gremien, :through=> :membership
|
has_many :gremien, :through=> :membership
|
||||||
mount_uploader :picture, PictureUploader
|
mount_uploader :picture, PictureUploader
|
||||||
@@ -23,11 +23,18 @@ class Fetprofile < ActiveRecord::Base
|
|||||||
validates :desc, :presence=>true
|
validates :desc, :presence=>true
|
||||||
validates :nachname, length:{minimum: 3},:presence=>true
|
validates :nachname, length:{minimum: 3},:presence=>true
|
||||||
validates :vorname, length:{minimum: 3},:presence=>true
|
validates :vorname, length:{minimum: 3},:presence=>true
|
||||||
|
validate :validate_birthday
|
||||||
has_many :users
|
has_many :users
|
||||||
scope :search, ->(query) {where("nachname like ? or vorname like ? or short like ?", "%#{query}%", "%#{query}%", "%#{query}%")}
|
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
|
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
|
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
|
def title
|
||||||
self.name
|
self.name
|
||||||
@@ -39,4 +46,15 @@ validates :desc, :presence=>true
|
|||||||
def fetmail
|
def fetmail
|
||||||
(fetmailalias.nil? || fetmailalias.empty?) ? short.to_s + "@fet.at" : fetmailalias.to_s + "@fet.at"
|
(fetmailalias.nil? || fetmailalias.empty?) ? short.to_s + "@fet.at" : fetmailalias.to_s + "@fet.at"
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -28,6 +28,29 @@
|
|||||||
<div class="span4"> <%= f.input :fetmailalias %></div>
|
<div class="span4"> <%= f.input :fetmailalias %></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span6">
|
||||||
|
Adresse:
|
||||||
|
|
||||||
|
<%=f.input :street %>
|
||||||
|
<%=f.input :plz %>
|
||||||
|
<%=f.input :city %>
|
||||||
|
KOntakt:
|
||||||
|
<%=f.input :instant %>
|
||||||
|
<%=f.input :skype %>
|
||||||
|
<%=f.input :telnr %>
|
||||||
|
<%=f.input :hdynr %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="span6">
|
||||||
|
Geburtstag:
|
||||||
|
<%=f.input :birth_day %>
|
||||||
|
<%=f.input :birth_month %>
|
||||||
|
<%=f.input :birth_year %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
<% @memberships.each do |m| %>
|
<% @memberships.each do |m| %>
|
||||||
|
|
||||||
<%= f.semantic_fields_for :memberships, m do |membership| %>
|
<%= f.semantic_fields_for :memberships, m do |membership| %>
|
||||||
|
|||||||
13
app/views/fetprofiles/_interninfo.html.erb
Normal file
13
app/views/fetprofiles/_interninfo.html.erb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<p>
|
||||||
|
<b>Adresse:</b>
|
||||||
|
<%= interninfo.plz %>
|
||||||
|
<%= interninfo.city %>,
|
||||||
|
<%= interninfo.street %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= raw("<b>Telefon: </b>")+ interninfo.telnr + "<br>" unless interninfo.telnr.empty?%>
|
||||||
|
<%= raw("<b>Handy: </b>") +interninfo.hdynr unless interninfo.hdynr.empty? %><br>
|
||||||
|
<%= raw("<b>Skype: </b>") +interninfo.skype unless interninfo.skype.empty? %><br>
|
||||||
|
<%= raw("<b>Instant Messaging: </b>") +interninfo.instant unless interninfo.instant.empty? %><br>
|
||||||
|
|
||||||
|
</p>
|
||||||
12
app/views/fetprofiles/_internrow.html.erb
Normal file
12
app/views/fetprofiles/_internrow.html.erb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<tr>
|
||||||
|
<td> <%= link_to internrow.name, internrow %>
|
||||||
|
</td>
|
||||||
|
<td> <%= internrow.adress %></td>
|
||||||
|
<td>
|
||||||
|
<%= raw("Telefon: ")+ internrow.telnr + "<br>" unless internrow.telnr.nil? || internrow.telnr.empty?%>
|
||||||
|
<%= raw("Handy: ") +internrow.hdynr + raw("<br>") unless internrow.hdynr.nil? || internrow.hdynr.empty? %>
|
||||||
|
<%= raw("Skype: ") +internrow.skype + raw("<br>") unless internrow.skype.nil? || internrow.skype.empty? %>
|
||||||
|
<%= raw("Instant Messaging: ") +internrow.instant + raw("<br>") unless internrow.instant.nil? || internrow.instant.empty? %>
|
||||||
|
</td>
|
||||||
|
<td><%= internrow.fetmail %></td>
|
||||||
|
</tr>
|
||||||
5
app/views/fetprofiles/internlist.html.erb
Normal file
5
app/views/fetprofiles/internlist.html.erb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<table style="width:100%" class="table table-striped">
|
||||||
|
<% @fetprofiles.each do |item| %>
|
||||||
|
<%= render partial: "internrow", object: item %>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
@@ -10,10 +10,15 @@
|
|||||||
<p>
|
<p>
|
||||||
<%= @fetprofile.fetmail %>
|
<%= @fetprofile.fetmail %>
|
||||||
</p>
|
</p>
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.json { render json: @fetprofiles }
|
||||||
|
end
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= @fetprofile.desc %>
|
<%= @fetprofile.desc %>
|
||||||
</p>
|
</p>
|
||||||
|
<%= render partial: "interninfo", object: @fetprofile if can?(:seeintern, @fetprofile) %>
|
||||||
<ul>
|
<ul>
|
||||||
<% @memberships.each do |m| %>
|
<% @memberships.each do |m| %>
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
<h1> FET Intern NEU </h1>
|
<h1> FET Intern NEU </h1>
|
||||||
<h2>Neuigkeiten</h2>
|
<div class="container-fluid">
|
||||||
<ul class="unstyled linkbox-list" style="max-width:70em">
|
<div class="row-fluid">
|
||||||
|
<div class="span6">
|
||||||
|
<%= link_to "Adressliste", internlist_fetprofiles_path %>
|
||||||
|
<%= link_to "Internes Nachschlagewerk" %>
|
||||||
|
</div>
|
||||||
|
<div class="span6">
|
||||||
|
<h2>Neuigkeiten</h2>
|
||||||
|
<ul class="unstyled linkbox-list">
|
||||||
<% @neuigkeiten.each do |n| %>
|
<% @neuigkeiten.each do |n| %>
|
||||||
<li><%= render n if can?(:show, n) %> </li>
|
<li><%= render n if can?(:show, n) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h2></h2>
|
<h2></h2>
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
resources :fetprofiles do
|
resources :fetprofiles do
|
||||||
collection do
|
collection do
|
||||||
get 'verwalten'
|
get 'verwalten'
|
||||||
|
get 'internlist'
|
||||||
end
|
end
|
||||||
resources :memberships, :only => [:new, :edit, :update,:destroy,:create]
|
resources :memberships, :only => [:new, :edit, :update,:destroy,:create]
|
||||||
end
|
end
|
||||||
|
|||||||
15
db/migrate/20140522094444_add_adress_to_fetprofile.rb
Normal file
15
db/migrate/20140522094444_add_adress_to_fetprofile.rb
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user