diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 58097ec..e36543b 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -37,24 +37,20 @@ end end - - -def get_theme - -# if params[:theme]== "default" || params[:theme]=="2003" || params[:theme].nil? -# params[:theme]="blue1" -# end - if ThemesForRails.available_theme_names.include?(params[:theme]) and can? :showintern,Thema - params[:theme] + def get_theme +u=current_user + if ! u.try(:preferredtheme).nil? and ThemesForRails.available_theme_names.include?(u.preferredtheme) + u.preferredtheme else "blue1" end -end + + end def current_ability @current_ability ||= Ability.new(current_user, request) end def default_url_options - {locale: I18n.locale, theme: (theme_name=="blue1") ? nil : theme_name , ansicht: nil} + {locale: I18n.locale, theme: nil , ansicht: nil} end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1bfe832..7a1f425 100755 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -113,4 +113,17 @@ m.save url.path=path return url end + + def get_theme_help(u) + +# if params[:theme]== "default" || params[:theme]=="2003" || params[:theme].nil? +# params[:theme]="blue1" +# end + if ! u.try(:preferredtheme).nil? and ThemesForRails.available_theme_names.include?(u.preferredtheme) + u.preferredtheme + else + "blue1" + end +end + end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8993188..52b01f4 100755 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -28,7 +28,7 @@
- <% cache("menu_u"+user_signed_in?.to_s+current_user.try(:id).to_s+"l"+I18n.locale.to_s+ can?(:seeintern, User).to_s+ can?(:index,Gallery).to_s, expires_in: 24.hours) do %> + <% cache("menu_u"+user_signed_in?.to_s+current_user.try(:id).to_s+"l"+I18n.locale.to_s+ can?(:seeintern, User).to_s+ can?(:index,Gallery).to_s+params[:theme].to_s, expires_in: 24.hours) do %>
<%= link_to home_index_path do %> diff --git a/app/views/themes/blue1/home/index.html.erb b/app/views/themes/blue1/home/index.html.erb index 481b871..c62a6ea 100644 --- a/app/views/themes/blue1/home/index.html.erb +++ b/app/views/themes/blue1/home/index.html.erb @@ -54,7 +54,7 @@
-<% cache("calendar_" + cache_array_key(@calentries)+params[:month].to_s+params[:year].to_s) do %> +<% cache("calendar_" + cache_array_key(@calentries)+params[:month].to_s+params[:year].to_s+params[:theme].to_s) do %> <%= render 'calendars/calentries', :object=>@calentries %> <% end %> diff --git a/db/migrate/20150602085525_add_preferredtheme_to_users.rb b/db/migrate/20150602085525_add_preferredtheme_to_users.rb new file mode 100644 index 0000000..d59b47f --- /dev/null +++ b/db/migrate/20150602085525_add_preferredtheme_to_users.rb @@ -0,0 +1,5 @@ +class AddPreferredthemeToUsers < ActiveRecord::Migration + def change + add_column :users, :preferredtheme, :string + end +end