# HG changeset patch # User luisf # Date 1296497455 0 # Node ID 9a5a265e77f03fa4610ed70130605efc1ac9a404 # Parent bd3f92477cbb4c45beb766eda28894a09db27713 labels correctly named institution field is now mandatory and validated. diff -r bd3f92477cbb -r 9a5a265e77f0 app/models/ssamr_user_detail.rb --- a/app/models/ssamr_user_detail.rb Mon Jan 31 17:00:28 2011 +0000 +++ b/app/models/ssamr_user_detail.rb Mon Jan 31 18:10:55 2011 +0000 @@ -2,4 +2,13 @@ belongs_to :user validates_presence_of :description + + validate :check_institution + + def check_institution() + errors.add(:institution_id, "Please insert an institution") if + institution_id.blank? and other_institution.blank? + end + + end diff -r bd3f92477cbb -r 9a5a265e77f0 app/views/account/register.rhtml --- a/app/views/account/register.rhtml Mon Jan 31 17:00:28 2011 +0000 +++ b/app/views/account/register.rhtml Mon Jan 31 18:10:55 2011 +0000 @@ -41,7 +41,7 @@ <%=l(:text_user_ssamr_description_info)%>

-

+

<%= ssamr_user_detail.radio_button :institution_type, true %> <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:prompt => true}) %>

diff -r bd3f92477cbb -r 9a5a265e77f0 app/views/my/account.rhtml --- a/app/views/my/account.rhtml Mon Jan 31 17:00:28 2011 +0000 +++ b/app/views/my/account.rhtml Mon Jan 31 18:10:55 2011 +0000 @@ -1,3 +1,6 @@ +<%= javascript_include_tag "ssamr_institutions" %> + +
<%= link_to(l(:button_change_password), :action => 'password') if @user.change_password_allowed? %> <%= call_hook(:view_my_account_contextual, :user => @user)%> @@ -35,10 +38,19 @@

<%= ssamr_user_detail.text_area :description, :rows => 3, :cols => 25, :required => true, :class => 'wiki-edit' %>

-

- - <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:selected => @user.ssamr_user_detail.institution_id.to_i} ) %> -

+ + +

+ <%= ssamr_user_detail.radio_button :institution_type, true %> + <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:selected => @selected_institution_id} ) %> +

+ + + +

+ <%= ssamr_user_detail.radio_button :institution_type, false %> Other: + <%= ssamr_user_detail.text_field :other_institution %> +

<% end %>
diff -r bd3f92477cbb -r 9a5a265e77f0 app/views/users/_form.rhtml --- a/app/views/users/_form.rhtml Mon Jan 31 17:00:28 2011 +0000 +++ b/app/views/users/_form.rhtml Mon Jan 31 18:10:55 2011 +0000 @@ -30,7 +30,7 @@

-

+

<%= ssamr_user_detail.radio_button :institution_type, true %> <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:selected => @selected_institution_id} ) %>

diff -r bd3f92477cbb -r 9a5a265e77f0 config/locales/en-GB.yml --- a/config/locales/en-GB.yml Mon Jan 31 17:00:28 2011 +0000 +++ b/config/locales/en-GB.yml Mon Jan 31 18:10:55 2011 +0000 @@ -199,6 +199,10 @@ field_ssamr_user_detail: description: User Description + institution: Institution + + field_other_institution: '' + field_name: Name field_description: Description field_summary: Summary diff -r bd3f92477cbb -r 9a5a265e77f0 config/locales/en.yml --- a/config/locales/en.yml Mon Jan 31 17:00:28 2011 +0000 +++ b/config/locales/en.yml Mon Jan 31 18:10:55 2011 +0000 @@ -203,6 +203,10 @@ field_ssamr_user_detail: description: User Description + institution: Institution + + field_other_institution: '' + field_name: Name field_description: Description field_summary: Summary