Mercurial > hg > soundsoftware-site
changeset 108:d70a0b926135 luisf
Feature #52: All users can now view and edit their description and university
author | luisf |
---|---|
date | Fri, 17 Dec 2010 13:02:30 +0000 |
parents | 361f1e8b2e23 |
children | b0086cb55640 3e75f003034a |
files | app/controllers/my_controller.rb app/controllers/users_controller.rb app/views/my/account.rhtml |
diffstat | 3 files changed, 46 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controllers/my_controller.rb Fri Dec 17 11:18:51 2010 +0000 +++ b/app/controllers/my_controller.rb Fri Dec 17 13:02:30 2010 +0000 @@ -52,11 +52,29 @@ def account @user = User.current @pref = @user.pref + @ssamr_user_details = @user.ssamr_user_detail if request.post? @user.attributes = params[:user] @user.mail_notification = params[:notification_option] || 'only_my_events' @user.pref.attributes = params[:pref] @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') + + if @user.ssamr_user_detail == nil + @ssamr_user_details = SsamrUserDetail.new() + @user.ssamr_user_detail = @ssamr_user_details + else + @ssamr_user_details = @user.ssamr_user_detail + end + + if params[:ssamr_user_details].nil? or params[:ssamr_user_details].empty? + @ssamr_user_details.description = @user.ssamr_user_detail.description + @ssamr_user_details.institution_id = @user.ssamr_user_detail.institution_id + else + @ssamr_user_details.description = params[:ssamr_user_details][:description] + @ssamr_user_details.institution_id = params[:ssamr_user_details][:institution_id] + @ssamr_user_details.save! + end + if @user.save @user.pref.save @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
--- a/app/controllers/users_controller.rb Fri Dec 17 11:18:51 2010 +0000 +++ b/app/controllers/users_controller.rb Fri Dec 17 13:02:30 2010 +0000 @@ -166,12 +166,13 @@ else @ssamr_user_details = @user.ssamr_user_detail end - - + if params[:ssamr_user_details].nil? or params[:ssamr_user_details].empty? @ssamr_user_details.description = @user.ssamr_user_detail.description + @ssamr_user_details.institution_id = @user.ssamr_user_detail.institution_id else @ssamr_user_details.description = params[:ssamr_user_details][:description] + @ssamr_user_details.institution_id = params[:ssamr_user_details][:institution_id] @ssamr_user_details.save! end
--- a/app/views/my/account.rhtml Fri Dec 17 11:18:51 2010 +0000 +++ b/app/views/my/account.rhtml Fri Dec 17 13:02:30 2010 +0000 @@ -9,6 +9,8 @@ :builder => TabularFormBuilder, :lang => current_language, :html => { :id => 'my_account_form' } do |f| %> + + <div class="splitcontentleft"> <h3><%=l(:label_information_plural)%></h3> <div class="box tabular"> @@ -23,9 +25,24 @@ <% @user.custom_field_values.select(&:editable?).each do |value| %> <p><%= custom_field_tag_with_label :user, value %></p> <% end %> + <%= call_hook(:view_my_account, :user => @user, :form => f) %> </div> +<h3><%=l(:label_ssamr_details)%></h3> +<div class="box tabular"> + <% fields_for :ssamr_user_details, :builder => TabularFormBuilder, :lang => current_language do |ssamr_user_detail| %> + <p> + <%= ssamr_user_detail.text_area :description, :rows => 3, :cols => 25, :required => true, :class => 'wiki-edit' %> + </p> + <p> + <label for="ssamr_user_institution"><%=l(:label_ssamr_institution)%></label> + <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:selected => @user.ssamr_user_detail.institution_id.to_i} ) %> + </p> + <% end %> +</div> + + <%= submit_tag l(:button_save) %> </div> @@ -43,6 +60,14 @@ </div> <% end %> + + + + + + + + <% content_for :sidebar do %> <%= render :partial => 'sidebar' %> <% end %>