From 801f53f49f5440acaeba70c65df8d3e611c0b4c4 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 17:24:13 +0100 Subject: Fixed not rendered link to create a new SIP account. --- app/views/tenants/_sip_accounts_and_phones.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/tenants/_sip_accounts_and_phones.html.haml b/app/views/tenants/_sip_accounts_and_phones.html.haml index f9d26f9..618236f 100644 --- a/app/views/tenants/_sip_accounts_and_phones.html.haml +++ b/app/views/tenants/_sip_accounts_and_phones.html.haml @@ -18,7 +18,7 @@ =link_to "#{sip_account.caller_name}", tenant_sip_account_path(tenant,sip_account) - if sip_account.phone_numbers.any? = '[' + truncate(sip_account.phone_numbers.map{|phone_number| phone_number.to_s}.join(', '), :length => 25) + ']' - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => SipAccount} + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => SipAccount} %td - if tenant.users_sip_accounts.any? - if tenant.users_sip_accounts.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS') -- cgit v1.2.3 From 2928e0342ef45d5b6ecf27faf2940b424c8bd513 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 17:24:38 +0100 Subject: Temporarily fix. @span needs to have a look here. --- app/controllers/gemeinschaft_setups_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb index 7205a86..89a82cb 100644 --- a/app/controllers/gemeinschaft_setups_controller.rb +++ b/app/controllers/gemeinschaft_setups_controller.rb @@ -47,8 +47,8 @@ class GemeinschaftSetupsController < ApplicationController GsParameter.where(:name => 'user_image_url').first.update_attributes(:value => "http://#{@gemeinschaft_setup.sip_domain.host}/uploads/user/image") # Restart FreeSWITCH - require 'freeswitch_event' - FreeswitchAPI.execute('fsctl', 'shutdown restart') + # require 'freeswitch_event' + # FreeswitchAPI.execute('fsctl', 'shutdown restart') # Auto-Login: session[:user_id] = user.id -- cgit v1.2.3 From bdad29d001523a2ba4f515e6202babaa61739fc9 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 18:02:06 +0100 Subject: Refactoring and caching. --- app/views/tenants/_admin_area.de.html.haml | 6 ++ app/views/tenants/_admin_area.html.haml | 7 +- app/views/tenants/_gs_parameter_table.html.haml | 24 ++++++ app/views/tenants/_table_of_functions.html.haml | 98 +++++++++++------------ app/views/tenants/_table_of_phone_books.html.haml | 1 - 5 files changed, 81 insertions(+), 55 deletions(-) create mode 100644 app/views/tenants/_gs_parameter_table.html.haml diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index d111c9d..4b8a9e6 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -27,8 +27,14 @@ = succeed '.' do =link_to manufacturer, manufacturer_path(manufacturer) +%h2 Admin Bereich = render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} +%h2 Features = render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant} +%h2 Gemeinschaft Konfiguration += render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} + +%h2=t("phone_books.index.page_title") = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} diff --git a/app/views/tenants/_admin_area.html.haml b/app/views/tenants/_admin_area.html.haml index b479995..b1b17a3 100644 --- a/app/views/tenants/_admin_area.html.haml +++ b/app/views/tenants/_admin_area.html.haml @@ -26,9 +26,14 @@ = succeed '.' do =link_to manufacturer, manufacturer_path(manufacturer) +%h2 Admin Area = render :partial => 'tenants/sip_accounts_and_phones', :locals => {:tenant => @tenant} +%h2 Features = render :partial => 'tenants/table_of_functions', :locals => {:tenant => @tenant} -= render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} +%h2 Gemeinschaft Configuration += render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => @tenant} +%h2=t("phone_books.index.page_title") += render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => @tenant} \ No newline at end of file diff --git a/app/views/tenants/_gs_parameter_table.html.haml b/app/views/tenants/_gs_parameter_table.html.haml new file mode 100644 index 0000000..7663f46 --- /dev/null +++ b/app/views/tenants/_gs_parameter_table.html.haml @@ -0,0 +1,24 @@ +- cache([I18n.locale, tenant, GuiFunction.count, GuiFunction.order(:updated_at).last, GsParameter.count, GsParameter.order(:updated_at).last]) do + %table + %tr{:class => 'even'} + %th + Funktion + %th + Anzahl + %th + Letztes Update + + %tr{:class => 'odd'} + %td + = t("gui_functions.name") + %td + = link_to GuiFunction.count.to_s, gui_functions_path + %td + = l GuiFunction.order(:updated_at).last.updated_at, :format => :short + %tr{:class => 'even'} + %td + = t("gs_parameters.name") + %td + = link_to GsParameter.count.to_s, gs_parameters_path + %td + = l GsParameter.order(:updated_at).last.updated_at, :format => :short diff --git a/app/views/tenants/_table_of_functions.html.haml b/app/views/tenants/_table_of_functions.html.haml index 79ea2b1..ef2a2d0 100644 --- a/app/views/tenants/_table_of_functions.html.haml +++ b/app/views/tenants/_table_of_functions.html.haml @@ -1,4 +1,4 @@ -- cache([I18n.locale, tenant, GuiFunction.count, GuiFunction.order(:updated_at).last, GsParameter.count, GsParameter.order(:updated_at).last]) do +- cache([I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last, tenant.conferences.count, tenant.conferences.order(:updated_at).last, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do %table %tr{:class => 'even'} %th @@ -6,55 +6,47 @@ %th Anzahl %th - %tr{:class => 'odd'} - %td - = t("callthroughs.name") - %td - - if tenant.callthroughs.any? - = link_to tenant.callthroughs.count.to_s, tenant_callthroughs_path(tenant) - - else - = '-' - %td - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Callthrough} - %tr{:class => 'even'} - %td - = t("conferences.name") - %td - - if tenant.conferences.any? - = link_to tenant.conferences.count.to_s, tenant_conferences_path(tenant) - - else - = '-' - %td - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Conference} - %tr{:class => 'odd'} - %td - = t("hunt_groups.name") - %td - - if tenant.hunt_groups.any? - = link_to tenant.hunt_groups.count.to_s, tenant_hunt_groups_path(tenant) - - else - = '-' - %td - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => HuntGroup} - %tr{:class => 'even'} - %td - = t("automatic_call_distributors.name") - %td - - if tenant.automatic_call_distributors.any? - = link_to tenant.automatic_call_distributors.count.to_s, tenant_automatic_call_distributors_path(tenant) - - else - = '-' - %td - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => AutomaticCallDistributor} - %tr{:class => 'odd'} - %td - = t("gui_functions.name") - %td - = link_to GuiFunction.count.to_s, gui_functions_path - %td - %tr{:class => 'even'} - %td - = t("gs_parameters.name") - %td - = link_to GsParameter.count.to_s, gs_parameters_path - %td \ No newline at end of file + - cache([I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last]) do + %tr{:class => 'odd'} + %td + = t("callthroughs.name") + %td + - if tenant.callthroughs.any? + = link_to tenant.callthroughs.count.to_s, tenant_callthroughs_path(tenant) + - else + = '-' + %td + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Callthrough} + - cache([I18n.locale, tenant, tenant.conferences.count, tenant.conferences.order(:updated_at).last]) do + %tr{:class => 'even'} + %td + = t("conferences.name") + %td + - if tenant.conferences.any? + = link_to tenant.conferences.count.to_s, tenant_conferences_path(tenant) + - else + = '-' + %td + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Conference} + - cache([I18n.locale, tenant, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last]) do + %tr{:class => 'odd'} + %td + = t("hunt_groups.name") + %td + - if tenant.hunt_groups.any? + = link_to tenant.hunt_groups.count.to_s, tenant_hunt_groups_path(tenant) + - else + = '-' + %td + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => HuntGroup} + - cache([I18n.locale, tenant, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do + %tr{:class => 'even'} + %td + = t("automatic_call_distributors.name") + %td + - if tenant.automatic_call_distributors.any? + = link_to tenant.automatic_call_distributors.count.to_s, tenant_automatic_call_distributors_path(tenant) + - else + = '-' + %td + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => AutomaticCallDistributor} \ No newline at end of file diff --git a/app/views/tenants/_table_of_phone_books.html.haml b/app/views/tenants/_table_of_phone_books.html.haml index 811fe26..a963bf4 100644 --- a/app/views/tenants/_table_of_phone_books.html.haml +++ b/app/views/tenants/_table_of_phone_books.html.haml @@ -3,6 +3,5 @@ -# - if GuiFunction.display?('show_phone_books_in_user_show_view', current_user) - if can?( :index, PhoneBook ) - %h2=t("phone_books.index.page_title") = render "phone_books/index_core", :phone_books => tenant.phone_books = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => PhoneBook} \ No newline at end of file -- cgit v1.2.3 From 8cea5d1c88e2e13ed99a5c54a1e1b69a5d6a2d01 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 19:05:01 +0100 Subject: Refactoring users#view and added caching. --- app/models/phone_book_entry.rb | 2 +- app/views/users/_conferences.html.haml | 7 ++ app/views/users/_fax_accounts.html.haml | 7 ++ app/views/users/_phone_books.html.haml | 7 ++ app/views/users/_phones.html.haml | 7 ++ app/views/users/_sip_accounts.html.haml | 7 ++ app/views/users/_tenants.html.haml | 5 ++ app/views/users/_user_groups.html.haml | 8 ++ app/views/users/show.html.haml | 128 ++++++++++++-------------------- 9 files changed, 95 insertions(+), 83 deletions(-) create mode 100644 app/views/users/_conferences.html.haml create mode 100644 app/views/users/_fax_accounts.html.haml create mode 100644 app/views/users/_phone_books.html.haml create mode 100644 app/views/users/_phones.html.haml create mode 100644 app/views/users/_sip_accounts.html.haml create mode 100644 app/views/users/_tenants.html.haml create mode 100644 app/views/users/_user_groups.html.haml diff --git a/app/models/phone_book_entry.rb b/app/models/phone_book_entry.rb index db2b44b..275c7b6 100644 --- a/app/models/phone_book_entry.rb +++ b/app/models/phone_book_entry.rb @@ -6,7 +6,7 @@ class PhoneBookEntry < ActiveRecord::Base attr_accessible :first_name, :middle_name, :last_name, :title, :nickname, :organization, :is_organization, :department, :job_title, :is_male, :birthday, :birth_name, :description, :homepage_personal, :homepage_organization, :twitter_account, :facebook_account, :google_plus_account, :xing_account, :linkedin_account, :mobileme_account, :image - belongs_to :phone_book + belongs_to :phone_book, :touch => true has_many :conference_invitees, :dependent => :destroy acts_as_list :scope => :phone_book diff --git a/app/views/users/_conferences.html.haml b/app/views/users/_conferences.html.haml new file mode 100644 index 0000000..b9592b6 --- /dev/null +++ b/app/views/users/_conferences.html.haml @@ -0,0 +1,7 @@ +-# Conferences +-# +- if (can?( :index, Conference ) && user.conferences.count > 0 ) || can?( :create, Conference ) + %h2= t('conferences.index.page_title') + - if can?( :index, Conference ) && user.conferences.count > 0 + = render "conferences/index_core", :conferences => user.conferences + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => Conference} \ No newline at end of file diff --git a/app/views/users/_fax_accounts.html.haml b/app/views/users/_fax_accounts.html.haml new file mode 100644 index 0000000..044b8f9 --- /dev/null +++ b/app/views/users/_fax_accounts.html.haml @@ -0,0 +1,7 @@ +-# FaxAccount +-# +- if (can?( :index, FaxAccount ) && user.fax_accounts.count > 0 ) || can?( :create, FaxAccount ) + %h2= t('fax_accounts.index.page_title') + - if can?( :index, FaxAccount ) && user.fax_accounts.count > 0 + = render "fax_accounts/index_core", {:fax_accounts => user.fax_accounts, :fax_accountable => user} + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => FaxAccount} \ No newline at end of file diff --git a/app/views/users/_phone_books.html.haml b/app/views/users/_phone_books.html.haml new file mode 100644 index 0000000..4943bc6 --- /dev/null +++ b/app/views/users/_phone_books.html.haml @@ -0,0 +1,7 @@ +-# Phone books +-# +- if GuiFunction.display?('show_phone_books_in_user_show_view', current_user) + - if can?( :index, PhoneBook ) + %h2=t("phone_books.index.page_title") + = render "phone_books/index_core", :phone_books => phone_books + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => PhoneBook} \ No newline at end of file diff --git a/app/views/users/_phones.html.haml b/app/views/users/_phones.html.haml new file mode 100644 index 0000000..e001eae --- /dev/null +++ b/app/views/users/_phones.html.haml @@ -0,0 +1,7 @@ +-# Phones +-# +- if (can?( :index, Phone, :phoneable => user ) && user.phones.count > 0 ) || can?( :create, Phone, :phoneable => user ) + %h2= t('phones.index.page_title') + - if can?( :index, Phone, :phoneable => user ) && user.phones.count > 0 + = render "phones/index_core", :phones => user.phones + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => Phone} \ No newline at end of file diff --git a/app/views/users/_sip_accounts.html.haml b/app/views/users/_sip_accounts.html.haml new file mode 100644 index 0000000..1861105 --- /dev/null +++ b/app/views/users/_sip_accounts.html.haml @@ -0,0 +1,7 @@ +-# SIP accounts +-# +- if (can?( :index, SipAccount ) && user.sip_accounts.count > 0 ) || can?( :create, SipAccount ) + %h2= t('sip_accounts.index.page_title') + - if can?( :index, SipAccount ) && user.sip_accounts.count > 0 + = render "sip_accounts/index_core", :sip_accounts => user.sip_accounts + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => SipAccount} \ No newline at end of file diff --git a/app/views/users/_tenants.html.haml b/app/views/users/_tenants.html.haml new file mode 100644 index 0000000..49a2d9b --- /dev/null +++ b/app/views/users/_tenants.html.haml @@ -0,0 +1,5 @@ +-# Tenants +-# +- if can?( :index, Tenant ) && user.tenants.count > 1 + %h2=t("tenants.index.page_title") + = render "tenants/index_core", :tenants => user.tenants \ No newline at end of file diff --git a/app/views/users/_user_groups.html.haml b/app/views/users/_user_groups.html.haml new file mode 100644 index 0000000..7e206b6 --- /dev/null +++ b/app/views/users/_user_groups.html.haml @@ -0,0 +1,8 @@ +-# User groups (only if the current user can edit or destroy them) +-# +- if user.user_groups.map{ |x| can?( :edit, x ) || can?( :destroy, x ) }.include?(true) + - if can?( :index, UserGroup ) + %h2=t("user_groups.index.page_title") + - if user.user_groups.count > 0 + = render "user_groups/index_core", :user_groups => user.user_groups.where(:tenant_id => tenant.id).order(:name) + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => UserGroup} \ No newline at end of file diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 7730447..5650b13 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -2,95 +2,59 @@ #user-show %aside - = image_tag @user.image_url(:small).to_s, class: 'display' if @user.image? && @user.image_url(:small) - %p - %strong= t('users.show.user_name') + ":" - = @user.user_name - %p - %strong= t('users.show.email') + ":" - = @user.email - - %p.controls - = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @tenant, :child => @user } - - - @user.sip_accounts.each do |sip_account| - - phone_number = sip_account.phone_numbers.order(:number).last - - if phone_number && !phone_number.number.blank? && phone_number.number[0] != '+' - %p - %strong= sip_account.phone_numbers.order(:number).last.number - %p - =link_to t("call_histories.index.page_title"), sip_account_call_histories_path(sip_account) - %br - =link_to t("voicemail_messages.index.page_title"), sip_account_voicemail_messages_path(sip_account) - %br - =link_to t("call_forwards.index.page_title"), phone_number_call_forwards_path(phone_number) - %br - =link_to t("voicemail_settings.index.page_title"), sip_account_voicemail_settings_path(sip_account) - %br - =link_to t("softkeys.index.page_title"), sip_account_softkeys_path(sip_account) - %br - =link_to t("ringtones.show.page_title"), phone_number_ringtones_path(phone_number) - - - if @user.conferences.any? + - cache([I18n.locale, 'show_aside', @user, @user.sip_accounts, @user.conferences]) do + = image_tag @user.image_url(:small).to_s, class: 'display' if @user.image? && @user.image_url(:small) + %p + %strong= t('users.show.user_name') + ":" + = @user.user_name %p - %strong= t("conferences.index.page_title") - - @user.conferences.each do |conference| + %strong= t('users.show.email') + ":" + = @user.email + + %p.controls + = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @tenant, :child => @user } + + - @user.sip_accounts.each do |sip_account| + - phone_number = sip_account.phone_numbers.order(:number).last + - if phone_number && !phone_number.number.blank? && phone_number.number[0] != '+' + %p + %strong= sip_account.phone_numbers.order(:number).last.number + %p + =link_to t("call_histories.index.page_title"), sip_account_call_histories_path(sip_account) + %br + =link_to t("voicemail_messages.index.page_title"), sip_account_voicemail_messages_path(sip_account) + %br + =link_to t("call_forwards.index.page_title"), phone_number_call_forwards_path(phone_number) + %br + =link_to t("voicemail_settings.index.page_title"), sip_account_voicemail_settings_path(sip_account) + %br + =link_to t("softkeys.index.page_title"), sip_account_softkeys_path(sip_account) + %br + =link_to t("ringtones.show.page_title"), phone_number_ringtones_path(phone_number) + + - if @user.conferences.any? %p - =link_to conference, edit_user_conference_path(@user, conference) + %strong= t("conferences.index.page_title") + - @user.conferences.each do |conference| + %p + =link_to conference, edit_user_conference_path(@user, conference) %section - -# Phone books - -# - - if GuiFunction.display?('show_phone_books_in_user_show_view', current_user) - - if can?( :index, PhoneBook ) - %h2=t("phone_books.index.page_title") - = render "phone_books/index_core", :phone_books => @phone_books - = render :partial => 'shared/create_link', :locals => {:parent => @user, :child_class => PhoneBook} - - -# User groups (only if the current user can edit or destroy them) - -# - - if @user.user_groups.map{ |x| can?( :edit, x ) || can?( :destroy, x ) }.include?(true) - - if can?( :index, UserGroup ) - %h2=t("user_groups.index.page_title") - - if @user.user_groups.count > 0 - = render "user_groups/index_core", :user_groups => @user.user_groups.where(:tenant_id => @tenant.id).order(:name) - = render :partial => 'shared/create_link', :locals => {:parent => @tenant, :child_class => UserGroup} + = render :partial => 'phone_books', :locals => {:user => @user, :phone_books => @phone_books} - -# SIP accounts - -# - - if (can?( :index, SipAccount ) && @user.sip_accounts.count > 0 ) || can?( :create, SipAccount ) - %h2= t('sip_accounts.index.page_title') - - if can?( :index, SipAccount ) && @user.sip_accounts.count > 0 - = render "sip_accounts/index_core", :sip_accounts => @user.sip_accounts - = render :partial => 'shared/create_link', :locals => {:parent => @user, :child_class => SipAccount} + - cache([I18n.locale, @user, @user.user_groups, @user.sip_accounts, @user.phones, @user.fax_accounts, @user.conferences]) do + - cache([I18n.locale, @user, @user.user_groups]) do + = render :partial => 'user_groups', :locals => {:user => @user, :tenant => @tenant} - -# Phones - -# - - if (can?( :index, Phone, :phoneable => @user ) && @user.phones.count > 0 ) || can?( :create, Phone, :phoneable => @user ) - %h2= t('phones.index.page_title') - - if can?( :index, Phone, :phoneable => @user ) && @user.phones.count > 0 - = render "phones/index_core", :phones => @user.phones - = render :partial => 'shared/create_link', :locals => {:parent => @user, :child_class => Phone} + - cache([I18n.locale, @user, @user.sip_accounts]) do + = render :partial => 'sip_accounts', :locals => {:user => @user} - -# FaxAccount - -# - - if (can?( :index, FaxAccount ) && @user.fax_accounts.count > 0 ) || can?( :create, FaxAccount ) - %h2= t('fax_accounts.index.page_title') - - if can?( :index, FaxAccount ) && @user.fax_accounts.count > 0 - = render "fax_accounts/index_core", {:fax_accounts => @user.fax_accounts, :fax_accountable => @user} - = render :partial => 'shared/create_link', :locals => {:parent => @user, :child_class => FaxAccount} + - cache([I18n.locale, @user, @user.phones]) do + = render :partial => 'phones', :locals => {:user => @user} - -# Conferences - -# - - if (can?( :index, Conference ) && @user.conferences.count > 0 ) || can?( :create, Conference ) - %h2= t('conferences.index.page_title') - - if can?( :index, Conference ) && @user.conferences.count > 0 - = render "conferences/index_core", :conferences => @user.conferences - = render :partial => 'shared/create_link', :locals => {:parent => @user, :child_class => Conference} + - cache([I18n.locale, @user, @user.fax_accounts]) do + = render :partial => 'fax_accounts', :locals => {:user => @user} - -# Tenants - -# - - if can?( :index, Tenant ) && @user.tenants.count > 1 - %h2=t("tenants.index.page_title") - = render "tenants/index_core", :tenants => @user.tenants \ No newline at end of file + - cache([I18n.locale, @user, @user.conferences]) do + = render :partial => 'conferences', :locals => {:user => @user} -- cgit v1.2.3 From 078e90282bab4b76d6eb0678c9e5f69d7ae86748 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 19:13:44 +0100 Subject: Added caching for the phone_book_entries table. --- .../phone_book_entries/_index_core.de.html.haml | 72 ++++++++++----------- app/views/phone_book_entries/_index_core.html.haml | 73 +++++++++++----------- 2 files changed, 75 insertions(+), 70 deletions(-) diff --git a/app/views/phone_book_entries/_index_core.de.html.haml b/app/views/phone_book_entries/_index_core.de.html.haml index 0c6e74b..e460888 100644 --- a/app/views/phone_book_entries/_index_core.de.html.haml +++ b/app/views/phone_book_entries/_index_core.de.html.haml @@ -2,39 +2,41 @@ %section.phone-book-entries %header.entries-nav= render :partial => "phone_book_entries/navigation" .content - - reset_cycle - %table - - for entry in phone_book_entries - ~# Dear IE7, - ~# Because of you we have to do this with a table. - ~# With Love, - ~# Mario. - %tr.phone-book-entry{:class => cycle('odd', 'even'), :"itemscope itemtype" => "http://schema.org/Person"} - %td.thumbnail - = image_tag(entry.image_url(:small).to_s, :itemprop => 'image') - %td.user - - if entry.is_organization == true - %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry - - else - %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry - %a.company{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'memberOf'}= entry.organization - %td.contact - - if @found_phone_numbers and @found_phone_numbers.where(:phone_numberable_id => entry.id) - %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= @found_phone_numbers.where(:phone_numberable_id => entry.id).first - - elsif entry.phone_numbers.first - %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= entry.phone_numbers.first - - if entry.phone_numbers.count > 1 - %a.more{:href => phone_book_phone_book_entry_path(entry.phone_book, entry)}= t('phone_book_entries.index.more_numbers', :numbers => (entry.phone_numbers.count-1)) - %td.extra - - if !entry.description.blank? - %strong Beschreibung: - %div - = entry.description - - if !entry.homepage_organization.blank? - %br - =link_to entry.homepage_organization, entry.homepage_organization - - if can? :edit, entry - %td= link_to t('phone_book_entries.index.actions.edit'), edit_phone_book_phone_book_entry_path( entry.phone_book, entry ) - - if can? :destroy, entry - %td= link_to t('phone_book_entries.index.actions.destroy'), [entry.phone_book, entry], :confirm => t('phone_book_entries.index.actions.confirm'), :method => :delete + - cache([I18n.locale, 'phone_book_entries_table', current_user, phone_book_entries]) do + - reset_cycle + %table + - for entry in phone_book_entries + - cache([I18n.locale, 'phone_book_entries_table_tr', current_user, entry]) do + ~# Dear IE7, + ~# Because of you we have to do this with a table. + ~# With Love, + ~# Mario. + %tr.phone-book-entry{:class => cycle('odd', 'even'), :"itemscope itemtype" => "http://schema.org/Person"} + %td.thumbnail + = image_tag(entry.image_url(:small).to_s, :itemprop => 'image') + %td.user + - if entry.is_organization == true + %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry + - else + %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry + %a.company{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'memberOf'}= entry.organization + %td.contact + - if @found_phone_numbers and @found_phone_numbers.where(:phone_numberable_id => entry.id) + %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= @found_phone_numbers.where(:phone_numberable_id => entry.id).first + - elsif entry.phone_numbers.first + %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= entry.phone_numbers.first + - if entry.phone_numbers.count > 1 + %a.more{:href => phone_book_phone_book_entry_path(entry.phone_book, entry)}= t('phone_book_entries.index.more_numbers', :numbers => (entry.phone_numbers.count-1)) + %td.extra + - if !entry.description.blank? + %strong Beschreibung: + %div + = entry.description + - if !entry.homepage_organization.blank? + %br + =link_to entry.homepage_organization, entry.homepage_organization + - if can? :edit, entry + %td= link_to t('phone_book_entries.index.actions.edit'), edit_phone_book_phone_book_entry_path( entry.phone_book, entry ) + - if can? :destroy, entry + %td= link_to t('phone_book_entries.index.actions.destroy'), [entry.phone_book, entry], :confirm => t('phone_book_entries.index.actions.confirm'), :method => :delete %footer.entries-nav= render :partial => "phone_book_entries/navigation" diff --git a/app/views/phone_book_entries/_index_core.html.haml b/app/views/phone_book_entries/_index_core.html.haml index 9054833..37ad905 100644 --- a/app/views/phone_book_entries/_index_core.html.haml +++ b/app/views/phone_book_entries/_index_core.html.haml @@ -2,39 +2,42 @@ %section.phone-book-entries %header.entries-nav= render :partial => "phone_book_entries/navigation" .content - - reset_cycle - %table - - for entry in phone_book_entries - ~# Dear IE7, - ~# Because of you we have to do this with a table. - ~# With Love, - ~# Mario. - %tr.phone-book-entry{:class => cycle('odd', 'even'), :"itemscope itemtype" => "http://schema.org/Person"} - %td.thumbnail - = image_tag(entry.image_url(:small).to_s, :itemprop => 'image') - %td.user - - if entry.is_organization == true - %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry - - else - %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry - %a.company{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'memberOf'}= entry.organization - %td.contact - - if @found_phone_numbers and @found_phone_numbers.where(:phone_numberable_id => entry.id) - %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= @found_phone_numbers.where(:phone_numberable_id => entry.id).first - - elsif entry.phone_numbers.first - %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= entry.phone_numbers.first - - if entry.phone_numbers.count > 1 - %a.more{:href => phone_book_phone_book_entry_path(entry.phone_book, entry)}= t('phone_book_entries.index.more_numbers', :numbers => (entry.phone_numbers.count-1)) - %td.extra - - if !entry.description.blank? - %strong Description: - %div - = entry.description - - if !entry.homepage_organization.blank? - %br - =link_to entry.homepage_organization, entry.homepage_organization - - if can? :edit, entry - %td= link_to t('phone_book_entries.index.actions.edit'), edit_phone_book_phone_book_entry_path( entry.phone_book, entry ) - - if can? :destroy, entry - %td= link_to t('phone_book_entries.index.actions.destroy'), [entry.phone_book, entry], :confirm => t('phone_book_entries.index.actions.confirm'), :method => :delete + - cache([I18n.locale, 'phone_book_entries_table', current_user, phone_book_entries]) do + - reset_cycle + - reset_cycle + %table + - for entry in phone_book_entries + - cache([I18n.locale, 'phone_book_entries_table_tr', current_user, entry]) do + ~# Dear IE7, + ~# Because of you we have to do this with a table. + ~# With Love, + ~# Mario. + %tr.phone-book-entry{:class => cycle('odd', 'even'), :"itemscope itemtype" => "http://schema.org/Person"} + %td.thumbnail + = image_tag(entry.image_url(:small).to_s, :itemprop => 'image') + %td.user + - if entry.is_organization == true + %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry + - else + %a.name{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => "name"}= entry + %a.company{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'memberOf'}= entry.organization + %td.contact + - if @found_phone_numbers and @found_phone_numbers.where(:phone_numberable_id => entry.id) + %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= @found_phone_numbers.where(:phone_numberable_id => entry.id).first + - elsif entry.phone_numbers.first + %a.phone{:href=> phone_book_phone_book_entry_path(entry.phone_book, entry), :itemprop => 'telephone'}= entry.phone_numbers.first + - if entry.phone_numbers.count > 1 + %a.more{:href => phone_book_phone_book_entry_path(entry.phone_book, entry)}= t('phone_book_entries.index.more_numbers', :numbers => (entry.phone_numbers.count-1)) + %td.extra + - if !entry.description.blank? + %strong Description: + %div + = entry.description + - if !entry.homepage_organization.blank? + %br + =link_to entry.homepage_organization, entry.homepage_organization + - if can? :edit, entry + %td= link_to t('phone_book_entries.index.actions.edit'), edit_phone_book_phone_book_entry_path( entry.phone_book, entry ) + - if can? :destroy, entry + %td= link_to t('phone_book_entries.index.actions.destroy'), [entry.phone_book, entry], :confirm => t('phone_book_entries.index.actions.confirm'), :method => :delete %footer.entries-nav= render :partial => "phone_book_entries/navigation" -- cgit v1.2.3 From 4fbda07c7b593dcc22b90f571d1b85b1bdc47528 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 19:48:22 +0100 Subject: Check if Rails.env.production? before restarting FreeSWITCH. #101 --- app/controllers/gemeinschaft_setups_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb index 89a82cb..dbe8ff5 100644 --- a/app/controllers/gemeinschaft_setups_controller.rb +++ b/app/controllers/gemeinschaft_setups_controller.rb @@ -47,8 +47,10 @@ class GemeinschaftSetupsController < ApplicationController GsParameter.where(:name => 'user_image_url').first.update_attributes(:value => "http://#{@gemeinschaft_setup.sip_domain.host}/uploads/user/image") # Restart FreeSWITCH - # require 'freeswitch_event' - # FreeswitchAPI.execute('fsctl', 'shutdown restart') + if Rails.env.production? + require 'freeswitch_event' + FreeswitchAPI.execute('fsctl', 'shutdown restart') + end # Auto-Login: session[:user_id] = user.id -- cgit v1.2.3 From 5a49e044fe3a5bdeff40c15d363af6d0c36fa27a Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 20:27:39 +0100 Subject: Fixed breadcrumbs. --- app/controllers/gui_functions_controller.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/gui_functions_controller.rb b/app/controllers/gui_functions_controller.rb index 2ab2c5e..0cb7898 100644 --- a/app/controllers/gui_functions_controller.rb +++ b/app/controllers/gui_functions_controller.rb @@ -1,4 +1,6 @@ class GuiFunctionsController < ApplicationController + load_resource :gui_function + before_filter :load_user_groups before_filter :spread_breadcrumbs @@ -60,14 +62,10 @@ class GuiFunctionsController < ApplicationController end def spread_breadcrumbs - if @tenant - add_breadcrumb t("user_groups.index.page_title"), tenant_user_groups_path(@tenant) - if @user_group && !@user_group.new_record? - add_breadcrumb @user_group, tenant_user_group_path(@tenant, @user_group) - end - end - add_breadcrumb t("gui_functions.index.page_title"), gui_functions_path + if @gui_function && !@gui_function.new_record? + add_breadcrumb @gui_function, gui_function_path(@gui_function) + end end end -- cgit v1.2.3 From ca77ad70f4c2df28f6460e0160f23d115174440d Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 20:42:02 +0100 Subject: Optimized caching. --- app/controllers/gs_parameters_controller.rb | 2 +- app/views/gs_parameters/_index_core.html.haml | 6 +++--- app/views/gs_parameters/index.html.haml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb index a7813dc..0966132 100644 --- a/app/controllers/gs_parameters_controller.rb +++ b/app/controllers/gs_parameters_controller.rb @@ -1,6 +1,6 @@ class GsParametersController < ApplicationController def index - @ps_parameters_unordered = GsParameter.scoped + @gs_parameters_unordered = GsParameter.scoped @gs_parameters = GsParameter.order([:section, :name]) @sections = @gs_parameters.pluck(:section).uniq.sort end diff --git a/app/views/gs_parameters/_index_core.html.haml b/app/views/gs_parameters/_index_core.html.haml index 0c36560..a3f8e1c 100644 --- a/app/views/gs_parameters/_index_core.html.haml +++ b/app/views/gs_parameters/_index_core.html.haml @@ -1,4 +1,4 @@ -- cache([gs_parameters.first.section, gs_parameters.reorder(:updated_at).last, gs_parameters.pluck(:id)]) do +- cache(['gs_parameters_table_section', gs_parameters.first.section, gs_parameters.reorder(:updated_at).last, gs_parameters.pluck(:id)]) do %tr %th= t('gs_parameters.index.name') - if !@sections @@ -7,10 +7,10 @@ - reset_cycle - for gs_parameter in gs_parameters - - cache(gs_parameter) do + - cache(['gs_parameters_table_single_row', gs_parameter]) do %tr{:class => cycle('odd', 'even')} %td= gs_parameter.name - if !@sections %td= gs_parameter.section - %td= gs_parameter.value + %td= truncate(gs_parameter.value, :length => 50) =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gs_parameter} \ No newline at end of file diff --git a/app/views/gs_parameters/index.html.haml b/app/views/gs_parameters/index.html.haml index b4a53e8..c7a6b70 100644 --- a/app/views/gs_parameters/index.html.haml +++ b/app/views/gs_parameters/index.html.haml @@ -1,7 +1,7 @@ - title t("gs_parameters.index.page_title") - if @gs_parameters && @gs_parameters.count > 0 - - cache([@ps_parameters_unordered.order(:updated_at).last, @ps_parameters_unordered.count]) do + - cache(['gs_parameters_table', @gs_parameters_unordered.order(:updated_at).last, @gs_parameters_unordered.count]) do - if @sections %table - @sections.each do |section| -- cgit v1.2.3 From 907d081bf1b45e876f9d5833bfe1f4d6319aeb81 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 20:44:19 +0100 Subject: Added breadcrumbs for GsParameter. --- app/controllers/gs_parameters_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb index 0966132..7ca4e8e 100644 --- a/app/controllers/gs_parameters_controller.rb +++ b/app/controllers/gs_parameters_controller.rb @@ -1,4 +1,8 @@ class GsParametersController < ApplicationController + load_resource :gs_parameter + + before_filter :spread_breadcrumbs + def index @gs_parameters_unordered = GsParameter.scoped @gs_parameters = GsParameter.order([:section, :name]) @@ -30,4 +34,11 @@ class GsParametersController < ApplicationController def gs_parameter_params params.require(:gs_parameter).permit(:value, :class_type, :description) end + + def spread_breadcrumbs + add_breadcrumb t("gs_parameters.index.page_title"), gs_parameters_path + if @gs_parameter && !@gs_parameter.new_record? + add_breadcrumb @gs_parameter, gs_parameter_path(@gs_parameter) + end + end end -- cgit v1.2.3 From 7b5c903f96e1c97ad788962c88d6d285852d890e Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 20:50:18 +0100 Subject: Fixed caching. --- app/views/tenants/_gs_parameter_table.html.haml | 2 +- app/views/tenants/_table_of_functions.html.haml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/tenants/_gs_parameter_table.html.haml b/app/views/tenants/_gs_parameter_table.html.haml index 7663f46..3af06cf 100644 --- a/app/views/tenants/_gs_parameter_table.html.haml +++ b/app/views/tenants/_gs_parameter_table.html.haml @@ -1,4 +1,4 @@ -- cache([I18n.locale, tenant, GuiFunction.count, GuiFunction.order(:updated_at).last, GsParameter.count, GsParameter.order(:updated_at).last]) do +- cache(['gs_parameters_tenant_overview_table', I18n.locale, tenant, GuiFunction.count, GuiFunction.order(:updated_at).last, GsParameter.count, GsParameter.order(:updated_at).last]) do %table %tr{:class => 'even'} %th diff --git a/app/views/tenants/_table_of_functions.html.haml b/app/views/tenants/_table_of_functions.html.haml index ef2a2d0..75b2332 100644 --- a/app/views/tenants/_table_of_functions.html.haml +++ b/app/views/tenants/_table_of_functions.html.haml @@ -1,4 +1,4 @@ -- cache([I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last, tenant.conferences.count, tenant.conferences.order(:updated_at).last, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do +- cache(['table_of_pbx_features', I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last, tenant.conferences.count, tenant.conferences.order(:updated_at).last, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do %table %tr{:class => 'even'} %th @@ -6,7 +6,7 @@ %th Anzahl %th - - cache([I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last]) do + - cache(['table_of_pbx_features_callthroughs_row', I18n.locale, tenant, tenant.callthroughs.count, tenant.callthroughs.order(:updated_at).last]) do %tr{:class => 'odd'} %td = t("callthroughs.name") @@ -17,7 +17,7 @@ = '-' %td = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Callthrough} - - cache([I18n.locale, tenant, tenant.conferences.count, tenant.conferences.order(:updated_at).last]) do + - cache(['table_of_pbx_features_conferences_row', I18n.locale, tenant, tenant.conferences.count, tenant.conferences.order(:updated_at).last]) do %tr{:class => 'even'} %td = t("conferences.name") @@ -28,7 +28,7 @@ = '-' %td = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Conference} - - cache([I18n.locale, tenant, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last]) do + - cache(['table_of_pbx_features_hunt_groups_row', I18n.locale, tenant, tenant.hunt_groups.count, tenant.hunt_groups.order(:updated_at).last]) do %tr{:class => 'odd'} %td = t("hunt_groups.name") @@ -39,7 +39,7 @@ = '-' %td = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => HuntGroup} - - cache([I18n.locale, tenant, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do + - cache(['table_of_pbx_features_automatic_call_distributors_row', I18n.locale, tenant, tenant.automatic_call_distributors.count, tenant.automatic_call_distributors.order(:updated_at).last]) do %tr{:class => 'even'} %td = t("automatic_call_distributors.name") -- cgit v1.2.3 From 6b7cbac8a2a274c1839e8ea6aa293d0e6e49d370 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 21:38:22 +0100 Subject: Fixes caching bugs. --- app/views/users/show.html.haml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 5650b13..c3af173 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -2,7 +2,7 @@ #user-show %aside - - cache([I18n.locale, 'show_aside', @user, @user.sip_accounts, @user.conferences]) do + - cache(['user_show_aside', I18n.locale, @user, @user.sip_accounts, @user.conferences]) do = image_tag @user.image_url(:small).to_s, class: 'display' if @user.image? && @user.image_url(:small) %p %strong= t('users.show.user_name') + ":" @@ -43,18 +43,18 @@ %section = render :partial => 'phone_books', :locals => {:user => @user, :phone_books => @phone_books} - - cache([I18n.locale, @user, @user.user_groups, @user.sip_accounts, @user.phones, @user.fax_accounts, @user.conferences]) do - - cache([I18n.locale, @user, @user.user_groups]) do + - cache(['user_show_overview', I18n.locale, @user, @user.user_groups, @user.sip_accounts, @user.phones, @user.fax_accounts, @user.conferences]) do + - cache(['user_show_user_groups_overview', I18n.locale, @user, @user.user_groups]) do = render :partial => 'user_groups', :locals => {:user => @user, :tenant => @tenant} - - cache([I18n.locale, @user, @user.sip_accounts]) do + - cache(['user_show_sip_accounts_overview', I18n.locale, @user, @user.sip_accounts]) do = render :partial => 'sip_accounts', :locals => {:user => @user} - - cache([I18n.locale, @user, @user.phones]) do + - cache(['user_show_phones_overview', I18n.locale, @user, @user.phones]) do = render :partial => 'phones', :locals => {:user => @user} - - cache([I18n.locale, @user, @user.fax_accounts]) do + - cache(['user_show_fax_accounts_overview', I18n.locale, @user, @user.fax_accounts]) do = render :partial => 'fax_accounts', :locals => {:user => @user} - - cache([I18n.locale, @user, @user.conferences]) do + - cache(['user_show_conferences_overview', I18n.locale, @user, @user.conferences]) do = render :partial => 'conferences', :locals => {:user => @user} -- cgit v1.2.3 From 96fc4789d9991548b9fd1144f185da1f3464f156 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 21:47:26 +0100 Subject: Fixed caching bugs. --- app/views/phone_book_entries/_index_core.de.html.haml | 4 ++-- app/views/phone_book_entries/_index_core.html.haml | 4 ++-- app/views/tenants/_admin_area.de.html.haml | 2 +- app/views/tenants/_admin_area.html.haml | 2 +- app/views/tenants/_sip_accounts_and_phones.html.haml | 4 ++-- app/views/tenants/_table_of_phone_books.html.haml | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/phone_book_entries/_index_core.de.html.haml b/app/views/phone_book_entries/_index_core.de.html.haml index e460888..43d62f6 100644 --- a/app/views/phone_book_entries/_index_core.de.html.haml +++ b/app/views/phone_book_entries/_index_core.de.html.haml @@ -2,11 +2,11 @@ %section.phone-book-entries %header.entries-nav= render :partial => "phone_book_entries/navigation" .content - - cache([I18n.locale, 'phone_book_entries_table', current_user, phone_book_entries]) do + - cache(['phone_book_entries_table', I18n.locale, current_user, phone_book_entries]) do - reset_cycle %table - for entry in phone_book_entries - - cache([I18n.locale, 'phone_book_entries_table_tr', current_user, entry]) do + - cache(['phone_book_entries_table_tr', I18n.locale, current_user, entry]) do ~# Dear IE7, ~# Because of you we have to do this with a table. ~# With Love, diff --git a/app/views/phone_book_entries/_index_core.html.haml b/app/views/phone_book_entries/_index_core.html.haml index 37ad905..e98e8d5 100644 --- a/app/views/phone_book_entries/_index_core.html.haml +++ b/app/views/phone_book_entries/_index_core.html.haml @@ -2,12 +2,12 @@ %section.phone-book-entries %header.entries-nav= render :partial => "phone_book_entries/navigation" .content - - cache([I18n.locale, 'phone_book_entries_table', current_user, phone_book_entries]) do + - cache(['phone_book_entries_table', I18n.locale, current_user, phone_book_entries]) do - reset_cycle - reset_cycle %table - for entry in phone_book_entries - - cache([I18n.locale, 'phone_book_entries_table_tr', current_user, entry]) do + - cache(['phone_book_entries_table_tr', I18n.locale, current_user, entry]) do ~# Dear IE7, ~# Because of you we have to do this with a table. ~# With Love, diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index 4b8a9e6..beab94e 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -1,4 +1,4 @@ -- cache([I18n.locale, @tenant, UserGroup.count, UserGroup.order(:updated_at).last, User.count, User.order(:updated_at).last, Manufacturer.all]) do +- cache(['tenant_show_admin_area', I18n.locale, @tenant, UserGroup.count, UserGroup.order(:updated_at).last, User.count, User.order(:updated_at).last, Manufacturer.all]) do %p Sie sind Mitglied der = link_to 'Admin Gruppe', tenant_user_group_path(@tenant, @tenant.user_groups.find_by_name('Admins')) diff --git a/app/views/tenants/_admin_area.html.haml b/app/views/tenants/_admin_area.html.haml index b1b17a3..65810e7 100644 --- a/app/views/tenants/_admin_area.html.haml +++ b/app/views/tenants/_admin_area.html.haml @@ -1,4 +1,4 @@ -- cache([I18n.locale, @tenant, UserGroup.count, UserGroup.order(:updated_at).last, User.count, User.order(:updated_at).last, Manufacturer.all]) do +- cache(['tenant_show_admin_area', I18n.locale, @tenant, UserGroup.count, UserGroup.order(:updated_at).last, User.count, User.order(:updated_at).last, Manufacturer.all]) do %p You belong to the = link_to 'admin group', tenant_user_group_path(@tenant, @tenant.user_groups.find_by_name('Admins')) diff --git a/app/views/tenants/_sip_accounts_and_phones.html.haml b/app/views/tenants/_sip_accounts_and_phones.html.haml index 618236f..c698fef 100644 --- a/app/views/tenants/_sip_accounts_and_phones.html.haml +++ b/app/views/tenants/_sip_accounts_and_phones.html.haml @@ -12,7 +12,7 @@ - if tenant.sip_accounts.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS') = link_to tenant.sip_accounts.count.to_s, tenant_sip_accounts_path(tenant) - else - - cache([I18n.locale, tenant, tenant.sip_accounts, PhoneNumber.where(:phone_numberable_type => 'SipAccount').where(:id => tenant.sip_account_ids)]) do + - cache(['tenant_show_tenant_sip_accounts',I18n.locale, tenant, tenant.sip_accounts, PhoneNumber.where(:phone_numberable_type => 'SipAccount').where(:id => tenant.sip_account_ids)]) do - tenant.sip_accounts.each do |sip_account| = succeed ', ' do =link_to "#{sip_account.caller_name}", tenant_sip_account_path(tenant,sip_account) @@ -44,7 +44,7 @@ - if tenant.phones.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS') = link_to tenant.phones.count.to_s, tenant_phones_path(tenant) - else - - cache([I18n.locale, tenant, tenant.phones]) do + - cache(['tenant_show_tenant_phones', I18n.locale, tenant, tenant.phones]) do - tenant.phones.each do |phone| = succeed ', ' do = link_to "#{phone.phone_model.to_s} (#{phone.pretty_mac_address})#{(phone.ip_address.blank? ? '' : " - #{phone.ip_address}")}", tenant_phone_path(tenant, phone) diff --git a/app/views/tenants/_table_of_phone_books.html.haml b/app/views/tenants/_table_of_phone_books.html.haml index a963bf4..6baca58 100644 --- a/app/views/tenants/_table_of_phone_books.html.haml +++ b/app/views/tenants/_table_of_phone_books.html.haml @@ -1,4 +1,4 @@ -- cache([I18n.locale, tenant, tenant.phone_books]) do +- cache(['user_show_phone_books', I18n.locale, tenant, tenant.phone_books]) do -# Phone books -# - if GuiFunction.display?('show_phone_books_in_user_show_view', current_user) -- cgit v1.2.3 From bf9c8cdfb5d2754e53b15560242cc7c43603155a Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 21:53:22 +0100 Subject: GuiFunction can not be deleted or created on the GUI. --- app/models/ability.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 0fa40c8..cd91a8a 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -74,9 +74,10 @@ class Ability cannot :manage, PhoneNumberRange end - # GsParameter can't be created or deleted via the GUI + # GsParameter and GuiFunction can't be created or deleted via the GUI # cannot [:create, :destroy], GsParameter + cannot [:create, :destroy], GuiFunction else # Any user can do the following stuff. # -- cgit v1.2.3 From d44b8c81f939deb1e83e17d19c580b3bf6ac9ab6 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 22:00:45 +0100 Subject: Optimized caching. --- app/views/gs_parameters/index.html.haml | 2 +- app/views/gui_functions/_index_core.html.haml | 29 ++++++++++++++------------- app/views/gui_functions/index.html.haml | 3 ++- app/views/gui_functions/show.html.haml | 29 ++++++++++++++------------- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/app/views/gs_parameters/index.html.haml b/app/views/gs_parameters/index.html.haml index c7a6b70..37fe825 100644 --- a/app/views/gs_parameters/index.html.haml +++ b/app/views/gs_parameters/index.html.haml @@ -1,7 +1,7 @@ - title t("gs_parameters.index.page_title") - if @gs_parameters && @gs_parameters.count > 0 - - cache(['gs_parameters_table', @gs_parameters_unordered.order(:updated_at).last, @gs_parameters_unordered.count]) do + - cache(['gs_parameters_table', I18n.locale, @gs_parameters_unordered.order(:updated_at).last, @gs_parameters_unordered.count]) do - if @sections %table - @sections.each do |section| diff --git a/app/views/gui_functions/_index_core.html.haml b/app/views/gui_functions/_index_core.html.haml index 093a0d7..815b9c3 100644 --- a/app/views/gui_functions/_index_core.html.haml +++ b/app/views/gui_functions/_index_core.html.haml @@ -8,19 +8,20 @@ - reset_cycle - for gui_function in gui_functions %tr{:class => cycle('odd', 'even')} - %td= gui_function.category - %td - = gui_function.name - - if !gui_function.description.blank? - %br - %i= gui_function.description - - @user_groups.each do |user_group| - - if gui_function.gui_function_memberships.find_by_user_group_id(user_group.id) - - if gui_function.gui_function_memberships.find_by_user_group_id(user_group.id).activated == true - %td= 'x' + - cache(['gui_functions_table_row', I18n.locale, gui_function]) do + %td= gui_function.category + %td + = gui_function.name + - if !gui_function.description.blank? + %br + %i= gui_function.description + - @user_groups.each do |user_group| + - if gui_function.gui_function_memberships.find_by_user_group_id(user_group.id) + - if gui_function.gui_function_memberships.find_by_user_group_id(user_group.id).activated == true + %td= 'x' + - else + %td= '' - else - %td= '' - - else - %td= 'x' + %td= 'x' - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gui_function} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gui_function} \ No newline at end of file diff --git a/app/views/gui_functions/index.html.haml b/app/views/gui_functions/index.html.haml index ef909f0..9b53918 100644 --- a/app/views/gui_functions/index.html.haml +++ b/app/views/gui_functions/index.html.haml @@ -1,6 +1,7 @@ - title t("gui_functions.index.page_title") - if @gui_functions && @gui_functions.count > 0 - = render "index_core", :gui_functions => @gui_functions + - cache(['gui_functions_table', I18n.locale, @gui_functions.reorder(:updated_at).last, @gui_functions.count]) do + = render "index_core", :gui_functions => @gui_functions = render :partial => 'shared/create_link', :locals => {:child_class => GuiFunction} \ No newline at end of file diff --git a/app/views/gui_functions/show.html.haml b/app/views/gui_functions/show.html.haml index 0fc2dd9..8af329a 100644 --- a/app/views/gui_functions/show.html.haml +++ b/app/views/gui_functions/show.html.haml @@ -1,18 +1,19 @@ - title t("gui_functions.show.page_title") -%p - %strong= t('gui_functions.show.name') + ":" - = @gui_function.name -%p - %strong= t('gui_functions.show.description') + ":" - = @gui_function.description - -- @user_groups.each do |user_group| +- cache(['gui_function_show', I18n.locale, @gui_function]) do + %p + %strong= t('gui_functions.show.name') + ":" + = @gui_function.name %p - %strong= "#{user_group}:" - - if @gui_function.gui_function_memberships.where(:user_group_id => user_group.id, :activated => true).count > 0 - = 'x' - - else - = 'not activated' + %strong= t('gui_functions.show.description') + ":" + = @gui_function.description + + - @user_groups.each do |user_group| + %p + %strong= "#{user_group}:" + - if @gui_function.gui_function_memberships.where(:user_group_id => user_group.id, :activated => true).count > 0 + = 'x' + - else + = 'not activated' -= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gui_function } \ No newline at end of file + = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gui_function } \ No newline at end of file -- cgit v1.2.3 From 0820f0e79a28aaa22ff98e969cd202ed422298ff Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 22:06:30 +0100 Subject: Redirect root_url to user#show. --- app/controllers/page_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/page_controller.rb b/app/controllers/page_controller.rb index 4ea4d25..dc5f57b 100644 --- a/app/controllers/page_controller.rb +++ b/app/controllers/page_controller.rb @@ -5,7 +5,12 @@ class PageController < ApplicationController before_filter :if_fresh_system_then_go_to_wizard skip_before_filter :home_breadcrumb, :only => [:index] - def index;end + def index + if current_user + redirect_to [current_user.current_tenant, current_user] + end + end + def conference;end def beginners_intro;end -- cgit v1.2.3 From a0569f5546781b8e87011a79e2fccaae8c06e862 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 22:42:03 +0100 Subject: s/Benutzer/User/g --- config/locales/views/users/de.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/config/locales/views/users/de.yml b/config/locales/views/users/de.yml index 951600d..e4a0ae2 100644 --- a/config/locales/views/users/de.yml +++ b/config/locales/views/users/de.yml @@ -1,15 +1,15 @@ de: users: - name: "Benutzer" + name: "User" controller: - successfuly_created: 'Der Benutzer %{resource} wurde erstellt.' - successfuly_created_and_login: 'Der Benutzer %{resource} wurde erstellt. Sie sind jetzt als dieser Benutzer angemeldet.' - successfuly_updated: 'Benutzer-Daten aktualisiert.' - successfuly_destroyed: 'Der Benutzer wurde gelöscht.' + successfuly_created: 'Der User %{resource} wurde erstellt.' + successfuly_created_and_login: 'Der User %{resource} wurde erstellt. Sie sind jetzt als dieser User angemeldet.' + successfuly_updated: 'User-Daten aktualisiert.' + successfuly_destroyed: 'Der User wurde gelöscht.' avatar_destroyed: 'Der Avatar wurde gelöscht.' index: - page_title: 'Benutzer' - user_name: 'Benutzer-Name' + page_title: 'User' + user_name: 'User-Name' email: 'E-Mail Adresse' first_name: 'Vorname' middle_name: 'Zweiter Vorname' @@ -20,15 +20,15 @@ de: language_id: 'Sprache' send_voicemail_as_email_attachment: 'Sprachnachrichten per E-Mail' actions: - confirm: 'Sind Sie sicher, dass Sie diesen Benutzer löschen möchten?' + confirm: 'Sind Sie sicher, dass Sie diesen User löschen möchten?' destroy: 'Löschen' edit: 'Bearbeiten' show: 'Anzeigen' - create: 'Neuen Benutzer anlegen' - create_for: 'Neuen Benutzer für %{resource} anlegen' + create: 'Neuen User anlegen' + create_for: 'Neuen User für %{resource} anlegen' show: - page_title: 'Benutzer anzeigen' - user_name: 'Benutzer-Name' + page_title: 'User anzeigen' + user_name: 'User-Name' email: 'E-Mail Adresse' first_name: 'Vorname' middle_name: 'Zweiter Vorname' @@ -39,17 +39,17 @@ de: language_id: 'Sprache' send_voicemail_as_email_attachment: 'Sprachnachrichten per E-Mail' actions: - confirm: 'Sind Sie sicher, dass Sie diesen Benutzer löschen möchten?' + confirm: 'Sind Sie sicher, dass Sie diesen User löschen möchten?' destroy: 'Löschen' edit: 'Bearbeiten' - view_all: 'Alle Benutzer anzeigen' + view_all: 'Alle User anzeigen' new: - page_title: 'Neuen Benutzer anlegen' + page_title: 'Neuen User anlegen' edit: - page_title: 'Benutzer %{resource} bearbeiten' + page_title: 'User %{resource} bearbeiten' form: user_name: - label: 'Benutzer-Name' + label: 'User-Name' hint: '' email: label: 'E-Mail Adresse' -- cgit v1.2.3 From 8d622f127f8d951c50bbf3fd0921626fd3746dae Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 15 Jan 2013 22:42:15 +0100 Subject: Optimized caching. --- .../tenants/_sip_accounts_and_phones.html.haml | 64 ++++++++++++---------- app/views/tenants/show.html.haml | 15 ++--- 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/app/views/tenants/_sip_accounts_and_phones.html.haml b/app/views/tenants/_sip_accounts_and_phones.html.haml index c698fef..e322b67 100644 --- a/app/views/tenants/_sip_accounts_and_phones.html.haml +++ b/app/views/tenants/_sip_accounts_and_phones.html.haml @@ -1,24 +1,40 @@ %table %tr{:class => 'even'} %th - %th - = tenant - %th= t("users.index.page_title") + %th= t("sip_accounts.index.page_title") + %th= t("phones.index.page_title") - %tr{:class => 'odd'} - %td= t("sip_accounts.index.page_title") - %td - - if tenant.sip_accounts.any? - - if tenant.sip_accounts.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS') - = link_to tenant.sip_accounts.count.to_s, tenant_sip_accounts_path(tenant) - - else - - cache(['tenant_show_tenant_sip_accounts',I18n.locale, tenant, tenant.sip_accounts, PhoneNumber.where(:phone_numberable_type => 'SipAccount').where(:id => tenant.sip_account_ids)]) do - - tenant.sip_accounts.each do |sip_account| - = succeed ', ' do - =link_to "#{sip_account.caller_name}", tenant_sip_account_path(tenant,sip_account) - - if sip_account.phone_numbers.any? - = '[' + truncate(sip_account.phone_numbers.map{|phone_number| phone_number.to_s}.join(', '), :length => 25) + ']' - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => SipAccount} + - cache(['tenant_show_admin_area_sip_accounts_and_phones_row', I18n.locale, @tenant, @tenant.sip_accounts.count, @tenant.sip_accounts.reorder(:updated_at).last, @tenant.phones.count, @tenant.phones.reorder(:updated_at).last]) do + + %tr{:class => 'odd'} + %td= tenant + - cache(['tenant_show_admin_area_sip_accounts_table_cell', I18n.locale, @tenant, @tenant.sip_accounts.count, @tenant.sip_accounts.reorder(:updated_at).last]) do + %td + - if tenant.sip_accounts.any? + - if tenant.sip_accounts.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS') + = link_to tenant.sip_accounts.count.to_s, tenant_sip_accounts_path(tenant) + - else + - tenant.sip_accounts.each do |sip_account| + = succeed ', ' do + =link_to "#{sip_account.caller_name}", tenant_sip_account_path(tenant,sip_account) + - if sip_account.phone_numbers.any? + = '[' + truncate(sip_account.phone_numbers.map{|phone_number| phone_number.to_s}.join(', '), :length => 25) + ']' + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => SipAccount} + + - cache(['tenant_show_admin_area_sip_accounts_table_cell', I18n.locale, @tenant, @tenant.phones.count, @tenant.phones.reorder(:updated_at).last]) do + %td + - if tenant.phones.any? + - if tenant.phones.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS') + = link_to tenant.phones.count.to_s, tenant_phones_path(tenant) + - else + - cache(['tenant_show_tenant_phones', I18n.locale, tenant, tenant.phones]) do + - tenant.phones.each do |phone| + = succeed ', ' do + = link_to "#{phone.phone_model.to_s} (#{phone.pretty_mac_address})#{(phone.ip_address.blank? ? '' : " - #{phone.ip_address}")}", tenant_phone_path(tenant, phone) + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Phone} + + %tr{:class => 'even'} + %td= t("users.index.page_title") %td - if tenant.users_sip_accounts.any? - if tenant.users_sip_accounts.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS') @@ -37,18 +53,6 @@ - else = "-" - %tr{:class => 'even'} - %td= t("phones.index.page_title") - %td - - if tenant.phones.any? - - if tenant.phones.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS') - = link_to tenant.phones.count.to_s, tenant_phones_path(tenant) - - else - - cache(['tenant_show_tenant_phones', I18n.locale, tenant, tenant.phones]) do - - tenant.phones.each do |phone| - = succeed ', ' do - = link_to "#{phone.phone_model.to_s} (#{phone.pretty_mac_address})#{(phone.ip_address.blank? ? '' : " - #{phone.ip_address}")}", tenant_phone_path(tenant, phone) - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => Phone} %td - if tenant.users_phones.any? - if tenant.users_phones.count > GsParameter.get('NUMBER_OF_SHOWN_ITEMS') @@ -61,4 +65,4 @@ - else = link_to "#{phone.phone_model.to_s} (#{phone.pretty_mac_address})#{(phone.ip_address.blank? ? '' : " - #{phone.ip_address}")}", user_phone_path(phone.phoneable, phone) - else - = '-' \ No newline at end of file + = '-' diff --git a/app/views/tenants/show.html.haml b/app/views/tenants/show.html.haml index cb2b895..10845cf 100644 --- a/app/views/tenants/show.html.haml +++ b/app/views/tenants/show.html.haml @@ -1,14 +1,15 @@ - title t("tenants.show.page_title") -%p - %strong= t('tenants.show.name') + ":" - = @tenant.name -- if !@tenant.description.blank? +- cache(['tenant_show_name_and_description', I18n.locale, @tenant, current_user]) do %p - %strong= t('tenants.show.description') + ":" - = @tenant.description + %strong= t('tenants.show.name') + ":" + = @tenant.name + - if !@tenant.description.blank? + %p + %strong= t('tenants.show.description') + ":" + = @tenant.description -= render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @tenant } + = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @tenant } - if @tenant.user_groups.where(:name => 'Admins').count > 0 && @tenant.user_groups.where(:name => 'Admins').first.users.include?(current_user) = render 'admin_area' \ No newline at end of file -- cgit v1.2.3 From 6635621faeebbc8dd744e0ad71741f9e82aed1f8 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 16 Jan 2013 07:21:11 +0100 Subject: Show the user_groups in User#view only for Admins. --- app/views/users/show.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index c3af173..f74d0a5 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -43,10 +43,12 @@ %section = render :partial => 'phone_books', :locals => {:user => @user, :phone_books => @phone_books} - - cache(['user_show_overview', I18n.locale, @user, @user.user_groups, @user.sip_accounts, @user.phones, @user.fax_accounts, @user.conferences]) do + - if current_user.user_groups.where(:name => 'Admins').any? - cache(['user_show_user_groups_overview', I18n.locale, @user, @user.user_groups]) do = render :partial => 'user_groups', :locals => {:user => @user, :tenant => @tenant} + - cache(['user_show_overview_for_sip_account_phones_fax_accounts_and_conferences', I18n.locale, @user, @user.sip_accounts, @user.phones, @user.fax_accounts, @user.conferences]) do + - cache(['user_show_sip_accounts_overview', I18n.locale, @user, @user.sip_accounts]) do = render :partial => 'sip_accounts', :locals => {:user => @user} -- cgit v1.2.3