fat_free_crm 0.17.3 → 0.19.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fat_free_crm might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +71 -148
- data/.travis.yml +35 -14
- data/CHANGELOG.md +92 -6
- data/CONTRIBUTORS.md +96 -53
- data/Dockerfile +45 -14
- data/Gemfile +23 -13
- data/Gemfile.lock +256 -248
- data/Procfile +1 -1
- data/README.md +9 -6
- data/Rakefile +1 -1
- data/app/assets/javascripts/crm.js.coffee +3 -3
- data/app/assets/javascripts/crm_select2.js.coffee +15 -14
- data/app/assets/stylesheets/common.scss +1 -1
- data/app/controllers/admin/application_controller.rb +1 -1
- data/app/controllers/admin/field_groups_controller.rb +9 -4
- data/app/controllers/admin/fields_controller.rb +4 -4
- data/app/controllers/admin/groups_controller.rb +1 -1
- data/app/controllers/admin/tags_controller.rb +2 -4
- data/app/controllers/admin/users_controller.rb +5 -8
- data/app/controllers/application_controller.rb +22 -45
- data/app/controllers/comments_controller.rb +16 -11
- data/{config/initializers/authlogic.rb → app/controllers/confirmations_controller.rb} +4 -2
- data/app/controllers/emails_controller.rb +0 -2
- data/app/controllers/entities/accounts_controller.rb +1 -3
- data/app/controllers/entities/campaigns_controller.rb +8 -5
- data/app/controllers/entities/contacts_controller.rb +4 -24
- data/app/controllers/entities/leads_controller.rb +16 -12
- data/app/controllers/entities/opportunities_controller.rb +17 -16
- data/app/controllers/entities_controller.rb +31 -12
- data/app/controllers/home_controller.rb +2 -4
- data/app/controllers/lists_controller.rb +5 -1
- data/app/controllers/passwords_controller.rb +3 -59
- data/{spec/features/support/maintain_sessions.rb → app/controllers/registrations_controller.rb} +12 -5
- data/{lib/development_tasks/gem.rake → app/controllers/sessions_controller.rb} +6 -6
- data/app/controllers/tasks_controller.rb +22 -17
- data/app/controllers/users_controller.rb +8 -29
- data/app/helpers/accounts_helper.rb +1 -1
- data/app/helpers/admin/users_helper.rb +1 -1
- data/app/helpers/application_helper.rb +28 -33
- data/app/helpers/campaigns_helper.rb +1 -1
- data/app/helpers/contacts_helper.rb +1 -3
- data/app/helpers/leads_helper.rb +1 -1
- data/app/helpers/opportunities_helper.rb +48 -3
- data/app/helpers/tasks_helper.rb +1 -1
- data/app/helpers/users_helper.rb +1 -3
- data/{config/initializers/paper_trail.rb → app/mailers/devise_mailer.rb} +5 -1
- data/app/mailers/user_mailer.rb +0 -9
- data/app/models/entities/account.rb +10 -10
- data/app/models/entities/campaign.rb +4 -6
- data/app/models/entities/contact.rb +24 -12
- data/app/models/entities/lead.rb +7 -14
- data/app/models/entities/opportunity.rb +10 -11
- data/app/models/fields/custom_field.rb +1 -0
- data/app/models/fields/custom_field_date_pair.rb +2 -0
- data/app/models/fields/field.rb +1 -3
- data/app/models/list.rb +1 -1
- data/app/models/observers/entity_observer.rb +3 -7
- data/app/models/observers/lead_observer.rb +2 -4
- data/app/models/observers/opportunity_observer.rb +5 -7
- data/app/models/observers/task_observer.rb +1 -1
- data/app/models/polymorphic/email.rb +2 -2
- data/app/models/polymorphic/task.rb +13 -9
- data/app/models/polymorphic/version.rb +3 -2
- data/app/models/setting.rb +2 -0
- data/app/models/users/ability.rb +3 -4
- data/app/models/users/permission.rb +3 -3
- data/app/models/users/preference.rb +2 -1
- data/app/models/users/user.rb +67 -42
- data/app/views/accounts/_top_section.html.haml +1 -1
- data/app/views/accounts/edit.js.haml +1 -1
- data/app/views/accounts/update.js.haml +2 -2
- data/app/views/admin/users/_user.html.haml +4 -4
- data/app/views/campaigns/_metrics.html.haml +3 -3
- data/app/views/contacts/_index_brief.html.haml +1 -1
- data/app/views/contacts/_index_full.html.haml +1 -1
- data/app/views/contacts/_index_long.html.haml +1 -1
- data/app/views/devise/confirmations/new.html.haml +9 -0
- data/app/views/devise/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/devise/mailer/password_change.html.haml +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/devise/passwords/edit.html.haml +18 -0
- data/app/views/devise/passwords/new.html.haml +10 -0
- data/app/views/devise/registrations/new.html.haml +21 -0
- data/app/views/devise/sessions/new.html.haml +32 -0
- data/app/views/home/_opportunity.html.haml +4 -19
- data/app/views/layouts/_about.html.haml +5 -5
- data/app/views/layouts/_header.html.haml +3 -3
- data/app/views/layouts/admin/_header.html.haml +1 -1
- data/app/views/opportunities/_index_long.html.haml +1 -24
- data/app/views/opportunities/_sidebar_show.html.haml +3 -3
- data/app/views/opportunities/_top_section.html.haml +1 -1
- data/app/views/shared/_address.html.haml +5 -5
- data/app/views/shared/_empty.html.haml +1 -1
- data/app/views/shared/_paginate_with_per_page.html.haml +1 -0
- data/app/views/users/_avatar.html.haml +1 -1
- data/bin/bundle +1 -1
- data/bin/rails +1 -1
- data/bin/setup +38 -0
- data/bin/update +33 -0
- data/bin/yarn +13 -0
- data/config/application.rb +8 -6
- data/config/boot.rb +1 -1
- data/config/brakeman.ignore +2 -2
- data/config/database.postgres.docker.yml +5 -5
- data/config/environment.rb +1 -1
- data/config/environments/development.rb +1 -0
- data/config/environments/test.rb +7 -0
- data/config/initializers/action_mailer.rb +1 -3
- data/config/initializers/application_controller_renderer.rb +9 -0
- data/config/initializers/assets.rb +6 -11
- data/config/initializers/backtrace_silencers.rb +0 -6
- data/config/initializers/content_security_policy.rb +26 -0
- data/config/initializers/cookies_serializer.rb +3 -6
- data/config/initializers/devise.rb +289 -0
- data/config/initializers/filter_parameter_logging.rb +0 -5
- data/config/initializers/gravatar.rb +0 -1
- data/config/initializers/inflections.rb +0 -6
- data/config/initializers/mime_types.rb +1 -9
- data/config/initializers/new_framework_defaults_5_2.rb +40 -0
- data/config/initializers/relative_url_root.rb +1 -3
- data/config/initializers/session_store.rb +1 -3
- data/config/initializers/wrap_parameters.rb +4 -9
- data/config/locales/fat_free_crm.en-GB.yml +5 -5
- data/config/locales/fat_free_crm.en-US.yml +5 -5
- data/config/locales/fat_free_crm.fr.yml +1 -1
- data/config/locales/fat_free_crm.ru.yml +1 -0
- data/config/routes.rb +20 -9
- data/db/demo/users.yml +62 -81
- data/db/migrate/20100928030620_remove_uuid.rb +1 -2
- data/db/migrate/20120316045804_activities_to_versions.rb +1 -0
- data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +1 -0
- data/db/migrate/20180107082701_authlogic_to_devise.rb +58 -0
- data/db/schema.rb +48 -46
- data/docker-compose.yml +10 -0
- data/fat_free_crm.gemspec +12 -14
- data/lib/development_tasks/license.rake +2 -2
- data/lib/fat_free_crm/callback.rb +2 -2
- data/lib/fat_free_crm/comment_extensions.rb +2 -4
- data/lib/fat_free_crm/core_ext/string.rb +1 -1
- data/lib/fat_free_crm/engine.rb +2 -2
- data/lib/fat_free_crm/errors.rb +1 -1
- data/lib/fat_free_crm/export_csv.rb +1 -0
- data/lib/fat_free_crm/exportable.rb +1 -1
- data/lib/fat_free_crm/fields.rb +2 -2
- data/lib/fat_free_crm/gem_dependencies.rb +1 -1
- data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +1 -3
- data/lib/fat_free_crm/i18n.rb +2 -2
- data/lib/fat_free_crm/mail_processor/base.rb +4 -10
- data/lib/fat_free_crm/mail_processor/dropbox.rb +5 -15
- data/lib/fat_free_crm/permissions.rb +7 -18
- data/lib/fat_free_crm/sortable.rb +1 -1
- data/lib/fat_free_crm/tabs.rb +2 -2
- data/lib/fat_free_crm/version.rb +2 -2
- data/lib/gravatar_image_tag.rb +7 -8
- data/lib/missing_translation_detector.rb +1 -0
- data/lib/tasks/ffcrm/missing_translations.rake +1 -0
- data/lib/tasks/ffcrm/setup.rake +13 -4
- data/lib/tasks/ffcrm/update_data.rake +2 -2
- data/script/rails +2 -2
- data/spec/controllers/admin/users_controller_spec.rb +25 -81
- data/spec/controllers/comments_controller_spec.rb +19 -19
- data/spec/controllers/emails_controller_spec.rb +2 -2
- data/spec/controllers/entities/accounts_controller_spec.rb +56 -56
- data/spec/controllers/entities/campaigns_controller_spec.rb +66 -66
- data/spec/controllers/entities/contacts_controller_spec.rb +69 -68
- data/spec/controllers/entities/leads_controller_spec.rb +126 -126
- data/spec/controllers/entities/opportunities_controller_spec.rb +101 -101
- data/spec/controllers/entities_controller_spec.rb +5 -0
- data/spec/controllers/home_controller_spec.rb +30 -30
- data/spec/controllers/tasks_controller_spec.rb +42 -40
- data/spec/controllers/users_controller_spec.rb +43 -113
- data/spec/factories/account_factories.rb +13 -13
- data/spec/factories/campaign_factories.rb +8 -8
- data/spec/factories/contact_factories.rb +18 -18
- data/spec/factories/field_factories.rb +11 -10
- data/spec/factories/lead_factories.rb +13 -13
- data/spec/factories/list_factories.rb +3 -3
- data/spec/factories/opportunity_factories.rb +9 -9
- data/spec/factories/sequences.rb +1 -1
- data/spec/factories/setting_factories.rb +5 -5
- data/spec/factories/shared_factories.rb +25 -23
- data/spec/factories/subscription_factories.rb +1 -1
- data/spec/factories/tag_factories.rb +1 -1
- data/spec/factories/task_factories.rb +11 -11
- data/spec/factories/user_factories.rb +27 -30
- data/spec/features/accounts_spec.rb +17 -4
- data/spec/features/admin/groups_spec.rb +2 -2
- data/spec/features/admin/users_spec.rb +4 -2
- data/spec/features/campaigns_spec.rb +5 -5
- data/spec/features/contacts_spec.rb +11 -5
- data/spec/features/dashboard_spec.rb +8 -8
- data/spec/features/devise/sign_in_spec.rb +58 -0
- data/spec/features/devise/sign_up_spec.rb +36 -0
- data/spec/features/leads_spec.rb +5 -5
- data/spec/features/opportunities_overview_spec.rb +16 -16
- data/spec/features/opportunities_spec.rb +35 -9
- data/spec/features/support/autocomlete_helper.rb +17 -0
- data/spec/features/support/browser.rb +5 -9
- data/spec/features/tasks_spec.rb +5 -5
- data/spec/helpers/admin/field_groups_helper_spec.rb +1 -1
- data/spec/helpers/application_helper_spec.rb +1 -1
- data/spec/helpers/tasks_helper_spec.rb +1 -1
- data/spec/helpers/users_helper_spec.rb +7 -7
- data/spec/lib/comment_extensions_spec.rb +11 -5
- data/spec/lib/errors_spec.rb +2 -2
- data/spec/lib/mail_processor/base_spec.rb +3 -3
- data/spec/lib/mail_processor/comment_replies_spec.rb +3 -3
- data/spec/lib/mail_processor/dropbox_spec.rb +17 -17
- data/spec/lib/mail_processor/sample_emails/dropbox.rb +8 -8
- data/spec/lib/permissions_spec.rb +15 -28
- data/spec/mailers/devise_mailer_spec.rb +35 -0
- data/spec/mailers/user_mailer_spec.rb +6 -32
- data/spec/models/entities/account_spec.rb +58 -32
- data/spec/models/entities/campaign_spec.rb +18 -25
- data/spec/models/entities/contact_spec.rb +113 -21
- data/spec/models/entities/lead_spec.rb +9 -11
- data/spec/models/entities/opportunity_spec.rb +45 -45
- data/spec/models/fields/custom_field_date_pair_spec.rb +4 -2
- data/spec/models/fields/custom_field_spec.rb +21 -19
- data/spec/models/list_spec.rb +2 -2
- data/spec/models/observers/entity_observer_spec.rb +7 -7
- data/spec/models/polymorphic/address_spec.rb +1 -1
- data/spec/models/polymorphic/avatar_spec.rb +5 -5
- data/spec/models/polymorphic/comment_spec.rb +5 -5
- data/spec/models/polymorphic/task_spec.rb +65 -58
- data/spec/models/polymorphic/version_spec.rb +31 -31
- data/spec/models/setting_spec.rb +2 -2
- data/spec/models/users/preference_spec.rb +6 -6
- data/spec/models/users/user_spec.rb +46 -50
- data/spec/routing/users_routing_spec.rb +30 -8
- data/spec/shared/controllers.rb +3 -9
- data/spec/shared/models.rb +22 -22
- data/spec/spec_helper.rb +12 -4
- data/spec/support/assert_select.rb +1 -0
- data/spec/support/devise_helpers.rb +28 -0
- data/spec/{features/support/helpers.rb → support/feature_helpers.rb} +11 -11
- data/spec/support/macros.rb +7 -4
- data/spec/views/accounts/_edit.haml_spec.rb +1 -1
- data/spec/views/accounts/create.js.haml_spec.rb +3 -3
- data/spec/views/accounts/destroy.js.haml_spec.rb +1 -1
- data/spec/views/accounts/edit.js.haml_spec.rb +2 -2
- data/spec/views/accounts/index.haml_spec.rb +2 -2
- data/spec/views/accounts/index.js.haml_spec.rb +1 -1
- data/spec/views/accounts/show.haml_spec.rb +4 -4
- data/spec/views/accounts/update.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/create.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/destroy.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/edit.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/new.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/update.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/create.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/destroy.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/edit.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/index.haml_spec.rb +1 -1
- data/spec/views/admin/users/index.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/reactivate.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/suspend.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/update.js.haml_spec.rb +1 -1
- data/spec/views/application/auto_complete.haml_spec.rb +3 -3
- data/spec/views/campaigns/_edit.haml_spec.rb +1 -1
- data/spec/views/campaigns/create.js.haml_spec.rb +4 -4
- data/spec/views/campaigns/destroy.js.haml_spec.rb +1 -1
- data/spec/views/campaigns/edit.js.haml_spec.rb +4 -4
- data/spec/views/campaigns/index.haml_spec.rb +1 -1
- data/spec/views/campaigns/index.js.haml_spec.rb +2 -2
- data/spec/views/campaigns/show.haml_spec.rb +4 -4
- data/spec/views/campaigns/update.js.haml_spec.rb +2 -2
- data/spec/views/contacts/_edit.haml_spec.rb +7 -7
- data/spec/views/contacts/_new.haml_spec.rb +1 -1
- data/spec/views/contacts/create.js.haml_spec.rb +5 -5
- data/spec/views/contacts/destroy.js.haml_spec.rb +1 -1
- data/spec/views/contacts/edit.js.haml_spec.rb +4 -4
- data/spec/views/contacts/index.haml_spec.rb +1 -1
- data/spec/views/contacts/index.js.html_spec.rb +2 -2
- data/spec/views/contacts/new.js.haml_spec.rb +1 -1
- data/spec/views/contacts/show.haml_spec.rb +3 -3
- data/spec/views/contacts/update.js.haml_spec.rb +5 -5
- data/spec/views/home/index.haml_spec.rb +1 -1
- data/spec/views/home/index.js.haml_spec.rb +1 -1
- data/spec/views/home/options.js.haml_spec.rb +2 -2
- data/spec/views/leads/_convert.haml_spec.rb +3 -3
- data/spec/views/leads/_edit.haml_spec.rb +2 -2
- data/spec/views/leads/_new.haml_spec.rb +2 -2
- data/spec/views/leads/_sidebar_show.haml_spec.rb +5 -5
- data/spec/views/leads/convert.js.haml_spec.rb +4 -4
- data/spec/views/leads/create.js.haml_spec.rb +5 -5
- data/spec/views/leads/destroy.js.haml_spec.rb +2 -2
- data/spec/views/leads/edit.js.haml_spec.rb +4 -4
- data/spec/views/leads/index.haml_spec.rb +1 -1
- data/spec/views/leads/index.js.haml_spec.rb +1 -1
- data/spec/views/leads/new.js.haml_spec.rb +1 -1
- data/spec/views/leads/promote.js.haml_spec.rb +7 -7
- data/spec/views/leads/reject.js.haml_spec.rb +2 -2
- data/spec/views/leads/show.haml_spec.rb +2 -2
- data/spec/views/leads/update.js.haml_spec.rb +4 -4
- data/spec/views/opportunities/_edit.haml_spec.rb +7 -7
- data/spec/views/opportunities/_new.haml_spec.rb +2 -2
- data/spec/views/opportunities/create.js.haml_spec.rb +6 -6
- data/spec/views/opportunities/destroy.js.haml_spec.rb +3 -3
- data/spec/views/opportunities/edit.js.haml_spec.rb +3 -3
- data/spec/views/opportunities/index.haml_spec.rb +1 -1
- data/spec/views/opportunities/index.js.haml_spec.rb +1 -1
- data/spec/views/opportunities/new.js.haml_spec.rb +1 -1
- data/spec/views/opportunities/show.haml_spec.rb +3 -3
- data/spec/views/opportunities/update.js.haml_spec.rb +5 -5
- data/spec/views/tasks/_edit.haml_spec.rb +1 -1
- data/spec/views/tasks/complete.js.haml_spec.rb +4 -4
- data/spec/views/tasks/create.js.haml_spec.rb +6 -6
- data/spec/views/tasks/destroy.js.haml_spec.rb +2 -2
- data/spec/views/tasks/index.haml_spec.rb +4 -4
- data/spec/views/tasks/new.js.haml_spec.rb +1 -1
- data/spec/views/tasks/uncomplete.js.haml_spec.rb +2 -2
- data/spec/views/tasks/update.js.haml_spec.rb +18 -18
- data/spec/views/users/upload_avatar.js.haml_spec.rb +2 -2
- metadata +49 -71
- data/app/controllers/authentications_controller.rb +0 -53
- data/app/models/users/authentication.rb +0 -56
- data/app/views/authentications/new.html.haml +0 -19
- data/app/views/passwords/edit.html.haml +0 -15
- data/app/views/passwords/new.html.haml +0 -10
- data/app/views/user_mailer/password_reset_instructions.html.haml +0 -6
- data/app/views/users/new.html.haml +0 -19
- data/spec/controllers/authentications_controller_spec.rb +0 -150
- data/spec/controllers/passwords_controller_spec.rb +0 -32
- data/spec/models/users/authentication_spec.rb +0 -19
- data/spec/support/auth_macros.rb +0 -49
- data/spec/views/authentications/new.haml_spec.rb +0 -31
@@ -6,8 +6,6 @@
|
|
6
6
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
7
|
#------------------------------------------------------------------------------
|
8
8
|
class EmailsController < ApplicationController
|
9
|
-
before_action :require_user
|
10
|
-
|
11
9
|
# DELETE /emails/1
|
12
10
|
# DELETE /emails/1.json
|
13
11
|
# DELETE /emails/1.xml AJAX
|
@@ -45,9 +45,7 @@ class AccountsController < EntitiesController
|
|
45
45
|
# GET /accounts/1/edit AJAX
|
46
46
|
#----------------------------------------------------------------------------
|
47
47
|
def edit
|
48
|
-
if params[:previous].to_s =~ /(\d+)\z/
|
49
|
-
@previous = Account.my(current_user).find_by_id(Regexp.last_match[1]) || Regexp.last_match[1].to_i
|
50
|
-
end
|
48
|
+
@previous = Account.my(current_user).find_by_id(Regexp.last_match[1]) || Regexp.last_match[1].to_i if params[:previous].to_s =~ /(\d+)\z/
|
51
49
|
|
52
50
|
respond_with(@account)
|
53
51
|
end
|
@@ -84,9 +84,7 @@ class CampaignsController < EntitiesController
|
|
84
84
|
# GET /campaigns/1/edit AJAX
|
85
85
|
#----------------------------------------------------------------------------
|
86
86
|
def edit
|
87
|
-
if params[:previous].to_s =~ /(\d+)\z/
|
88
|
-
@previous = Campaign.my(current_user).find_by_id(Regexp.last_match[1]) || Regexp.last_match[1].to_i
|
89
|
-
end
|
87
|
+
@previous = Campaign.my(current_user).find_by_id(Regexp.last_match[1]) || Regexp.last_match[1].to_i if params[:previous].to_s =~ /(\d+)\z/
|
90
88
|
|
91
89
|
respond_with(@campaign)
|
92
90
|
end
|
@@ -196,8 +194,13 @@ class CampaignsController < EntitiesController
|
|
196
194
|
other: 0
|
197
195
|
]
|
198
196
|
Setting.campaign_status.each do |key|
|
199
|
-
@campaign_status_total[key] =
|
200
|
-
|
197
|
+
@campaign_status_total[key] = 0
|
198
|
+
end
|
199
|
+
|
200
|
+
status_counts = Campaign.my(current_user).where(status: Setting.campaign_status).group(:status).count
|
201
|
+
status_counts.each do |key, total|
|
202
|
+
@campaign_status_total[key.to_sym] = total
|
203
|
+
@campaign_status_total[:other] -= total
|
201
204
|
end
|
202
205
|
@campaign_status_total[:other] += @campaign_status_total[:all]
|
203
206
|
end
|
@@ -51,9 +51,7 @@ class ContactsController < EntitiesController
|
|
51
51
|
#----------------------------------------------------------------------------
|
52
52
|
def edit
|
53
53
|
@account = @contact.account || Account.new(user: current_user)
|
54
|
-
if params[:previous].to_s =~ /(\d+)\z/
|
55
|
-
@previous = Contact.my(current_user).find_by_id(Regexp.last_match[1]) || Regexp.last_match[1].to_i
|
56
|
-
end
|
54
|
+
@previous = Contact.my(current_user).find_by_id(Regexp.last_match[1]) || Regexp.last_match[1].to_i if params[:previous].to_s =~ /(\d+)\z/
|
57
55
|
|
58
56
|
respond_with(@contact)
|
59
57
|
end
|
@@ -67,17 +65,7 @@ class ContactsController < EntitiesController
|
|
67
65
|
@contact.add_comment_by_user(@comment_body, current_user)
|
68
66
|
@contacts = get_contacts if called_from_index_page?
|
69
67
|
else
|
70
|
-
if params[:account]
|
71
|
-
@account = if params[:account][:id].blank?
|
72
|
-
if request.referer =~ /\/accounts\/(\d+)\z/
|
73
|
-
Account.find(Regexp.last_match[1]) # related account
|
74
|
-
else
|
75
|
-
Account.new(user: current_user)
|
76
|
-
end
|
77
|
-
else
|
78
|
-
Account.find(params[:account][:id])
|
79
|
-
end
|
80
|
-
end
|
68
|
+
@account = guess_related_account(params[:account][:id], request.referer, current_user) if params[:account]
|
81
69
|
@opportunity = Opportunity.my(current_user).find(params[:opportunity]) unless params[:opportunity].blank?
|
82
70
|
end
|
83
71
|
end
|
@@ -87,13 +75,7 @@ class ContactsController < EntitiesController
|
|
87
75
|
#----------------------------------------------------------------------------
|
88
76
|
def update
|
89
77
|
respond_with(@contact) do |_format|
|
90
|
-
unless @contact.update_with_account_and_permissions(params.permit!)
|
91
|
-
@account = if @contact.account
|
92
|
-
@contact.account
|
93
|
-
else
|
94
|
-
Account.new(user: current_user)
|
95
|
-
end
|
96
|
-
end
|
78
|
+
@account = @contact.account || Account.new(user: current_user) unless @contact.update_with_account_and_permissions(params.permit!)
|
97
79
|
end
|
98
80
|
end
|
99
81
|
|
@@ -128,9 +110,7 @@ class ContactsController < EntitiesController
|
|
128
110
|
# Sorting and naming only: set the same option for Leads if the hasn't been set yet.
|
129
111
|
if params[:sort_by]
|
130
112
|
current_user.pref[:contacts_sort_by] = Contact.sort_by_map[params[:sort_by]]
|
131
|
-
if Lead.sort_by_fields.include?(params[:sort_by])
|
132
|
-
current_user.pref[:leads_sort_by] ||= Lead.sort_by_map[params[:sort_by]]
|
133
|
-
end
|
113
|
+
current_user.pref[:leads_sort_by] ||= Lead.sort_by_map[params[:sort_by]] if Lead.sort_by_fields.include?(params[:sort_by])
|
134
114
|
end
|
135
115
|
if params[:naming]
|
136
116
|
current_user.pref[:contacts_naming] = params[:naming]
|
@@ -52,9 +52,7 @@ class LeadsController < EntitiesController
|
|
52
52
|
def edit
|
53
53
|
get_campaigns
|
54
54
|
|
55
|
-
if params[:previous].to_s =~ /(\d+)\z/
|
56
|
-
@previous = Lead.my(current_user).find_by_id(Regexp.last_match[1]) || Regexp.last_match[1].to_i
|
57
|
-
end
|
55
|
+
@previous = Lead.my(current_user).find_by_id(Regexp.last_match[1]) || Regexp.last_match[1].to_i if params[:previous].to_s =~ /(\d+)\z/
|
58
56
|
|
59
57
|
respond_with(@lead)
|
60
58
|
end
|
@@ -110,9 +108,7 @@ class LeadsController < EntitiesController
|
|
110
108
|
@accounts = Account.my(current_user).order('name')
|
111
109
|
@opportunity = Opportunity.new(user: current_user, access: "Lead", stage: "prospecting", campaign: @lead.campaign, source: @lead.source)
|
112
110
|
|
113
|
-
if params[:previous].to_s =~ /(\d+)\z/
|
114
|
-
@previous = Lead.my(current_user).find_by_id(Regexp.last_match[1]) || Regexp.last_match[1].to_i
|
115
|
-
end
|
111
|
+
@previous = Lead.my(current_user).find_by_id(Regexp.last_match[1]) || Regexp.last_match[1].to_i if params[:previous].to_s =~ /(\d+)\z/
|
116
112
|
|
117
113
|
respond_with(@lead)
|
118
114
|
end
|
@@ -142,7 +138,10 @@ class LeadsController < EntitiesController
|
|
142
138
|
update_sidebar
|
143
139
|
|
144
140
|
respond_with(@lead) do |format|
|
145
|
-
format.html
|
141
|
+
format.html do
|
142
|
+
flash[:notice] = t(:msg_asset_rejected, @lead.full_name)
|
143
|
+
redirect_to leads_path
|
144
|
+
end
|
146
145
|
end
|
147
146
|
end
|
148
147
|
|
@@ -166,9 +165,7 @@ class LeadsController < EntitiesController
|
|
166
165
|
# Sorting and naming only: set the same option for Contacts if the hasn't been set yet.
|
167
166
|
if params[:sort_by]
|
168
167
|
current_user.pref[:leads_sort_by] = Lead.sort_by_map[params[:sort_by]]
|
169
|
-
if Contact.sort_by_fields.include?(params[:sort_by])
|
170
|
-
current_user.pref[:contacts_sort_by] ||= Contact.sort_by_map[params[:sort_by]]
|
171
|
-
end
|
168
|
+
current_user.pref[:contacts_sort_by] ||= Contact.sort_by_map[params[:sort_by]] if Contact.sort_by_fields.include?(params[:sort_by])
|
172
169
|
end
|
173
170
|
if params[:naming]
|
174
171
|
current_user.pref[:leads_naming] = params[:naming]
|
@@ -248,10 +245,17 @@ class LeadsController < EntitiesController
|
|
248
245
|
all: Lead.my(current_user).count,
|
249
246
|
other: 0
|
250
247
|
]
|
248
|
+
|
251
249
|
Setting.lead_status.each do |key|
|
252
|
-
@lead_status_total[key] =
|
253
|
-
|
250
|
+
@lead_status_total[key] = 0
|
251
|
+
end
|
252
|
+
|
253
|
+
status_counts = Lead.my(current_user).where(status: Setting.lead_status).group(:status).count
|
254
|
+
status_counts.each do |key, total|
|
255
|
+
@lead_status_total[key.to_sym] = total
|
256
|
+
@lead_status_total[:other] -= total
|
254
257
|
end
|
258
|
+
|
255
259
|
@lead_status_total[:other] += @lead_status_total[:all]
|
256
260
|
end
|
257
261
|
end
|
@@ -34,8 +34,8 @@ class OpportunitiesController < EntitiesController
|
|
34
34
|
#----------------------------------------------------------------------------
|
35
35
|
def new
|
36
36
|
@opportunity.attributes = { user: current_user, stage: Opportunity.default_stage, access: Setting.default_access, assigned_to: nil }
|
37
|
-
@account
|
38
|
-
@accounts
|
37
|
+
@account = Account.new(user: current_user, access: Setting.default_access)
|
38
|
+
@accounts = Account.my(current_user).order('name')
|
39
39
|
|
40
40
|
if params[:related]
|
41
41
|
model, id = params[:related].split('_')
|
@@ -57,9 +57,7 @@ class OpportunitiesController < EntitiesController
|
|
57
57
|
@account = @opportunity.account || Account.new(user: current_user)
|
58
58
|
@accounts = Account.my(current_user).order('name')
|
59
59
|
|
60
|
-
if params[:previous].to_s =~ /(\d+)\z/
|
61
|
-
@previous = Opportunity.my(current_user).find_by_id(Regexp.last_match[1]) || Regexp.last_match[1].to_i
|
62
|
-
end
|
60
|
+
@previous = Opportunity.my(current_user).find_by_id(Regexp.last_match[1]) || Regexp.last_match[1].to_i if params[:previous].to_s =~ /(\d+)\z/
|
63
61
|
|
64
62
|
respond_with(@opportunity)
|
65
63
|
end
|
@@ -81,15 +79,7 @@ class OpportunitiesController < EntitiesController
|
|
81
79
|
end
|
82
80
|
else
|
83
81
|
@accounts = Account.my(current_user).order('name')
|
84
|
-
@account =
|
85
|
-
if request.referer =~ /\/accounts\/(\d+)\z/
|
86
|
-
Account.find(Regexp.last_match[1]) # related account
|
87
|
-
else
|
88
|
-
Account.new(user: current_user)
|
89
|
-
end
|
90
|
-
else
|
91
|
-
Account.find(params[:account][:id])
|
92
|
-
end
|
82
|
+
@account = guess_related_account(params[:account][:id], request.referer, current_user)
|
93
83
|
@contact = Contact.find(params[:contact]) unless params[:contact].blank?
|
94
84
|
@campaign = Campaign.find(params[:campaign]) unless params[:campaign].blank?
|
95
85
|
end
|
@@ -169,6 +159,10 @@ class OpportunitiesController < EntitiesController
|
|
169
159
|
|
170
160
|
private
|
171
161
|
|
162
|
+
def order_by_attributes(scope, order)
|
163
|
+
scope.weighted_sort.order(order)
|
164
|
+
end
|
165
|
+
|
172
166
|
#----------------------------------------------------------------------------
|
173
167
|
alias get_opportunities get_list_of_records
|
174
168
|
|
@@ -207,9 +201,16 @@ class OpportunitiesController < EntitiesController
|
|
207
201
|
all: Opportunity.my(current_user).count,
|
208
202
|
other: 0
|
209
203
|
]
|
204
|
+
stages = []
|
210
205
|
@stage.each do |_value, key|
|
211
|
-
|
212
|
-
@opportunity_stage_total[
|
206
|
+
stages << key
|
207
|
+
@opportunity_stage_total[key] = 0
|
208
|
+
end
|
209
|
+
|
210
|
+
stage_counts = Opportunity.my(current_user).where(stage: stages).group(:stage).count
|
211
|
+
stage_counts.each do |key, total|
|
212
|
+
@opportunity_stage_total[key.to_sym] = total
|
213
|
+
@opportunity_stage_total[:other] -= total
|
213
214
|
end
|
214
215
|
@opportunity_stage_total[:other] += @opportunity_stage_total[:all]
|
215
216
|
end
|
@@ -6,7 +6,6 @@
|
|
6
6
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
7
|
#------------------------------------------------------------------------------
|
8
8
|
class EntitiesController < ApplicationController
|
9
|
-
before_action :require_user
|
10
9
|
before_action :set_current_tab, only: %i[index show]
|
11
10
|
before_action :set_view, only: %i[index show redraw]
|
12
11
|
|
@@ -22,7 +21,7 @@ class EntitiesController < ApplicationController
|
|
22
21
|
# Common attach handler for all core controllers.
|
23
22
|
#----------------------------------------------------------------------------
|
24
23
|
def attach
|
25
|
-
@attachment = params[:assets].
|
24
|
+
@attachment = find_class(params[:assets]).find(params[:asset_id])
|
26
25
|
@attached = entity.attach!(@attachment)
|
27
26
|
entity.reload
|
28
27
|
|
@@ -32,7 +31,7 @@ class EntitiesController < ApplicationController
|
|
32
31
|
# Common discard handler for all core controllers.
|
33
32
|
#----------------------------------------------------------------------------
|
34
33
|
def discard
|
35
|
-
@attachment = params[:attachment].
|
34
|
+
@attachment = find_class(params[:attachment]).find(params[:attachment_id])
|
36
35
|
entity.discard!(@attachment)
|
37
36
|
entity.reload
|
38
37
|
|
@@ -152,16 +151,16 @@ class EntitiesController < ApplicationController
|
|
152
151
|
scope = scope.state(filter) if filter.present?
|
153
152
|
end
|
154
153
|
|
155
|
-
scope = scope.text_search(query)
|
154
|
+
scope = scope.text_search(query) if query.present?
|
156
155
|
scope = scope.tagged_with(tags, on: :tags) if tags.present?
|
157
156
|
|
158
157
|
# Ignore this order when doing advanced search
|
159
158
|
unless advanced_search
|
160
159
|
order = current_user.pref[:"#{controller_name}_sort_by"] || klass.sort_by
|
161
|
-
scope = scope
|
160
|
+
scope = order_by_attributes(scope, order)
|
162
161
|
end
|
163
162
|
|
164
|
-
@search_results_count = scope.
|
163
|
+
@search_results_count = scope.size
|
165
164
|
|
166
165
|
# Pagination is disabled for xls and csv requests
|
167
166
|
unless wants.xls? || wants.csv?
|
@@ -178,9 +177,14 @@ class EntitiesController < ApplicationController
|
|
178
177
|
scope
|
179
178
|
end
|
180
179
|
|
180
|
+
#----------------------------------------------------------------------------
|
181
|
+
def order_by_attributes(scope, order)
|
182
|
+
scope.order(order)
|
183
|
+
end
|
184
|
+
|
181
185
|
#----------------------------------------------------------------------------
|
182
186
|
def update_recently_viewed
|
183
|
-
entity.versions.create(event: :view, whodunnit: PaperTrail.whodunnit)
|
187
|
+
entity.versions.create(event: :view, whodunnit: PaperTrail.request.whodunnit)
|
184
188
|
end
|
185
189
|
|
186
190
|
# Somewhat simplistic parser that extracts query and hash-prefixed tags from
|
@@ -190,13 +194,18 @@ class EntitiesController < ApplicationController
|
|
190
194
|
#----------------------------------------------------------------------------
|
191
195
|
def parse_query_and_tags(search_string)
|
192
196
|
return ['', ''] if search_string.blank?
|
197
|
+
|
193
198
|
query = []
|
194
199
|
tags = []
|
195
|
-
search_string.
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
+
if search_string.start_with?("#") && search_string.end_with?("#")
|
201
|
+
tags << search_string[1..-2]
|
202
|
+
else
|
203
|
+
search_string.strip.split(/\s+/).each do |token|
|
204
|
+
if token.starts_with?("#")
|
205
|
+
tags << token[1..-1]
|
206
|
+
else
|
207
|
+
query << token
|
208
|
+
end
|
200
209
|
end
|
201
210
|
end
|
202
211
|
[query.join(" "), tags.join(", ")]
|
@@ -226,4 +235,14 @@ class EntitiesController < ApplicationController
|
|
226
235
|
page = params[:page]&.to_i
|
227
236
|
[0, page].max if page
|
228
237
|
end
|
238
|
+
|
239
|
+
def guess_related_account(id, url, user)
|
240
|
+
return Account.find(id) unless id.blank?
|
241
|
+
|
242
|
+
if url =~ %r{/accounts/(\d+)\z}
|
243
|
+
Account.find(Regexp.last_match[1]) # related account
|
244
|
+
else
|
245
|
+
Account.new(user: user)
|
246
|
+
end
|
247
|
+
end
|
229
248
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
7
|
#------------------------------------------------------------------------------
|
8
8
|
class HomeController < ApplicationController
|
9
|
-
|
9
|
+
skip_before_action :authenticate_user!, only: %i[timezone]
|
10
10
|
before_action :set_current_tab, only: :index
|
11
11
|
|
12
12
|
#----------------------------------------------------------------------------
|
@@ -160,9 +160,7 @@ class HomeController < ApplicationController
|
|
160
160
|
duration = current_user.pref[:activity_duration]
|
161
161
|
if duration
|
162
162
|
words = duration.split("_") # "two_weeks" => 2.weeks
|
163
|
-
if %w[one two].include?(words.first) && %w[hour day days week weeks month].include?(words.last)
|
164
|
-
%w[zero one two].index(words.first).send(words.last)
|
165
|
-
end
|
163
|
+
%w[zero one two].index(words.first).send(words.last) if %w[one two].include?(words.first) && %w[hour day days week weeks month].include?(words.last)
|
166
164
|
end
|
167
165
|
end
|
168
166
|
end
|
@@ -5,63 +5,7 @@
|
|
5
5
|
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
6
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
7
|
#------------------------------------------------------------------------------
|
8
|
-
class PasswordsController <
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
#----------------------------------------------------------------------------
|
13
|
-
def new
|
14
|
-
# <-- render new.html.haml
|
15
|
-
end
|
16
|
-
|
17
|
-
#----------------------------------------------------------------------------
|
18
|
-
def create
|
19
|
-
@user = User.find_by_email(params[:email])
|
20
|
-
if @user
|
21
|
-
@user.deliver_password_reset_instructions!
|
22
|
-
flash[:notice] = t(:msg_pwd_instructions_sent)
|
23
|
-
redirect_to root_url
|
24
|
-
else
|
25
|
-
flash[:notice] = t(:msg_email_not_found)
|
26
|
-
redirect_to action: :new
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
#----------------------------------------------------------------------------
|
31
|
-
def edit
|
32
|
-
# <-- render edit.html.haml
|
33
|
-
end
|
34
|
-
|
35
|
-
#----------------------------------------------------------------------------
|
36
|
-
def update
|
37
|
-
if empty_password?
|
38
|
-
flash[:notice] = t(:msg_enter_new_password)
|
39
|
-
render :edit
|
40
|
-
elsif @user.update_attributes(params.require(:user).permit(:password, :password_confirmation))
|
41
|
-
flash[:notice] = t(:msg_password_updated)
|
42
|
-
redirect_to profile_url
|
43
|
-
else
|
44
|
-
render :edit
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
#----------------------------------------------------------------------------
|
51
|
-
def load_user_using_perishable_token
|
52
|
-
@user = User.find_using_perishable_token(params[:id])
|
53
|
-
unless @user
|
54
|
-
flash[:notice] = <<-EOS
|
55
|
-
Sorry, we could not locate your user profile. Try to copy and paste the URL
|
56
|
-
from your email into your browser or restart the reset password process.
|
57
|
-
EOS
|
58
|
-
redirect_to root_url
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
#----------------------------------------------------------------------------
|
63
|
-
def empty_password?
|
64
|
-
(params[:user][:password] == params[:user][:password_confirmation]) &&
|
65
|
-
params[:user][:password].blank? # " ".blank? == true
|
66
|
-
end
|
8
|
+
class PasswordsController < Devise::PasswordsController
|
9
|
+
respond_to :html
|
10
|
+
append_view_path 'app/views/devise'
|
67
11
|
end
|
data/{spec/features/support/maintain_sessions.rb → app/controllers/registrations_controller.rb}
RENAMED
@@ -5,8 +5,15 @@
|
|
5
5
|
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
6
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
7
|
#------------------------------------------------------------------------------
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
class RegistrationsController < Devise::RegistrationsController
|
9
|
+
respond_to :html
|
10
|
+
append_view_path 'app/views/devise'
|
11
|
+
|
12
|
+
def edit
|
13
|
+
redirect_to profile_path
|
14
|
+
end
|
15
|
+
|
16
|
+
def after_inactive_sign_up_path_for(*)
|
17
|
+
new_user_session_path
|
18
|
+
end
|
19
|
+
end
|