changeset 163:9a5a265e77f0 feature_55

labels correctly named institution field is now mandatory and validated.
author luisf
date Mon, 31 Jan 2011 18:10:55 +0000
parents bd3f92477cbb
children bb9724ba3d60
files app/models/ssamr_user_detail.rb app/views/account/register.rhtml app/views/my/account.rhtml app/views/users/_form.rhtml config/locales/en-GB.yml config/locales/en.yml
diffstat 6 files changed, 35 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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 @@
                           <em> <%=l(:text_user_ssamr_description_info)%></em>
                         </p>
 
-                        <p>
+                        <p><label for="institution"><%=l("field_ssamr_user_detail.institution")%> <span class="required">*</span></label>
                           <%= ssamr_user_detail.radio_button :institution_type, true %>
                           <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:prompt => true}) %>
                         </p>
--- 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" %>
+
+
 <div class="contextual">
 <%= 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 @@
        <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>
+
+
+            <p><label for="institution"><%=l("field_ssamr_user_detail.institution")%> <span class="required">*</span></label>
+              <%= ssamr_user_detail.radio_button :institution_type, true %>
+              <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:selected => @selected_institution_id} ) %>
+            </p>
+
+
+
+            <p>
+               <%= ssamr_user_detail.radio_button :institution_type, false %> Other:
+               <%= ssamr_user_detail.text_field :other_institution %>
+            </p>
     <% end %>
 </div>
 
--- 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 @@
             </p>
 
 
-            <p>
+            <p><label for="institution"><%=l("field_ssamr_user_detail.institution")%> <span class="required">*</span></label>
               <%= ssamr_user_detail.radio_button :institution_type, true %>
               <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:selected => @selected_institution_id} ) %>
             </p>
--- 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
--- 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