Mercurial > hg > soundsoftware-site
changeset 60:cf39b52d24b4 luisf
DEVELOPMENT COMMIT: The description can now be seen and edited BUT when a new user registers the informations is not saved to the correct table.
author | luisf |
---|---|
date | Wed, 01 Dec 2010 18:04:19 +0000 |
parents | 7ff14a13f48a |
children | aedfe093ec32 |
files | app/controllers/account_controller.rb app/controllers/users_controller.rb app/models/ssamr_user_detail.rb app/models/user.rb app/views/account/register.rhtml app/views/users/_form.rhtml config/locales/en-GB.yml config/locales/en.yml |
diffstat | 8 files changed, 53 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controllers/account_controller.rb Wed Dec 01 00:21:03 2010 +0000 +++ b/app/controllers/account_controller.rb Wed Dec 01 18:04:19 2010 +0000 @@ -77,18 +77,17 @@ # User self-registration def register redirect_to(home_url) && return unless Setting.self_registration? || session[:auth_source_registration] + if request.get? session[:auth_source_registration] = nil @user = User.new(:language => Setting.default_language) + else @user = User.new(params[:user]) @user.admin = false + + @user.register - - @user.description = params[:description] - - - @user.register if session[:auth_source_registration] @user.activate @user.login = session[:auth_source_registration][:login]
--- a/app/controllers/users_controller.rb Wed Dec 01 00:21:03 2010 +0000 +++ b/app/controllers/users_controller.rb Wed Dec 01 18:04:19 2010 +0000 @@ -53,9 +53,7 @@ @user = User.find(params[:id]) @description = @user.ssamr_user_detail.description - - # @description = @user.ssamr_user_detail.description - + # show projects based on current user visibility @memberships = @user.memberships.all(:conditions => Project.visible_by(User.current)) @@ -74,12 +72,15 @@ render_404 end - def new + def new @notification_options = User::MAIL_NOTIFICATION_OPTIONS @notification_option = Setting.default_notification_option @user = User.new(:language => Setting.default_language) @auth_sources = AuthSource.find(:all) + + @ssamr_user_details = SsamrUserDetail.new + end verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } @@ -87,22 +88,24 @@ @notification_options = User::MAIL_NOTIFICATION_OPTIONS @notification_option = Setting.default_notification_option - @user = User.new(params[:user]) + @user = User.new(params[:user]) @user.admin = params[:user][:admin] || false @user.login = params[:user][:login] @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id - @user.ssamr_user_detail.description = params[:user.ssamr_user_detail][:description] - - @ssamr_description = params[:user.ssamr_user_detail][:description] - # TODO: Similar to My#account @user.mail_notification = params[:notification_option] || 'only_my_events' @user.pref.attributes = params[:pref] @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') + @ssamr_user_details = @user.ssamr_user_detail + @ssamr_user_details.description = params[:ssamr_user_details][:description] + if @user.save @user.pref.save + + @ssamr_user_details.save! + @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) Mailer.deliver_account_information(@user, params[:password]) if params[:send_information] @@ -123,8 +126,8 @@ @notification_options = @user.valid_notification_options @notification_option = @user.mail_notification -# @ssamr_description = @user.ssamr_user_detail - + @ssamr_user_details = @user.ssamr_user_detail + @auth_sources = AuthSource.find(:all) @membership ||= Member.new end @@ -132,7 +135,7 @@ verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } def update @user = User.find(params[:id]) - + @notification_options = @user.valid_notification_options @notification_option = @user.mail_notification @@ -150,11 +153,17 @@ @user.pref.attributes = params[:pref] @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') + @ssamr_user_details = @user.ssamr_user_detail + @ssamr_user_details.description = params[:ssamr_user_details][:description] + + @ssamr_user_details.save! + + if @user.save @user.pref.save @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) - if was_activated + if was_activatedd Mailer.deliver_account_activated(@user) elsif @user.active? && params[:send_information] && !params[:password].blank? && @user.auth_source_id.nil? Mailer.deliver_account_information(@user, params[:password])
--- a/app/models/ssamr_user_detail.rb Wed Dec 01 00:21:03 2010 +0000 +++ b/app/models/ssamr_user_detail.rb Wed Dec 01 18:04:19 2010 +0000 @@ -1,3 +1,5 @@ class SsamrUserDetail < ActiveRecord::Base - belongs_to :user + belongs_to :user + + validates_presence_of :user end
--- a/app/models/user.rb Wed Dec 01 00:21:03 2010 +0000 +++ b/app/models/user.rb Wed Dec 01 18:04:19 2010 +0000 @@ -64,6 +64,9 @@ attr_protected :login, :admin, :password, :password_confirmation, :hashed_password, :group_ids validates_presence_of :login, :firstname, :lastname, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) } + + # TODO: is this validation correct validates_presence_of :ssamr_user_detail + validates_uniqueness_of :login, :if => Proc.new { |user| !user.login.blank? }, :case_sensitive => false validates_uniqueness_of :mail, :if => Proc.new { |user| !user.mail.blank? }, :case_sensitive => false # Login must contain lettres, numbers, underscores only
--- a/app/views/account/register.rhtml Wed Dec 01 00:21:03 2010 +0000 +++ b/app/views/account/register.rhtml Wed Dec 01 18:04:19 2010 +0000 @@ -26,14 +26,19 @@ <p><label for="user_mail"><%=l(:field_mail)%> <span class="required">*</span></label> <%= text_field 'user', 'mail' %></p> -<p><label for="ssamr_user_description"><%=l(:field_ssamr_description)%><span class="required">*</span></label> -<%= text_field 'user.ssamr_user_detail', 'description' %></p> - - <p><label for="user_language"><%=l(:field_language)%></label> <%= select("user", "language", lang_options_for_select) %></p> +<h3><%=l(:label_ssamr_details)%></h3> + <%= error_messages_for :ssamr_user_details %> + <% fields_for :ssamr_user_details, :builder => TabularFormBuilder, :lang => current_language do |ssamr_user_detail| %> + <p><%= ssamr_user_detail.text_area :description, :rows => 3, :cols => 40, :required => true %></p> + <% end %> + + + + <% if Setting.openid? %> <p><label for="user_identity_url"><%=l(:field_identity_url)%></label> <%= text_field 'user', 'identity_url' %></p>
--- a/app/views/users/_form.rhtml Wed Dec 01 00:21:03 2010 +0000 +++ b/app/views/users/_form.rhtml Wed Dec 01 18:04:19 2010 +0000 @@ -20,8 +20,11 @@ </div> <div class="box tabular"> - <h3><%=l(:label_ssamr_detail)%></h3> - <p><%= f.text_field User.description, :size => 25 %></p> + <h3><%=l(:label_ssamr_details)%></h3> + <%= error_messages_for :ssamr_user_details %> + <% fields_for :ssamr_user_details, :builder => TabularFormBuilder, :lang => current_language do |ssamr_user_detail| %> + <p><%= ssamr_user_detail.text_area :description, :rows => 3, :cols => 40, :required => true %></p> + <% end %> </div> <div class="box tabular">
--- a/config/locales/en-GB.yml Wed Dec 01 00:21:03 2010 +0000 +++ b/config/locales/en-GB.yml Wed Dec 01 18:04:19 2010 +0000 @@ -410,6 +410,9 @@ label_tipoftheday: Tip of the day label_notifications: Important Message + label_ssamr_description: Description + label_ssamr_details: Other Details + label_user: User label_user_plural: Users label_user_new: New user
--- a/config/locales/en.yml Wed Dec 01 00:21:03 2010 +0000 +++ b/config/locales/en.yml Wed Dec 01 18:04:19 2010 +0000 @@ -299,11 +299,12 @@ field_text: Text field field_visible: Visible + setting_tipoftheday_text: Tip of the Day + setting_notifications_text: Notifications + label_ssamr_description: Description setting_app_title: Application title setting_app_subtitle: Application subtitle setting_welcome_text: Welcome text - setting_tipoftheday_text: Tip of the Day - setting_notifications_text: Notifications setting_default_language: Default language setting_login_required: Authentication required setting_self_registration: Self-registration @@ -425,6 +426,7 @@ project_module_gantt: Gantt label_tipoftheday: Tip of the day + label_ssamr_details: Other Details label_user: User label_user_plural: Users label_user_new: New user