Mercurial > hg > soundsoftware-site
changeset 193:90cc857e968a luisf
Merge from branch "feature_64"
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Mon, 07 Feb 2011 12:52:57 +0000 |
parents | e5171a80c541 (current diff) d1713ab10813 (diff) |
children | 2eaccf99a7b0 61d8fba252fd |
files | config/locales/en-GB.yml config/locales/en.yml |
diffstat | 18 files changed, 345 insertions(+), 169 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controllers/account_controller.rb Mon Jan 24 14:35:24 2011 +0000 +++ b/app/controllers/account_controller.rb Mon Feb 07 12:52:57 2011 +0000 @@ -108,7 +108,9 @@ # associates the 2 objects @user.ssamr_user_detail = @ssamr_user_details + @selected_institution_id = params[:ssamr_user_details][:institution_id].to_i + case Setting.self_registration when '1' register_by_email_activation(@user)
--- a/app/controllers/my_controller.rb Mon Jan 24 14:35:24 2011 +0000 +++ b/app/controllers/my_controller.rb Mon Feb 07 12:52:57 2011 +0000 @@ -53,6 +53,14 @@ @user = User.current @pref = @user.pref @ssamr_user_details = @user.ssamr_user_detail + + + if @user.ssamr_user_detail == nil + @selected_institution_id = nil + else + @selected_institution_id = @ssamr_user_details.institution_id.to_i + end + if request.post? @user.attributes = params[:user] @user.mail_notification = params[:notification_option] || 'only_my_events' @@ -69,12 +77,15 @@ 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 + @institution_type = @ssamr_user_details.institution_type + @other_institution = @ssamr_user_details.other_institution 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! + @ssamr_user_details.institution_type = params[:ssamr_user_details][:institution_type] + @ssamr_user_details.other_institution = params[:ssamr_user_details][:other_institution] 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 Mon Jan 24 14:35:24 2011 +0000 +++ b/app/controllers/users_controller.rb Mon Feb 07 12:52:57 2011 +0000 @@ -54,8 +54,14 @@ if @user.ssamr_user_detail != nil @description = @user.ssamr_user_detail.description - if @user.ssamr_user_detail.institution_id != nil - @institution_name = Institution.find(@user.ssamr_user_detail.institution_id).name + + if @user.ssamr_user_detail.institution_type != nil + # institution_type is true for listed institutions + if (@user.ssamr_user_detail.institution_type) + @institution_name = Institution.find(@user.ssamr_user_detail.institution_id).name + else + @institution_name = @user.ssamr_user_detail.other_institution + end end end @@ -85,11 +91,6 @@ @auth_sources = AuthSource.find(:all) @ssamr_user_details = SsamrUserDetail.new - - # default value - @selected_institution_id = 1 - - end verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } @@ -138,7 +139,12 @@ @notification_option = @user.mail_notification @ssamr_user_details = @user.ssamr_user_detail - @selected_institution_id = @user.ssamr_user_detail.institution_id.to_i + + if @user.ssamr_user_detail == nil + @selected_institution_id = nil + else + @selected_institution_id = @user.ssamr_user_detail.institution_id.to_i + end @auth_sources = AuthSource.find(:all) @membership ||= Member.new @@ -175,10 +181,14 @@ 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 + @ssamr_user_details.other_institution = @user.ssamr_user_detail.other_institution + @ssamr_user_details.institution_type = @user.ssamr_user_detail.institution_type + 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! + @ssamr_user_details.other_institution = params[:ssamr_user_details][:other_institution] + @ssamr_user_details.institution_type = params[:ssamr_user_details][:institution_type] end if @user.save
--- a/app/models/ssamr_user_detail.rb Mon Jan 24 14:35:24 2011 +0000 +++ b/app/models/ssamr_user_detail.rb Mon Feb 07 12:52:57 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/models/user.rb Mon Jan 24 14:35:24 2011 +0000 +++ b/app/models/user.rb Mon Feb 07 12:52:57 2011 +0000 @@ -79,6 +79,8 @@ validates_length_of :mail, :maximum => 60, :allow_nil => true validates_confirmation_of :password, :allow_nil => true + validates_acceptance_of :terms_and_conditions, :on => :create, :message => :must_accept_terms_and_conditions + def before_create self.mail_notification = Setting.default_notification_option if self.mail_notification.blank? true
--- a/app/views/account/register.rhtml Mon Jan 24 14:35:24 2011 +0000 +++ b/app/views/account/register.rhtml Mon Feb 07 12:52:57 2011 +0000 @@ -1,3 +1,6 @@ +<%= javascript_include_tag "ssamr_institutions" %> +<%= javascript_include_tag "ssamr_registration" %> + <h2><%=l(:label_register)%> <%=link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></h2> <% form_tag({:action => 'register'}, :class => "tabular") do %> @@ -34,21 +37,21 @@ <% 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, :class => 'wiki-edit' %> - <em> <%=l(:text_user_ssamr_description_info)%></em> </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.find(:all, :order => "institutions.order"), :id, :name, {:selected => @selected_institution_id, :prompt => true}).gsub('&', '&') %> + </p> + <p> - <label for="ssamr_user_institution"><%=l(:label_ssamr_institution)%></label> - <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:prompt => true}) %> + <%= ssamr_user_detail.radio_button :institution_type, false %> Other: + <%= ssamr_user_detail.text_field(:other_institution) %> </p> <% end %> - - - <% if Setting.openid? %> <p><label for="user_identity_url"><%=l(:field_identity_url)%></label> <%= text_field 'user', 'identity_url' %></p> @@ -60,5 +63,9 @@ <!--[eoform:user]--> </div> +<%= check_box :user, :terms_and_conditions %> <%= l(:accept_terms_and_conditions) %> <%= link_to("Terms and Conditions", "https://code.soundsoftware.ac.uk/projects/soundsoftware-site/wiki/TandCs", {:target => "_blank"}) %>. +<br /> +<br /> + <%= submit_tag l(:button_submit) %> <% end %>
--- a/app/views/my/account.rhtml Mon Jan 24 14:35:24 2011 +0000 +++ b/app/views/my/account.rhtml Mon Feb 07 12:52:57 2011 +0000 @@ -1,3 +1,5 @@ +<%= 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 +37,21 @@ <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> + <nobr> + <%= ssamr_user_detail.radio_button :institution_type, true %> + <%= ssamr_user_detail.collection_select(:institution_id, Institution.find(:all, :order => "institutions.order"), :id, :name, {:selected => @selected_institution_id, :prompt => true} ).gsub('&', '&') %> + </nobr> + </p> + + <p> + <nobr> + <%= ssamr_user_detail.radio_button :institution_type, false %> Other: + <%= ssamr_user_detail.text_field :other_institution, :size => 19 %> + </nobr> + </p> <% end %> </div>
--- a/app/views/users/_form.rhtml Mon Jan 24 14:35:24 2011 +0000 +++ b/app/views/users/_form.rhtml Mon Feb 07 12:52:57 2011 +0000 @@ -1,3 +1,6 @@ +<%= javascript_include_tag "ssamr_institutions" %> + + <%= error_messages_for 'user' %> <!--[form:user]--> @@ -25,11 +28,23 @@ <p> <%= ssamr_user_detail.text_area :description, :rows => 3, :cols => 40, :required => true, :class => 'wiki-edit' %> </p> + + <p><label for="institution"><%=l("field_ssamr_user_detail.institution")%> <span class="required">*</span></label> + <nobr> + <%= ssamr_user_detail.radio_button :institution_type, true %> + <%= ssamr_user_detail.collection_select(:institution_id, Institution.find(:all, :order => "institutions.order"), :id, :name, {:selected => @selected_institution_id, :prompt => true} ).gsub('&', '&') %> + </nobr> + </p> + + + <p> - <label for="ssamr_user_institution"><%=l(:label_ssamr_institution)%></label> - <%= ssamr_user_detail.collection_select(:institution_id, Institution.all, :id, :name, {:selected => @selected_institution_id} ) %> + <nobr> + <%= ssamr_user_detail.radio_button :institution_type, false %> Other: + <%= ssamr_user_detail.text_field :other_institution %> + </nobr> </p> - <% end %> + <% end %> </div>
--- a/config/locales/en-GB.yml Mon Jan 24 14:35:24 2011 +0000 +++ b/config/locales/en-GB.yml Mon Feb 07 12:52:57 2011 +0000 @@ -123,6 +123,7 @@ not_same_project: "doesn't belong to the same project" circular_dependency: "This relation would create a circular dependency" cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" + must_accept_terms_and_conditions: "You must accept the Terms and Conditions" actionview_instancetag_blank_option: Please select @@ -199,6 +200,10 @@ field_ssamr_user_detail: description: User Description + institution: Institution + + field_other_institution: '' + field_name: Name field_description: Description field_summary: Summary @@ -413,6 +418,8 @@ label_tipoftheday: Tip of the day label_notifications: Important Message + field_terms_and_conditions: 'Terms and Conditions:' + accept_terms_and_conditions: 'I have read and agree with the ' label_ssamr_description: Research description label_ssamr_details: Other Details label_ssamr_institution: Institution
--- a/config/locales/en.yml Mon Jan 24 14:35:24 2011 +0000 +++ b/config/locales/en.yml Mon Feb 07 12:52:57 2011 +0000 @@ -86,7 +86,6 @@ gb: "GB" tb: "TB" - # Used in array.to_sentence. support: array: @@ -120,6 +119,7 @@ not_same_project: "doesn't belong to the same project" circular_dependency: "This relation would create a circular dependency" cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks" + must_accept_terms_and_conditions: "You must accept the Terms and Conditions" actionview_instancetag_blank_option: Please select @@ -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 @@ -304,6 +308,8 @@ setting_tipoftheday_text: Tip of the Day setting_notifications_text: Notifications + field_terms_and_conditions: 'Terms and Conditions:' + accept_terms_and_conditions: 'I have read and agree with the ' label_ssamr_description: Research description setting_app_title: Application title setting_app_subtitle: Application subtitle
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/db/migrate/20110126153504_add_other_institution_column_to_ssamr_user_details.rb Mon Feb 07 12:52:57 2011 +0000 @@ -0,0 +1,9 @@ +class AddOtherInstitutionColumnToSsamrUserDetails < ActiveRecord::Migration + def self.up + add_column :ssamr_user_details, :other_institution, :string + end + + def self.down + remove_column :ssamr_user_details, :other_institution + end +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/db/migrate/20110127161758_add_institution_type_column_to_ssamr_user_details.rb Mon Feb 07 12:52:57 2011 +0000 @@ -0,0 +1,9 @@ +class AddInstitutionTypeColumnToSsamrUserDetails < ActiveRecord::Migration + def self.up + add_column :ssamr_user_details, :institution_type, :boolean + end + + def self.down + remove_column :ssamr_user_details, :institution_type + end +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/db/migrate/20110202170156_add_order_column_to_institutions.rb Mon Feb 07 12:52:57 2011 +0000 @@ -0,0 +1,9 @@ +class AddOrderColumnToInstitutions < ActiveRecord::Migration + def self.up + add_column :institutions, :order, :integer + end + + def self.down + remove_column :institutions, :order + end +end
--- a/db/seed_data/institutions.txt Mon Jan 24 14:35:24 2011 +0000 +++ b/db/seed_data/institutions.txt Mon Feb 07 12:52:57 2011 +0000 @@ -1,141 +1,141 @@ -University of Aberdeen -University of Abertay Dundee -Aberystwyth University -Anglia Ruskin University -University of the Arts London -Aston University -Bangor University -University of Bath -Bath Spa University -University of Bedfordshire -Birkbeck, University of London -University of Birmingham -Birmingham City University -Birmingham Conservatoire -University Centre at Blackburn College -University of Bolton -Bournemouth University -University of Bradford -University of Brighton -University of Bristol -Brunel University -University of Buckingham -Buckinghamshire New University -University of Cambridge -Institute of Cancer Research, University of London -Canterbury Christ Church University -Cardiff University -University of Central Lancashire -Central School of Speech and Drama, University of London -University of Chester -University of Chichester -City University London -Courtauld Institute of Art -Coventry University -Cranfield University -University for the Creative Arts -University of Cumbria -De Montfort University -University of Derby -University of Dundee -Durham University -University of East Anglia -University of East London -Edge Hill University -University of Edinburgh -Edinburgh Napier University -Institute of Education, University of London -University of Essex -University of Exeter -University of Glamorgan -University of Glasgow -Glasgow Caledonian University -University of Gloucestershire -Goldsmiths, University of London -University of Greenwich -Glyndŵr University -Heriot-Watt University -University of Hertfordshire -Heythrop College -University of Huddersfield -University of Hull -Hull York Medical School -Imperial College London -Keele University -University of Kent -King's College London -Kingston University -Lancaster University -University of Leeds -Leeds Metropolitan University -University of Leicester -University of Lincoln -University of Liverpool -Liverpool Hope University -Liverpool John Moores University -London Business School -London College of Music -London Metropolitan University -London School of Economics and Political Science -London School of Hygiene and Tropical Medicine -London South Bank University -Loughborough University -University of Manchester -Manchester Metropolitan University -Middlesex University -Newcastle University -University of Northampton -Northumbria University -University of Nottingham -Nottingham Trent University -The Open University -University of Oxford -Oxford Brookes University -Peninsula College of Medicine and Dentistry -University of Plymouth -University of Portsmouth -Queen's University Belfast -Queen Margaret University -Queen Mary, University of London -University of Reading -The Robert Gordon University, Aberdeen -Roehampton University -Royal Academy of Music -Royal College of Art -Royal Holloway, University of London -Royal Veterinary College -University of St Andrews -St George's, University of London -University of Salford -School of Advanced Study, University of London -School of Oriental and African Studies -School of Pharmacy, University of London -University of Sheffield -Sheffield Hallam University -University of Southampton -Southampton Solent University -Staffordshire University -University of Stirling -University of Strathclyde -University of Sunderland -University of Surrey -University of Sussex -Swansea Metropolitan University -Swansea University -University of Teesside -Thames Valley University -University of Ulster -University College London -University of Wales -University of Wales Institute, Cardiff -University of Wales, Newport -University of Wales, Trinity Saint David -University of Warwick -University of Westminster -University of the West of England -University of the West of Scotland -University of Winchester -University of Wolverhampton -University of Worcester -University of York -York St John University +University of Aberdeen|1 +University of Abertay Dundee |2 +Aberystwyth University|3 +Anglia Ruskin University|4 +University of the Arts London|5 +Aston University|6 +Bangor University|7 +University of Bath|8 +Bath Spa University|9 +University of Bedfordshire|10 +Birkbeck, University of London|11 +University of Birmingham|12 +Birmingham City University|13 +Birmingham Conservatoire|14 +University Centre at Blackburn College|15 +University of Bolton|16 +Bournemouth University|17 +University of Bradford|18 +University of Brighton|19 +University of Bristol|20 +Brunel University|21 +University of Buckingham|22 +Buckinghamshire New University|23 +University of Cambridge|24 +Institute of Cancer Research, University of London|25 +Canterbury Christ Church University|26 +Cardiff University|27 +University of Central Lancashire|28 +Central School of Speech and Drama, University of London|29 +University of Chester|30 +University of Chichester|31 +City University London|32 +Courtauld Institute of Art|33 +Coventry University|34 +Cranfield University|35 +University for the Creative Arts|36 +University of Cumbria|37 +De Montfort University|38 +University of Derby|39 +University of Dundee|40 +Durham University|41 +University of East Anglia|42 +University of East London|43 +Edge Hill University|44 +University of Edinburgh|45 +Edinburgh Napier University|46 +Institute of Education, University of London|47 +University of Essex|48 +University of Exeter|49 +University of Glamorgan|50 +University of Glasgow|51 +Glasgow Caledonian University|52 +University of Gloucestershire|53 +Goldsmiths, University of London|54 +University of Greenwich|55 +Glyndŵr University|56 +Heriot-Watt University|57 +University of Hertfordshire|58 +Heythrop College|59 +University of Huddersfield|60 +University of Hull|61 +Hull York Medical School|62 +Imperial College London|63 +Keele University|64 +University of Kent|65 +King's College London|66 +Kingston University|67 +Lancaster University|68 +University of Leeds|69 +Leeds Metropolitan University|70 +University of Leicester|71 +University of Lincoln|72 +University of Liverpool|73 +Liverpool Hope University|74 +Liverpool John Moores University|75 +London Business School|76 +London College of Music|77 +London Metropolitan University|78 +London School of Economics and Political Science|79 +London School of Hygiene and Tropical Medicine|80 +London South Bank University|81 +Loughborough University|82 +University of Manchester|83 +Manchester Metropolitan University|84 +Middlesex University|85 +Newcastle University|86 +University of Northampton|87 +Northumbria University|88 +University of Nottingham|89 +Nottingham Trent University|90 +The Open University|91 +University of Oxford|92 +Oxford Brookes University|93 +Peninsula College of Medicine and Dentistry|94 +University of Plymouth|95 +University of Portsmouth|96 +Queen's University Belfast|97 +Queen Margaret University|98 +Queen Mary, University of London|99 +University of Reading|100 +The Robert Gordon University, Aberdeen|101 +Roehampton University|102 +Royal Academy of Music|103 +Royal College of Art|104 +Royal Holloway, University of London|105 +Royal Veterinary College|106 +University of St Andrews|107 +St George's, University of London|108 +University of Salford|109 +School of Advanced Study, University of London|110 +School of Oriental and African Studies|111 +School of Pharmacy, University of London|112 +University of Sheffield|113 +Sheffield Hallam University|114 +University of Southampton|115 +Southampton Solent University|116 +Staffordshire University|117 +University of Stirling|118 +University of Strathclyde|119 +University of Sunderland|120 +University of Surrey|121 +University of Sussex|122 +Swansea Metropolitan University|123 +Swansea University|124 +University of Teesside|125 +Thames Valley University|126 +University of Ulster|127 +University College London|128 +University of Wales|129 +University of Wales Institute, Cardiff|130 +University of Wales, Newport|131 +University of Wales, Trinity Saint David|132 +University of Warwick|133 +University of Westminster|134 +University of the West of England|135 +University of the West of Scotland|136 +University of Winchester|137 +University of Wolverhampton|138 +University of Worcester|139 +University of York|140 +York St John University|141
--- a/db/seeds.rb Mon Jan 24 14:35:24 2011 +0000 +++ b/db/seeds.rb Mon Feb 07 12:52:57 2011 +0000 @@ -6,10 +6,22 @@ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Major.create(:name => 'Daley', :city => cities.first) -Institution.delete_all +def truncate_table(table_name) + quoted = connection.quote_table_name(table_name) + connection.execute("TRUNCATE #{quoted}") +end + +def connection + ActiveRecord::Base.connection +end + +truncate_table('institutions') open("db/seed_data/institutions.txt") do |institutions| institutions.read.each_line do |institution| - Institution.create(:name => institution.chomp) + inst=institution.split('|') + + + Institution.create(:name => inst[0].chomp, :order => inst[1].chomp) end end \ No newline at end of file
--- a/public/javascripts/application.js Mon Jan 24 14:35:24 2011 +0000 +++ b/public/javascripts/application.js Mon Feb 07 12:52:57 2011 +0000 @@ -239,3 +239,7 @@ } Event.observe(window, 'load', hideOnLoad); + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/public/javascripts/ssamr_institutions.js Mon Feb 07 12:52:57 2011 +0000 @@ -0,0 +1,32 @@ + + +/* SSAMR specific functions */ + +/* institution related functions */ +Event.observe(window, 'load', + function() { + $('ssamr_user_details_institution_type_true').observe('click', function(e, el) { + $('ssamr_user_details_other_institution').disable(); + $('ssamr_user_details_institution_id').enable(); + }); + + $('ssamr_user_details_institution_type_false').observe('click', function(e, el) { + $('ssamr_user_details_other_institution').enable(); + $('ssamr_user_details_institution_id').disable(); + }); + + if($('ssamr_user_details_institution_type_true').checked) + $('ssamr_user_details_other_institution').disable(); + else if($('ssamr_user_details_institution_type_false').checked) + $('ssamr_user_details_institution_id').disable(); + else { + $('ssamr_user_details_other_institution').disable(); + $('ssamr_user_details_institution_id').enable(); + $('ssamr_user_details_institution_type_true').checked = true; + $('ssamr_user_details_institution_type_false').checked = false; + } +} +); + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/public/javascripts/ssamr_registration.js Mon Feb 07 12:52:57 2011 +0000 @@ -0,0 +1,19 @@ + + +/* SSAMR specific functions */ + +/* institution related functions */ +Event.observe(window, 'load', + function() { + + if(!$('ssamr_user_details_institution_type_true').checked && $('ssamr_user_details_institution_type_true').checked){ + $('ssamr_user_details_other_institution').disable(); + $('ssamr_user_details_institution_id').enable(); + $('ssamr_user_details_institution_type_true').checked = true; + $('ssamr_user_details_institution_type_false').checked = false; + } + } +); + + +