fetprofileprivate data

This commit is contained in:
2014-05-27 19:41:35 +05:30
parent 015bf132a9
commit 13514317c9
10 changed files with 116 additions and 11 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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| %>

View 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>

View 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>

View File

@@ -0,0 +1,5 @@
<table style="width:100%" class="table table-striped">
<% @fetprofiles.each do |item| %>
<%= render partial: "internrow", object: item %>
<% end %>
</table>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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

View 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