forked from bofh/fetsite
Views & Logik Membership, Fetprofile, Gremium
This commit is contained in:
@@ -2,8 +2,10 @@ class FetprofilesController < ApplicationController
|
||||
# GET /fetprofiles
|
||||
# GET /fetprofiles.json
|
||||
def index
|
||||
@fetprofiles = Fetprofile.all
|
||||
|
||||
@fetprofiles = Fetprofile.active
|
||||
@fetprofiles = Fetprofile.order(:vorname,:nachname) if params[:filter]== "all"
|
||||
@gremientabs=Gremium.order(:typ)
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @fetprofiles }
|
||||
|
||||
@@ -3,7 +3,7 @@ class GremienController < ApplicationController
|
||||
# GET /gremien.json
|
||||
def index
|
||||
@gremien = Gremium.all
|
||||
|
||||
@gremientabs=Gremium.all
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @gremien }
|
||||
@@ -14,7 +14,7 @@ class GremienController < ApplicationController
|
||||
# GET /gremien/1.json
|
||||
def show
|
||||
@gremium = Gremium.find(params[:id])
|
||||
|
||||
@gremientabs=Gremium.order(:typ)
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @gremium }
|
||||
|
||||
@@ -34,7 +34,7 @@ class MembershipsController < ApplicationController
|
||||
# PUT /memberships/1
|
||||
# PUT /memberships/1.json
|
||||
def update
|
||||
@membership = Membership.find(params[:id])
|
||||
#@membership = Membership.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @membership.update_attributes(params[:membership])
|
||||
|
||||
@@ -23,5 +23,8 @@ class Fetprofile < ActiveRecord::Base
|
||||
[vorname, nachname, "(",short,")"].join(" ")
|
||||
end
|
||||
accepts_nested_attributes_for :memberships
|
||||
scope :active, -> { where(:active=>:true).order(:vorname) }
|
||||
scope :active, -> { where(:active=>true).order(:vorname) }
|
||||
def fetmail
|
||||
fetmailalias.empty? ? short + "@fet.at" : fetmailalias + "@fet.at"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,4 +17,6 @@ class Membership < ActiveRecord::Base
|
||||
attr_accessible :fetprofile_id, :gremium_id, :start, :stop, :typ
|
||||
belongs_to :fetprofile
|
||||
belongs_to :gremium
|
||||
scope :active, -> {where("stop >= ? OR stop IS NULL", Time.now.to_date)}
|
||||
|
||||
end
|
||||
|
||||
12
app/views/fetprofiles/_fetprofile.html.erb
Normal file
12
app/views/fetprofiles/_fetprofile.html.erb
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
<div class="media">
|
||||
<div class="pull-left">
|
||||
<%= image_tag fetprofile.picture.portrait.url %>
|
||||
</div>
|
||||
<div class="media-body">
|
||||
|
||||
<h2><%= link_to fetprofile.name, fetprofile %></h2>
|
||||
<p><%= fetprofile.fetmail %></p>
|
||||
<p><%= fetprofile.desc.split(" ")[1..20].join(" ") %></p>
|
||||
<p><%= fetprofile.active %> </p>
|
||||
</div>
|
||||
24
app/views/fetprofiles/_tabs.html.erb
Normal file
24
app/views/fetprofiles/_tabs.html.erb
Normal file
@@ -0,0 +1,24 @@
|
||||
<ul class="nav nav-tabs">
|
||||
<li <%= (request.fullpath == fetprofiles_path(filter: "active")|| request.fullpath == fetprofiles_path) ? 'class="active"'.html_safe : ''%> >
|
||||
<%= link_to "Aktive Mitglieder" , fetprofiles_path( filter: "active") %> </li>
|
||||
|
||||
<% for g in @gremientabs %>
|
||||
<li <%= (!@gremium.nil? && g == @gremium) ? 'class="active"'.html_safe : '' %> title="<%= g.name %>">
|
||||
<%= link_to g.name, g %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<li <%= (request.fullpath == fetprofiles_path(filter: "all")) ? 'class="active"'.html_safe : ''%> >
|
||||
<%= link_to "Alle Mitglieder" , fetprofiles_path( filter: "all") %> </li>
|
||||
|
||||
|
||||
<% if can?(:verwalten,Gremium) %>
|
||||
<% if request.fullpath == gremien_path %>
|
||||
<li class="active pull-right">
|
||||
<% else %>
|
||||
<li class="pull-right">
|
||||
<% end %>
|
||||
<%= link_to "Verwaltung", gremien_path %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
@@ -1,10 +1,20 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<h1>Listing fetprofiles</h1>
|
||||
<%= render 'fetprofiles/tabs' %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<h1>
|
||||
<%= I18n.t 'fetprofiles.all' if params[:filter] == "all" %>
|
||||
<%= I18n.t 'fetprofiles.active' if params[:filter].nil? || params[:filter]== "active"
|
||||
%>
|
||||
|
||||
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
<% @fetprofiles.each do |fetprofile| %>
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
@@ -13,7 +23,7 @@
|
||||
<div class="span9">
|
||||
|
||||
<h2><%= link_to fetprofile.name, fetprofile %></h2>
|
||||
<p><%= fetprofile.fetmailalias %></p>
|
||||
<p><%= fetprofile.fetmail %></p>
|
||||
<p><%= fetprofile.desc %></p>
|
||||
<p><%= fetprofile.active %> </p>
|
||||
</div>
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Name:</b>
|
||||
<%= render 'fetprofiles/tabs' %>
|
||||
<h1>
|
||||
<%= @gremium.name %>
|
||||
</p>
|
||||
|
||||
</h1>
|
||||
<p>
|
||||
<b>Desc:</b>
|
||||
<%= @gremium.desc %>
|
||||
</p>
|
||||
|
||||
<% @gremium.memberships.order(:typ).active.each do |m| %>
|
||||
<%= image_tag m.fetprofile.picture.portrait %>
|
||||
<%= m.fetprofile.name + " ist" + render(m) %>
|
||||
<% end %>
|
||||
<p>
|
||||
<b>Typ:</b>
|
||||
<%= Gremium::TYPEN[@gremium.typ.to_i].to_s %>
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_gremium_path(@gremium) %> |
|
||||
<%= link_to 'Back', gremien_path %>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
<%= "seit" if membership.stop.nil? %>
|
||||
<%= membership.stop.nil? ? "seit " : "von " %>
|
||||
<%=membership.start.to_s %>
|
||||
<%= " bis "+membership.stop.to_s unless membership.stop.nil? %>
|
||||
<%= Membership::TYPEN[membership.typ.to_i] %>
|
||||
|
||||
Reference in New Issue
Block a user