From 56f32606dcc35bfbce4d327d363598b6ea5d2e35 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Mon, 16 Dec 2013 10:27:15 +0100 Subject: [PATCH] user und fetprofile link --- app/controllers/users_controller.rb | 11 +++++ app/models/fetprofile.rb | 4 +- app/models/user.rb | 9 ++++- app/views/neuigkeiten/show.html.erb | 2 +- app/views/users/index.html.erb | 62 ++++++++++++++++++----------- 5 files changed, 60 insertions(+), 28 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2741498..474839f 100755 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -12,6 +12,17 @@ class UsersController < ApplicationController end redirect_to users_url end + + def all_update + + params[:users].each do |id,u| + user=User.find(id) + user.fetprofile = Fetprofile.find(u[:fetprofile_id].to_i) if u[:fetprofile_id].to_i>0 + user.save if can? :edit, User + end + redirect_to users_url + end + def do_confirm @user= User.find(params[:id]) @user.confirm! diff --git a/app/models/fetprofile.rb b/app/models/fetprofile.rb index bd810ee..7c23182 100644 --- a/app/models/fetprofile.rb +++ b/app/models/fetprofile.rb @@ -23,9 +23,9 @@ class Fetprofile < ActiveRecord::Base validates :desc, :presence=>true validates :nachname, length:{minimum: 3},:presence=>true validates :vorname, length:{minimum: 3},:presence=>true - + has_many :users - accepts_nested_attributes_for :memberships, :reject_if=>lambda{|a| a[:typ].blank?|| a[:start].blank? ||a[:gremium_id].blank?} + accepts_nested_attributes_for :memberships, :reject_if=>lambda{|a| a[:typ].blank?|| a[:start].blank? ||a[:gremium_id].blank?}, :allow_destroy=>true def name [vorname, nachname, ((short.empty?)? "": ["(",short,")"].join)].join(" ") diff --git a/app/models/user.rb b/app/models/user.rb index d764a1d..a18646b 100755 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -33,6 +33,7 @@ class User < ActiveRecord::Base # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me, :provider, :uid, :name +belongs_to :fetprofile # attr_accessible :title, :body def self.find_for_facebook_oauth(auth, signed_in_resource=nil) logger.debug auth.to_s @@ -79,5 +80,11 @@ logger.debug auth.to_s end end end - + def text + if self.fetprofile.nil? + self.email +else +self.fetprofile.name +end +end end diff --git a/app/views/neuigkeiten/show.html.erb b/app/views/neuigkeiten/show.html.erb index 36de7a7..aae1ba9 100755 --- a/app/views/neuigkeiten/show.html.erb +++ b/app/views/neuigkeiten/show.html.erb @@ -6,7 +6,7 @@ <%= @neuigkeit.author.email.to_s unless @neuigkeit.try(:author).try(:email).to_s %> - <%= "am " + I18n.l(@neuigkeit.try(:datum).try(:to_date)) unless @neuigkeit.try(:datum).try(:to_date).nil? %> + <%= @neuigkeit.author.text+ " am " + I18n.l(@neuigkeit.try(:datum).try(:to_date)) unless @neuigkeit.try(:datum).try(:to_date).nil? %>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 5e21ced..30fc2c1 100755 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -3,31 +3,45 @@ <%= link_to "Admin" , :controller =>"config" , :action => "index"%> + +<%= semantic_form_for "users[]", :url=>all_update_users_path do |ff|%> - - -<% @users.each do |user|%> - - - + + <% @users.each do |user|%> -
- - Action - - - -
- -<% end %> + + + + + + + <% end %>
E-MailRollenActions
- <%= user.email %>
    - <% user.roles.each do |role| %> -
  • <%= role.name%>
  • -<% end %>
+
E-MailRollenActionsProfile
<%= user.email %> +
    + <% user.roles.each do |role| %>
  • <%= role.name%>
  • <% end %> +
+
+
+ + Action + + + +
+
+ <%= semantic_fields_for "users[#{user.id}]", user do |f|%> + <%= f.input :fetprofile ,:label=>false , :as=>:select , :collection=>Fetprofile.all %> + + <% end %> +
+<%= ff.actions do %> + <%= ff.action :submit, :as => :button %> + <%= ff.action :cancel, :as => :link %> + <% end %> +<% end %>