From e884e82fa5aca72f3c802f8b4d1087570d2ddd79 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Tue, 24 Sep 2013 10:00:13 +0200 Subject: [PATCH] fixed fetprofiles --- app/models/fetprofile.rb | 5 ++-- app/views/fetprofiles/_tabs.html.erb | 35 +++++++++++++------------- app/views/fetprofiles/index.html.erb | 37 ++++++++++++++-------------- app/views/fetprofiles/show.html.erb | 16 ++++-------- app/views/gremien/show.html.erb | 8 ++++-- app/views/gremien/verwalten.html.erb | 20 +++++++++++---- 6 files changed, 66 insertions(+), 55 deletions(-) diff --git a/app/models/fetprofile.rb b/app/models/fetprofile.rb index 360e19a..a83834c 100644 --- a/app/models/fetprofile.rb +++ b/app/models/fetprofile.rb @@ -16,15 +16,16 @@ class Fetprofile < ActiveRecord::Base attr_accessible :active, :desc, :fetmailalias, :nachname, :picture, :short, :vorname,:memberships_attributes,:remove_picture,:picture_cache - has_many :memberships + has_many :memberships, dependent: :delete_all has_many :gremien, :through=> :membership mount_uploader :picture, PictureUploader + has_paper_trail def name [vorname, nachname, "(",short,")"].join(" ") end accepts_nested_attributes_for :memberships scope :active, -> { where(:active=>true).order(:vorname) } def fetmail - fetmailalias.empty? ? short + "@fet.at" : fetmailalias + "@fet.at" + (fetmailalias.nil? || fetmail.empty?) ? short.to_s + "@fet.at" : fetmailalias.to_s + "@fet.at" end end diff --git a/app/views/fetprofiles/_tabs.html.erb b/app/views/fetprofiles/_tabs.html.erb index 902e756..71f204d 100644 --- a/app/views/fetprofiles/_tabs.html.erb +++ b/app/views/fetprofiles/_tabs.html.erb @@ -1,24 +1,25 @@ diff --git a/app/views/fetprofiles/index.html.erb b/app/views/fetprofiles/index.html.erb index 2da2a16..080f97c 100644 --- a/app/views/fetprofiles/index.html.erb +++ b/app/views/fetprofiles/index.html.erb @@ -6,26 +6,27 @@ %>
<%= link_to I18n.t('fetprofiles.new'), new_fetprofile_path %> -
+ + + diff --git a/app/views/fetprofiles/show.html.erb b/app/views/fetprofiles/show.html.erb index bf632cc..ba637c8 100644 --- a/app/views/fetprofiles/show.html.erb +++ b/app/views/fetprofiles/show.html.erb @@ -6,7 +6,6 @@

<%= @fetprofile.name %>

-

<%= @fetprofile.fetmailalias %>

@@ -14,9 +13,8 @@ <%= @fetprofile.desc %>

- <%= ""+I18n.t('fetprofiles.active')+"".html_safe if @fetprofile.active %> -

-

<%= link_to 'Destroy', @fetprofile, method: :delete, data: { confirm: 'Are you sure?' } %>

+ <%= link_to 'Destroy', @fetprofile, method: :delete, data: { confirm: 'Are you sure?' } %> +

@@ -26,15 +24,11 @@ <% @fetprofile.memberships.each do |m| %>
  • <%= render m %> - <% link_to 'edit', edit_fetprofile_membership_path(@fetprofile,m) %> + <%= link_to 'edit', edit_fetprofile_membership_path(@fetprofile,m) if params["verwalten"]%> + <%= link_to 'delete', [@fetprofile, m], method: :delete, data: {confirm: 'Sure?'} if params["verwalten"] %>
  • <% end %> - - - <%= link_to 'Neue Mitgliedschaft', new_fetprofile_membership_path(@fetprofile) %> | - - <%= link_to 'Edit', edit_fetprofile_path(@fetprofile) %> | - <%= link_to 'Back', fetprofiles_path %> + <%= render 'layouts/pretty_toolbar' %> diff --git a/app/views/gremien/show.html.erb b/app/views/gremien/show.html.erb index 0383c88..d87e96a 100644 --- a/app/views/gremien/show.html.erb +++ b/app/views/gremien/show.html.erb @@ -16,10 +16,14 @@ <% r.each do |m| %> <%= link_to m.fetprofile do %>
    - <%= image_tag m.fetprofile.picture.portrait %> -

    + <%= image_tag m.fetprofile.try(:picture).try(:portrait) %> +

    + <% if m.fetprofile.nil?%> + PROFIL fehlt + <% else %> <%= m.fetprofile.name %>
    <%= render(m) %> + <% end %>

    <% end %> diff --git a/app/views/gremien/verwalten.html.erb b/app/views/gremien/verwalten.html.erb index ec214f0..3348678 100644 --- a/app/views/gremien/verwalten.html.erb +++ b/app/views/gremien/verwalten.html.erb @@ -5,15 +5,25 @@
    <%= gremium.typ %>
    -
    +
    <%= gremium.name %> <%= gremium.desc %>
    -
    - <%= link_to 'Show', gremium %> - <%= link_to 'Edit', edit_gremium_path(gremium) %> - <%= link_to 'Destroy', gremium, method: :delete, data: { confirm: 'Are you sure?' } %> +
    +
    + <%= link_to 'Show', gremium,{:class=>"btn"} %> + + +
    +
    <% end %>