diff options
author | Julian Pawlowski <julian.pawlowski@gmail.com> | 2013-01-16 21:06:22 +0100 |
---|---|---|
committer | Julian Pawlowski <julian.pawlowski@gmail.com> | 2013-01-16 21:06:22 +0100 |
commit | 6a3eb3a21958e4bc1a73e5774c3717fc01ee64e0 (patch) | |
tree | 933902730c79edb8f1f8372ce6af6217433c9a84 | |
parent | ea70e08534319dd3f15c34859c498771fa7d9b32 (diff) | |
parent | a74efe4bb1b5afeaf892d18ba2e7969ed17b4099 (diff) |
Merge branch 'develop' of https://github.com/amooma/GS5 into develop
-rw-r--r-- | app/controllers/gemeinschaft_setups_controller.rb | 18 | ||||
-rw-r--r-- | app/models/gemeinschaft_setup.rb | 9 | ||||
-rw-r--r-- | app/views/users/_form_core.html.haml | 2 | ||||
-rw-r--r-- | db/schema.rb | 2 | ||||
-rw-r--r-- | lib/tasks/heater.rake | 11 |
5 files changed, 27 insertions, 15 deletions
diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb index dbe8ff5..27c0a83 100644 --- a/app/controllers/gemeinschaft_setups_controller.rb +++ b/app/controllers/gemeinschaft_setups_controller.rb @@ -1,8 +1,12 @@ class GemeinschaftSetupsController < ApplicationController + # We use the heater rake task to generate this file. + # So it loads super fast even on slow machines. + # + caches_page :new, :gzip => :best_compression + load_and_authorize_resource :gemeinschaft_setup skip_before_filter :go_to_setup_if_new_installation - # before_filter :redirect_if_not_a_fresh_installation def new @user = @gemeinschaft_setup.build_user( @@ -62,16 +66,4 @@ class GemeinschaftSetupsController < ApplicationController end end - private - - def redirect_if_not_a_fresh_installation - if GemeinschaftSetup.all.count > 0 - if current_user - redirect_to root_url , :alert => t('gemeinschaft_setups.initial_setup.access_denied_only_available_on_a_new_system') - else - redirect_to log_in_path , :alert => t('gemeinschaft_setups.initial_setup.access_denied_only_available_on_a_new_system') - end - end - end - end diff --git a/app/models/gemeinschaft_setup.rb b/app/models/gemeinschaft_setup.rb index b445b21..0b3eeae 100644 --- a/app/models/gemeinschaft_setup.rb +++ b/app/models/gemeinschaft_setup.rb @@ -5,4 +5,13 @@ class GemeinschaftSetup < ActiveRecord::Base accepts_nested_attributes_for :sip_domain belongs_to :country belongs_to :language + + # Remove the cache which was created by the heater rake task. + # + after_create :expire_cache + + private + def expire_cache + ActionController::Base.expire_page(Rails.application.routes.url_helpers.new_gemeinschaft_setup_path) + end end diff --git a/app/views/users/_form_core.html.haml b/app/views/users/_form_core.html.haml index 8e18d12..24b15f5 100644 --- a/app/views/users/_form_core.html.haml +++ b/app/views/users/_form_core.html.haml @@ -1,6 +1,6 @@ .inputs - if GuiFunction.display?('name_data_fields_in_user_edit_form', current_user) - = f.input :male, :collection => [[true, t('users.form.gender.male')], [false, t('users.form.gender.female')]], :label_method => :last, :value_method => :first, :label => t('users.form.male.label'), :hint => conditional_hint('users.form.gender.hint'), :label => t('users.form.gender.label'), :as => :radio + = f.input :male, :collection => [[true, t('users.form.gender.male')], [false, t('users.form.gender.female')]], :label_method => :last, :value_method => :first, :label => t('users.form.male.label'), :hint => conditional_hint('users.form.gender.hint'), :label => t('users.form.gender.label'), :as => :radio_buttons = f.input :first_name, :label => t('users.form.first_name.label'), :hint => conditional_hint('users.form.first_name.hint'), :autofocus => true = f.input :middle_name, :label => t('users.form.middle_name.label'), :hint => conditional_hint('users.form.middle_name.hint') = f.input :last_name, :label => t('users.form.last_name.label'), :hint => conditional_hint('users.form.last_name.hint') diff --git a/db/schema.rb b/db/schema.rb index 898faac..bc4f737 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130116133433) do +ActiveRecord::Schema.define(:version => 20130116145500) do create_table "access_authorizations", :force => true do |t| t.string "access_authorizationable_type" diff --git a/lib/tasks/heater.rake b/lib/tasks/heater.rake index 7d026d9..11862a5 100644 --- a/lib/tasks/heater.rake +++ b/lib/tasks/heater.rake @@ -1,6 +1,17 @@ namespace :heater do desc "Warm up the cache." task :preheat => :environment do + if GemeinschaftSetup.any? + else + # This is a fresh installation. + # + if Rails.env.production? + require 'open-uri' + open('/dev/null', 'wb') do |file| + file << open("http://localhost/gemeinschaft_setups/new").read + end + end + end end end
\ No newline at end of file |