From bd656ee1c7cd6e48e9073ec2afea331030582c10 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Sun, 23 Dec 2012 21:03:37 +0100 Subject: [PATCH] fix #1350 by removing admin_email from preferences model and add it as a site option in site.yml.tmpl. This one needs running migrations --- app/controllers/users_controller.rb | 4 ++-- app/models/preference.rb | 2 +- app/views/preferences/_profile.html.erb | 5 +---- config/site.yml.tmpl | 4 ++++ db/migrate/20121223144702_no_default_admin_email.rb | 9 +++++++++ 5 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 db/migrate/20121223144702_no_default_admin_email.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d15581b1..cb5ee46c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -49,7 +49,7 @@ class UsersController < ApplicationController @user = get_new_user else # all other situations (i.e. a non-admin is logged in, or no one is logged in, but we have some users) @page_title = t('users.no_signups_title') - @admin_email = User.find_admin.preference.admin_email + @admin_email = SITE_CONFIG['admin_email'] render :action => "nosignup", :layout => "login" return end @@ -72,7 +72,7 @@ class UsersController < ApplicationController format.html do unless User.no_users_yet? || (@user && @user.is_admin?) || SITE_CONFIG['open_signups'] @page_title = t('users.no_signups_title') - @admin_email = User.find_admin.preference.admin_email + @admin_email = SITE_CONFIG['admin_email'] render :action => "nosignup", :layout => "login" return end diff --git a/app/models/preference.rb b/app/models/preference.rb index d730acc9..e34bfd6e 100644 --- a/app/models/preference.rb +++ b/app/models/preference.rb @@ -3,7 +3,7 @@ class Preference < ActiveRecord::Base belongs_to :sms_context, :class_name => 'Context' attr_accessible :date_format, :week_starts, :show_number_completed, :show_completed_projects_in_sidebar, - :show_hidden_contexts_in_sidebar, :staleness_starts, :due_style, :admin_email, :locale, + :show_hidden_contexts_in_sidebar, :staleness_starts, :due_style, :locale, :title_date_format, :time_zone, :show_hidden_projects_in_sidebar, :show_project_on_todo_done, :review_period, :refresh, :verbose_action_descriptors, :mobile_todos_per_page, :sms_email, :sms_context_id diff --git a/app/views/preferences/_profile.html.erb b/app/views/preferences/_profile.html.erb index 478df97b..9a27ae97 100644 --- a/app/views/preferences/_profile.html.erb +++ b/app/views/preferences/_profile.html.erb @@ -1,6 +1,3 @@ <%= pref_with_text_field 'user', 'first_name' %> <%= pref_with_text_field 'user', 'last_name' %> -<%= pref_with_select_field('prefs', 'locale', I18n.available_locales.map {|l| l.to_s}) %> -<% if current_user.is_admin? %> - <%= pref_with_text_field('prefs', 'admin_email') %> -<% end %> +<%= pref_with_select_field('prefs', 'locale', I18n.available_locales.map {|l| l.to_s}) %> \ No newline at end of file diff --git a/config/site.yml.tmpl b/config/site.yml.tmpl index c188e6c1..892046b1 100644 --- a/config/site.yml.tmpl +++ b/config/site.yml.tmpl @@ -45,3 +45,7 @@ open_signups: false # this value is the cloudmailin-secret for verifying the authenticity of the request. # (see http://docs.cloudmailin.com/validating_the_sender) # cloudmailin: asdasd + +# change this to reflect the email address of the admin that you want to show +# on the signup page +admin_email: my.email@domain.com \ No newline at end of file diff --git a/db/migrate/20121223144702_no_default_admin_email.rb b/db/migrate/20121223144702_no_default_admin_email.rb new file mode 100644 index 00000000..dedc0cb2 --- /dev/null +++ b/db/migrate/20121223144702_no_default_admin_email.rb @@ -0,0 +1,9 @@ +class NoDefaultAdminEmail < ActiveRecord::Migration + def up + remove_column :preferences, :admin_email + end + + def down + add_column :preferences, :admin_email, :string, {:default => "butshesagirl@rousette.org.uk", :null => false} + end +end