Gremien, Memberships Update

This commit is contained in:
Andreas Stephanides
2013-08-25 16:37:59 +02:00
parent ad6e387635
commit 3bd04f9101
9 changed files with 33 additions and 9 deletions

View File

@@ -11,6 +11,14 @@
#
class Gremium < ActiveRecord::Base
attr_accessible :desc, :name, :typ
TYPEN={1=>"offiziell"}
GESCHLECHT={0=>"s&aumlchlich", 1 => "m&aumlnnlich", 2 => "weiblich"}
ART2FALL={0=>"des", 1=>"des",2=>"der"}
attr_accessible :desc, :name, :typ, :geschlecht,:thema_id
has_many :memberships
belongs_to :thema
def fall2
Gremium::ART2FALL[self.geschlecht.to_i].to_s+" "+ self.name.to_s+ ((self.geschlecht.to_i==1||self.geschlecht.to_i==0)? "s":"")
end
end

View File

@@ -13,6 +13,7 @@
#
class Membership < ActiveRecord::Base
TYPEN={1=>"Mitglied",2=> "Ersatzmitglied",3=>"VerantwortlicheR"}
attr_accessible :fetprofile_id, :gremium_id, :start, :stop, :typ
belongs_to :fetprofile
belongs_to :gremium

View File

@@ -25,7 +25,7 @@
<div class="span3"><%= membership.input :start, :as=>:date %></div>
<div class="span3"><%= membership.input :stop %></div>
<div class="span3"><%= membership. input :gremium %></div>
<div class="span2"><%= membership.input :typ ,:as=>:radio, :collection=>{"mitglied"=>1, "ersatzmitglied"=>2} %></div>
<div class="span2"><%= membership.input :typ ,:as=>:radio, :collection=>Membership::TYPEN.invert %></div>
</div> <% end %>
<% end %>

View File

@@ -24,8 +24,9 @@
<div class="span12">
<ul>
<% @fetprofile.memberships.each do |m| %>
<li><%= m.start.to_s %> bis <%= m.stop.to_s %> in <%= m.gremium.try(:name).to_s %>
<%= link_to 'edit', edit_fetprofile_membership_path(@fetprofile,m) %>
<li>
<%= render m %>
<% link_to 'edit', edit_fetprofile_membership_path(@fetprofile,m) %>
</li>
<% end %>
</ul>

View File

@@ -2,7 +2,9 @@
<%= f.inputs do %>
<%= f.input :name %>
<%= f.input :desc %>
<%= f.input :typ %>
<%= f.input :typ, :as => :select, :collection => Gremium::TYPEN.invert %>
<%= f.input :geschlecht, :as => :select, :collection => Gremium::GESCHLECHT.invert %>
<%= f.input :thema, :as=> :select, :collection => Thema.all %>
<% end %>
<%= f.actions do %>

View File

@@ -12,7 +12,7 @@
<p>
<b>Typ:</b>
<%= @gremium.typ %>
<%= Gremium::TYPEN[@gremium.typ.to_i].to_s %>
</p>

View File

@@ -3,7 +3,7 @@
<%= f.input :gremium, :as=>:radio %>
<%= f.input :start %>
<%= f.input :stop %>
<%= f.input :typ ,:as=>:radio, :collection=>{"mitglied"=>1, "ersatzmitglied"=>2} %>
<%= f.input :typ ,:as=>:radio,:collection=>Membership::TYPEN.invert %>
<% end %>
<%= f.actions do %>

View File

@@ -0,0 +1,6 @@
<%= "seit" if membership.stop.nil? %>
<%=membership.start.to_s %>
<%= " bis "+membership.stop.to_s unless membership.stop.nil? %>
<%= Membership::TYPEN[membership.typ.to_i] %>
<%= membership.gremium.fall2 %>

View File

@@ -0,0 +1,6 @@
class AddColumnsToGremien < ActiveRecord::Migration
def change
add_column :gremien, :geschlecht, :string
add_column :gremien, :thema_id, :integer
end
end