fat_free_crm 0.15.0.beta.2 → 0.15.0

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.

Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/.docker/nginx/sites-enabled/ffcrm.conf +8 -0
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +4 -1
  5. data/.rubocop_todo.yml +190 -89
  6. data/.travis.yml +10 -3
  7. data/CHANGELOG.md +27 -0
  8. data/{CONTRIBUTORS → CONTRIBUTORS.md} +2 -1
  9. data/Dockerfile +15 -13
  10. data/Gemfile +7 -4
  11. data/Gemfile.lock +200 -167
  12. data/README.md +4 -2
  13. data/app/assets/javascripts/crm_sortable.js.coffee +5 -0
  14. data/app/assets/javascripts/timeago.js.coffee +5 -0
  15. data/app/assets/stylesheets/about.css.scss +5 -0
  16. data/app/assets/stylesheets/common.scss +2 -1
  17. data/app/controllers/admin/fields_controller.rb +1 -1
  18. data/app/controllers/admin/groups_controller.rb +5 -1
  19. data/app/controllers/admin/tags_controller.rb +1 -1
  20. data/app/controllers/admin/users_controller.rb +10 -6
  21. data/app/controllers/application_controller.rb +13 -13
  22. data/app/controllers/authentications_controller.rb +2 -2
  23. data/app/controllers/comments_controller.rb +3 -2
  24. data/app/controllers/entities/contacts_controller.rb +9 -7
  25. data/app/controllers/entities/opportunities_controller.rb +1 -1
  26. data/app/controllers/entities_controller.rb +4 -4
  27. data/app/controllers/home_controller.rb +9 -9
  28. data/app/controllers/passwords_controller.rb +1 -1
  29. data/app/controllers/tasks_controller.rb +2 -1
  30. data/app/controllers/users_controller.rb +4 -2
  31. data/app/helpers/application_helper.rb +9 -9
  32. data/app/helpers/javascript_helper.rb +5 -0
  33. data/app/helpers/opportunities_helper.rb +1 -1
  34. data/app/helpers/remote_link_pagination_helper.rb +5 -0
  35. data/app/inputs/date_pair_input.rb +1 -1
  36. data/app/models/entities/account.rb +2 -2
  37. data/app/models/entities/account_contact.rb +1 -1
  38. data/app/models/entities/campaign.rb +3 -3
  39. data/app/models/entities/contact.rb +3 -3
  40. data/app/models/entities/lead.rb +2 -2
  41. data/app/models/entities/opportunity.rb +3 -3
  42. data/app/models/fields/custom_field.rb +1 -1
  43. data/app/models/fields/custom_field_pair.rb +2 -2
  44. data/app/models/fields/field.rb +1 -1
  45. data/app/models/polymorphic/address.rb +2 -2
  46. data/app/models/polymorphic/avatar.rb +4 -2
  47. data/app/models/polymorphic/email.rb +8 -6
  48. data/app/models/polymorphic/task.rb +3 -1
  49. data/app/models/polymorphic/version.rb +3 -3
  50. data/app/models/users/ability.rb +1 -1
  51. data/app/models/users/permission.rb +2 -0
  52. data/app/models/users/user.rb +2 -2
  53. data/app/views/accounts/index.js.haml +1 -1
  54. data/app/views/admin/fields/_sort_by.html.haml +1 -1
  55. data/app/views/admin/users/_user.html.haml +1 -1
  56. data/app/views/campaigns/index.js.haml +1 -1
  57. data/app/views/contacts/index.js.haml +1 -1
  58. data/app/views/entities/_basic_search.html.haml +1 -1
  59. data/app/views/home/_duration_menu.html.haml +1 -1
  60. data/app/views/home/_events_menu.html.haml +1 -1
  61. data/app/views/home/_users_menu.html.haml +1 -1
  62. data/app/views/layouts/application.html.haml +1 -1
  63. data/app/views/leads/index.js.haml +1 -1
  64. data/app/views/opportunities/index.js.haml +1 -1
  65. data/app/views/shared/_naming.html.haml +1 -1
  66. data/app/views/users/_languages.html.haml +1 -1
  67. data/config/application.rb +2 -3
  68. data/config/boot.rb +2 -0
  69. data/config/deploy.example.rb +1 -1
  70. data/config/environments/development.rb +2 -0
  71. data/config/environments/production.rb +1 -1
  72. data/config/environments/test.rb +2 -2
  73. data/config/initializers/assets.rb +6 -1
  74. data/config/initializers/backtrace_silencers.rb +5 -0
  75. data/config/initializers/constants.rb +1 -1
  76. data/config/initializers/cookies_serializer.rb +5 -0
  77. data/config/initializers/custom_field_ransack_translations.rb +5 -0
  78. data/config/initializers/filter_parameter_logging.rb +5 -0
  79. data/config/initializers/inflections.rb +5 -0
  80. data/config/initializers/paper_trail.rb +5 -0
  81. data/config/initializers/ransack.rb +3 -3
  82. data/config/initializers/session_store.rb +5 -0
  83. data/config/initializers/wrap_parameters.rb +5 -0
  84. data/config/locales/et.yml +207 -0
  85. data/config/locales/et_fat_free_crm.yml +928 -0
  86. data/config/locales/pt-BR_ransack.yml +81 -0
  87. data/config/locales/th.rb +1 -1
  88. data/config/routes.rb +18 -18
  89. data/db/migrate/20100928030598_create_sessions.rb +1 -1
  90. data/db/migrate/20100928030599_create_users.rb +2 -2
  91. data/db/migrate/20100928030600_create_openid_tables.rb +1 -1
  92. data/db/migrate/20100928030601_create_accounts.rb +2 -2
  93. data/db/migrate/20100928030602_create_permissions.rb +1 -1
  94. data/db/migrate/20100928030603_create_settings.rb +1 -1
  95. data/db/migrate/20100928030604_create_preferences.rb +2 -2
  96. data/db/migrate/20100928030605_create_campaigns.rb +2 -2
  97. data/db/migrate/20100928030606_create_leads.rb +2 -2
  98. data/db/migrate/20100928030607_create_contacts.rb +2 -2
  99. data/db/migrate/20100928030608_create_opportunities.rb +2 -2
  100. data/db/migrate/20100928030609_create_account_contacts.rb +1 -1
  101. data/db/migrate/20100928030610_create_account_opportunities.rb +1 -1
  102. data/db/migrate/20100928030611_create_contact_opportunities.rb +1 -1
  103. data/db/migrate/20100928030612_create_tasks.rb +2 -2
  104. data/db/migrate/20100928030613_create_comments.rb +1 -1
  105. data/db/migrate/20100928030614_create_activities.rb +1 -1
  106. data/db/migrate/20100928030615_create_avatars.rb +1 -1
  107. data/db/migrate/20100928030616_rename_remember_token.rb +1 -1
  108. data/db/migrate/20100928030617_drop_openid_tables.rb +1 -1
  109. data/db/migrate/20100928030618_add_admin_to_users.rb +1 -1
  110. data/db/migrate/20100928030619_add_suspended_to_users.rb +1 -1
  111. data/db/migrate/20100928030620_remove_uuid.rb +2 -2
  112. data/db/migrate/20100928030621_add_email_to_accounts.rb +1 -1
  113. data/db/migrate/20100928030622_add_background_info_to_models.rb +1 -1
  114. data/db/migrate/20100928030623_create_addresses.rb +2 -2
  115. data/db/migrate/20100928030624_add_index_on_permissions.rb +3 -3
  116. data/db/migrate/20100928030625_create_emails.rb +2 -2
  117. data/db/migrate/20100928030626_add_state_to_timeline_objects.rb +1 -1
  118. data/db/migrate/20100928030627_acts_as_taggable_on_migration.rb +2 -2
  119. data/db/migrate/20101221123456_add_single_access_token_to_users.rb +1 -1
  120. data/db/migrate/20101221345678_add_rating_and_category_to_accounts.rb +1 -1
  121. data/db/migrate/20110719082054_add_skype_to_contacts_and_leads.rb +1 -1
  122. data/db/migrate/20111101083437_create_fields.rb +1 -1
  123. data/db/migrate/20111101090312_create_field_groups.rb +1 -1
  124. data/db/migrate/20111116091952_add_field_groups_tag_id.rb +1 -1
  125. data/db/migrate/20111117041311_change_fields_collection_to_text.rb +1 -1
  126. data/db/migrate/20111201030535_add_field_groups_klass_name.rb +2 -2
  127. data/db/migrate/20120121054235_create_lists.rb +1 -1
  128. data/db/migrate/20120216031616_create_versions.rb +3 -3
  129. data/db/migrate/20120216042541_is_paranoid_to_paper_trail.rb +1 -1
  130. data/db/migrate/20120220233724_add_versions_object_changes.rb +1 -1
  131. data/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb +1 -1
  132. data/db/migrate/20120309070209_add_versions_related.rb +1 -1
  133. data/db/migrate/20120314080441_add_subscribed_users_to_entities.rb +2 -2
  134. data/db/migrate/20120316045804_activities_to_versions.rb +1 -1
  135. data/db/migrate/20120405080727_change_subscribed_users_to_set.rb +1 -1
  136. data/db/migrate/20120405080742_change_further_subscribed_users_to_set.rb +2 -2
  137. data/db/migrate/20120406082136_create_groups.rb +2 -2
  138. data/db/migrate/20120413034923_add_index_on_versions_item_type.rb +1 -1
  139. data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +3 -3
  140. data/db/migrate/20120528102124_increase_length_of_version_events.rb +1 -1
  141. data/db/migrate/20120801032706_add_pair_id_to_fields.rb +1 -1
  142. data/db/migrate/20121003063155_add_settings_to_custom_fields.rb +1 -1
  143. data/db/migrate/20121221033947_fix_country_mapping.rb +1 -1
  144. data/db/migrate/20131207033244_add_user_id_to_lists.rb +1 -1
  145. data/db/migrate/20140916011927_add_created_at_index_on_versions.rb +1 -1
  146. data/db/migrate/20140916012922_add_indexes_to_model_associations.rb +3 -3
  147. data/db/migrate/20141126031837_increase_email_to254_chars.rb +1 -1
  148. data/db/migrate/20141230021159_add_transaction_id_column_to_versions.rb +1 -1
  149. data/db/migrate/20141230205453_add_missing_unique_indices.acts_as_taggable_on_engine.rb +4 -4
  150. data/db/migrate/20141230205454_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +1 -1
  151. data/db/migrate/20141230205455_add_missing_taggable_index.acts_as_taggable_on_engine.rb +3 -3
  152. data/db/migrate/20150123060900_convert_radio_to_radio_buttons.rb +1 -1
  153. data/db/migrate/20150227123054_remove_last_request_at_from_users.rb +1 -1
  154. data/db/migrate/20150427131956_create_index_related_type.rb +3 -3
  155. data/db/migrate/20160511053730_add_account_contacts_index.rb +2 -2
  156. data/docker-compose.yml +17 -13
  157. data/fat_free_crm.gemspec +4 -6
  158. data/lib/development_tasks/license.rake +12 -9
  159. data/lib/fat_free_crm/callback.rb +4 -4
  160. data/lib/fat_free_crm/engine.rb +2 -2
  161. data/lib/fat_free_crm/exportable.rb +2 -2
  162. data/lib/fat_free_crm/fields.rb +2 -4
  163. data/lib/fat_free_crm/gem_ext.rb +0 -1
  164. data/lib/fat_free_crm/gem_ext/rake/task.rb +2 -0
  165. data/lib/fat_free_crm/mail_processor/base.rb +4 -4
  166. data/lib/fat_free_crm/mail_processor/dropbox.rb +1 -1
  167. data/lib/fat_free_crm/permissions.rb +5 -5
  168. data/lib/fat_free_crm/sortable.rb +1 -1
  169. data/lib/fat_free_crm/version.rb +1 -1
  170. data/lib/gravatar_image_tag.rb +1 -0
  171. data/lib/tasks/ffcrm/demo.rake +2 -2
  172. data/spec/controllers/admin/users_controller_spec.rb +25 -25
  173. data/spec/controllers/authentications_controller_spec.rb +9 -9
  174. data/spec/controllers/comments_controller_spec.rb +15 -15
  175. data/spec/controllers/emails_controller_spec.rb +2 -2
  176. data/spec/controllers/entities/accounts_controller_spec.rb +46 -46
  177. data/spec/controllers/entities/campaigns_controller_spec.rb +46 -46
  178. data/spec/controllers/entities/contacts_controller_spec.rb +55 -55
  179. data/spec/controllers/entities/leads_controller_spec.rb +85 -85
  180. data/spec/controllers/entities/opportunities_controller_spec.rb +74 -74
  181. data/spec/controllers/home_controller_spec.rb +11 -11
  182. data/spec/controllers/passwords_controller_spec.rb +2 -2
  183. data/spec/controllers/tasks_controller_spec.rb +37 -37
  184. data/spec/controllers/users_controller_spec.rb +31 -31
  185. data/spec/factories/campaign_factories.rb +1 -1
  186. data/spec/factories/contact_factories.rb +1 -1
  187. data/spec/factories/field_factories.rb +1 -1
  188. data/spec/factories/lead_factories.rb +2 -2
  189. data/spec/factories/opportunity_factories.rb +3 -3
  190. data/spec/factories/shared_factories.rb +1 -1
  191. data/spec/factories/task_factories.rb +1 -1
  192. data/spec/features/support/browser.rb +9 -1
  193. data/spec/lib/fields_spec.rb +2 -2
  194. data/spec/lib/permissions_spec.rb +38 -6
  195. data/spec/lib/view_factory_spec.rb +2 -2
  196. data/spec/models/fields/custom_field_spec.rb +3 -3
  197. data/spec/models/observers/entity_observer_spec.rb +1 -1
  198. data/spec/models/polymorphic/version_spec.rb +11 -11
  199. data/spec/models/users/abilities/user_ability_spec.rb +8 -3
  200. data/spec/models/users/permission_spec.rb +8 -0
  201. data/spec/models/users/user_spec.rb +1 -1
  202. data/spec/shared/controllers.rb +10 -10
  203. data/spec/spec_helper.rb +1 -1
  204. data/spec/views/accounts/index.haml_spec.rb +1 -1
  205. data/spec/views/accounts/update.js.haml_spec.rb +2 -2
  206. data/spec/views/admin/users/update.js.haml_spec.rb +2 -2
  207. data/spec/views/application/auto_complete.haml_spec.rb +1 -1
  208. data/spec/views/campaigns/index.haml_spec.rb +1 -1
  209. data/spec/views/campaigns/update.js.haml_spec.rb +2 -2
  210. data/spec/views/contacts/index.haml_spec.rb +1 -1
  211. data/spec/views/contacts/update.js.haml_spec.rb +2 -2
  212. data/spec/views/home/options.js.haml_spec.rb +1 -1
  213. data/spec/views/leads/index.haml_spec.rb +1 -1
  214. data/spec/views/leads/promote.js.haml_spec.rb +2 -2
  215. data/spec/views/leads/update.js.haml_spec.rb +2 -2
  216. data/spec/views/opportunities/index.haml_spec.rb +1 -1
  217. data/spec/views/opportunities/update.js.haml_spec.rb +1 -1
  218. data/spec/views/tasks/_edit.haml_spec.rb +2 -2
  219. data/spec/views/tasks/create.js.haml_spec.rb +2 -2
  220. data/spec/views/tasks/edit.js.haml_spec.rb +1 -1
  221. data/spec/views/users/change_password.js.haml_spec.rb +2 -2
  222. data/spec/views/users/update.js.haml_spec.rb +2 -2
  223. data/spec/views/users/upload_avatar.js.haml_spec.rb +2 -2
  224. metadata +17 -20
  225. data/lib/fat_free_crm/gem_ext/active_record/schema_dumper.rb +0 -27
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- # Fat Free CRM [![TravisCI][travis-img-url]][travis-ci-url] [![Code Climate](https://codeclimate.com/github/fatfreecrm/fat_free_crm.png)](https://codeclimate.com/github/fatfreecrm/fat_free_crm)
1
+ # Fat Free CRM [![TravisCI][travis-img-url]][travis-ci-url] [![Code Climate][codeclimate-img-url]][codeclimate-url]
2
2
 
3
- [travis-img-url]: https://secure.travis-ci.org/fatfreecrm/fat_free_crm.png?branch=master
3
+ [travis-img-url]: https://secure.travis-ci.org/fatfreecrm/fat_free_crm.svg?branch=master
4
4
  [travis-ci-url]: https://travis-ci.org/fatfreecrm/fat_free_crm
5
+ [codeclimate-img-url]: https://codeclimate.com/github/fatfreecrm/fat_free_crm.svg
6
+ [codeclimate-url]: https://codeclimate.com/github/fatfreecrm/fat_free_crm
5
7
 
6
8
  ### An open source, Ruby on Rails [customer relationship management][crm-wiki] platform (CRM).
7
9
 
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2008-2013 Michael Dvorkin and contributors.
2
+ #
3
+ # Fat Free CRM is freely distributable under the terms of MIT license.
4
+ # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
+ #------------------------------------------------------------------------------
1
6
  (($) ->
2
7
  window.crm ||= {}
3
8
 
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2008-2013 Michael Dvorkin and contributors.
2
+ #
3
+ # Fat Free CRM is freely distributable under the terms of MIT license.
4
+ # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
+ #------------------------------------------------------------------------------
1
6
  (($) ->
2
7
 
3
8
  # Run function on page load
@@ -1,3 +1,8 @@
1
+ // Copyright (c) 2008-2013 Michael Dvorkin and contributors.
2
+ //
3
+ // Fat Free CRM is freely distributable under the terms of MIT license.
4
+ // See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
+ //------------------------------------------------------------------------------
1
6
  #about > ul {
2
7
  margin-left: 15px;
3
8
  }
@@ -704,7 +704,8 @@ ul.tools {
704
704
 
705
705
  .mail.highlight,
706
706
  .comment.highlight {
707
- background-color: #f2f2f2; }
707
+ background-color: #f2f2f2;
708
+ word-break: break-all; }
708
709
 
709
710
  .highlight:hover {
710
711
  background-color: seashell;
@@ -6,7 +6,7 @@
6
6
  class Admin::FieldsController < Admin::ApplicationController
7
7
  before_action "set_current_tab('admin/fields')", only: [:index]
8
8
 
9
- load_resource except: [:create, :subform]
9
+ load_resource except: %i[create subform]
10
10
 
11
11
  # GET /fields
12
12
  # GET /fields.xml HTML
@@ -4,7 +4,7 @@
4
4
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
6
  class Admin::GroupsController < Admin::ApplicationController
7
- before_action "set_current_tab('admin/groups')", only: [:index, :show]
7
+ before_action :setup_current_tab, only: %i[index show]
8
8
 
9
9
  load_resource
10
10
 
@@ -62,4 +62,8 @@ class Admin::GroupsController < Admin::ApplicationController
62
62
  def group_params
63
63
  params[:group].permit!
64
64
  end
65
+
66
+ def setup_current_tab
67
+ set_current_tab('admin/groups')
68
+ end
65
69
  end
@@ -4,7 +4,7 @@
4
4
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
6
  class Admin::TagsController < Admin::ApplicationController
7
- before_action "set_current_tab('admin/tags')", only: [:index, :show]
7
+ before_action "set_current_tab('admin/tags')", only: %i[index show]
8
8
 
9
9
  load_resource
10
10
 
@@ -4,7 +4,7 @@
4
4
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
6
  class Admin::UsersController < Admin::ApplicationController
7
- before_action "set_current_tab('admin/users')", only: [:index, :show]
7
+ before_action :setup_current_tab, only: %i[index show]
8
8
 
9
9
  load_resource except: [:create]
10
10
 
@@ -44,8 +44,6 @@ class Admin::UsersController < Admin::ApplicationController
44
44
  # POST /admin/users.xml AJAX
45
45
  #----------------------------------------------------------------------------
46
46
  def create
47
- params[:user][:email].try(:strip!)
48
- params[:user][:password_confirmation] = nil if params[:user][:password_confirmation].blank?
49
47
  @user = User.new(user_params)
50
48
  @user.check_if_needs_approval
51
49
  @user.save_without_session_maintenance
@@ -57,8 +55,6 @@ class Admin::UsersController < Admin::ApplicationController
57
55
  # PUT /admin/users/1.xml AJAX
58
56
  #----------------------------------------------------------------------------
59
57
  def update
60
- params[:user][:email].try(:strip!)
61
- params[:user][:password_confirmation] = nil if params[:user][:password_confirmation].blank?
62
58
  @user = User.find(params[:id])
63
59
  @user.attributes = user_params
64
60
  @user.save_without_session_maintenance
@@ -108,6 +104,10 @@ class Admin::UsersController < Admin::ApplicationController
108
104
  protected
109
105
 
110
106
  def user_params
107
+ return {} unless params[:user]
108
+ params[:user][:email].try(:strip!)
109
+ params[:user][:password_confirmation] = nil if params[:user][:password_confirmation].blank?
110
+
111
111
  params[:user].permit(
112
112
  :admin,
113
113
  :username,
@@ -136,7 +136,7 @@ class Admin::UsersController < Admin::ApplicationController
136
136
  self.current_page = options[:page] if options[:page]
137
137
  self.current_query = params[:query] if params[:query]
138
138
 
139
- @search = klass.search(params[:q])
139
+ @search = klass.ransack(params[:q])
140
140
  @search.build_grouping unless @search.groupings.any?
141
141
 
142
142
  wants = request.format
@@ -146,4 +146,8 @@ class Admin::UsersController < Admin::ApplicationController
146
146
  scope = scope.paginate(page: current_page) if wants.html? || wants.js? || wants.xml?
147
147
  scope
148
148
  end
149
+
150
+ def setup_current_tab
151
+ set_current_tab('admin/users')
152
+ end
149
153
  end
@@ -6,20 +6,20 @@
6
6
  class ApplicationController < ActionController::Base
7
7
  protect_from_forgery
8
8
 
9
- before_filter :set_paper_trail_whodunnit
9
+ before_action :set_paper_trail_whodunnit
10
10
 
11
11
  before_action :set_context
12
12
  before_action :clear_setting_cache
13
13
  before_action :cors_preflight_check
14
- before_action "hook(:app_before_filter, self)"
15
- after_action "hook(:app_after_filter, self)"
14
+ before_action { hook(:app_before_filter, self) }
15
+ after_action { hook(:app_after_filter, self) }
16
16
  after_action :cors_set_access_control_headers
17
17
 
18
18
  helper_method :current_user_session, :current_user, :can_signup?
19
19
  helper_method :called_from_index_page?, :called_from_landing_page?
20
20
  helper_method :klass
21
21
 
22
- respond_to :html, only: [:index, :show, :auto_complete]
22
+ respond_to :html, only: %i[index show auto_complete]
23
23
  respond_to :js
24
24
  respond_to :json, :xml, except: :edit
25
25
  respond_to :atom, :csv, :rss, :xls, only: :index
@@ -36,7 +36,7 @@ class ApplicationController < ActionController::Base
36
36
  @auto_complete = hook(:auto_complete, self, query: @query, user: current_user)
37
37
  if @auto_complete.empty?
38
38
  exclude_ids = auto_complete_ids_to_exclude(params[:related])
39
- @auto_complete = klass.my.text_search(@query).search(id_not_in: exclude_ids).result.limit(10)
39
+ @auto_complete = klass.my.text_search(@query).ransack(id_not_in: exclude_ids).result.limit(10)
40
40
  else
41
41
  @auto_complete = @auto_complete.last
42
42
  end
@@ -135,7 +135,7 @@ class ApplicationController < ActionController::Base
135
135
  flash[:notice] = t(:msg_login_needed) if request.fullpath != "/"
136
136
  respond_to do |format|
137
137
  format.html { redirect_to login_url }
138
- format.js { render text: "window.location = '#{login_url}';" }
138
+ format.js { render plain: "window.location = '#{login_url}';" }
139
139
  end
140
140
  end
141
141
  end
@@ -217,8 +217,8 @@ class ApplicationController < ActionController::Base
217
217
 
218
218
  respond_to do |format|
219
219
  format.html { redirect_to(redirection_url) }
220
- format.js { render text: 'window.location.reload();' }
221
- format.json { render text: flash[:warning], status: :not_found }
220
+ format.js { render plain: 'window.location.reload();' }
221
+ format.json { render plain: flash[:warning], status: :not_found }
222
222
  format.xml { render xml: [flash[:warning]], status: :not_found }
223
223
  end
224
224
  end
@@ -231,8 +231,8 @@ class ApplicationController < ActionController::Base
231
231
  url = send("#{related.pluralize}_path")
232
232
  respond_to do |format|
233
233
  format.html { redirect_to(url) }
234
- format.js { render text: %(window.location.href = "#{url}";) }
235
- format.json { render text: flash[:warning], status: :not_found }
234
+ format.js { render plain: %(window.location.href = "#{url}";) }
235
+ format.json { render plain: flash[:warning], status: :not_found }
236
236
  format.xml { render xml: [flash[:warning]], status: :not_found }
237
237
  end
238
238
  end
@@ -242,8 +242,8 @@ class ApplicationController < ActionController::Base
242
242
  flash[:warning] = t(:msg_not_authorized, default: 'You are not authorized to take this action.')
243
243
  respond_to do |format|
244
244
  format.html { redirect_to(redirection_url) }
245
- format.js { render text: 'window.location.reload();' }
246
- format.json { render text: flash[:warning], status: :unauthorized }
245
+ format.js { render plain: 'window.location.reload();' }
246
+ format.json { render plain: flash[:warning], status: :unauthorized }
247
247
  format.xml { render xml: [flash[:warning]], status: :unauthorized }
248
248
  end
249
249
  end
@@ -272,7 +272,7 @@ class ApplicationController < ActionController::Base
272
272
  headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version, Token'
273
273
  headers['Access-Control-Max-Age'] = '1728000'
274
274
 
275
- render text: '', content_type: 'text/plain'
275
+ render plain: ''
276
276
  end
277
277
  end
278
278
  end
@@ -4,7 +4,7 @@
4
4
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
6
  class AuthenticationsController < ApplicationController
7
- before_action :require_no_user, only: [:new, :create, :show]
7
+ before_action :require_no_user, only: %i[new create show]
8
8
  before_action :require_user, only: :destroy
9
9
 
10
10
  #----------------------------------------------------------------------------
@@ -19,7 +19,7 @@ class AuthenticationsController < ApplicationController
19
19
 
20
20
  #----------------------------------------------------------------------------
21
21
  def create
22
- @authentication = Authentication.new(params[:authentication])
22
+ @authentication = Authentication.new(params[:authentication].permit(:username, :password, :remember_me))
23
23
 
24
24
  if @authentication.save && !@authentication.user.suspended?
25
25
  flash[:notice] = t(:msg_welcome)
@@ -24,8 +24,8 @@ class CommentsController < ApplicationController
24
24
  flash[:warning] = t(:msg_assets_not_available, "notes")
25
25
  respond_to do |format|
26
26
  format.html { redirect_to root_url }
27
- format.json { render text: flash[:warning], status: :not_found }
28
- format.xml { render text: flash[:warning], status: :not_found }
27
+ format.json { render plain: flash[:warning], status: :not_found }
28
+ format.xml { render plain: flash[:warning], status: :not_found }
29
29
  end
30
30
  end
31
31
 
@@ -83,6 +83,7 @@ class CommentsController < ApplicationController
83
83
  protected
84
84
 
85
85
  def comment_params
86
+ return {} unless params[:comment]
86
87
  params[:comment].permit!
87
88
  end
88
89
 
@@ -4,7 +4,7 @@
4
4
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
6
  class ContactsController < EntitiesController
7
- before_action :get_accounts, only: [:new, :create, :edit, :update]
7
+ before_action :get_accounts, only: %i[new create edit update]
8
8
 
9
9
  # GET /contacts
10
10
  #----------------------------------------------------------------------------
@@ -65,14 +65,16 @@ class ContactsController < EntitiesController
65
65
  @contact.add_comment_by_user(@comment_body, current_user)
66
66
  @contacts = get_contacts if called_from_index_page?
67
67
  else
68
- if params[:account][:id].blank?
69
- if request.referer =~ /\/accounts\/(\d+)\z/
70
- @account = Account.find(Regexp.last_match[1]) # related account
68
+ if params[:account]
69
+ if params[:account][:id].blank?
70
+ if request.referer =~ /\/accounts\/(\d+)\z/
71
+ @account = Account.find(Regexp.last_match[1]) # related account
72
+ else
73
+ @account = Account.new(user: current_user)
74
+ end
71
75
  else
72
- @account = Account.new(user: current_user)
76
+ @account = Account.find(params[:account][:id])
73
77
  end
74
- else
75
- @account = Account.find(params[:account][:id])
76
78
  end
77
79
  @opportunity = Opportunity.my.find(params[:opportunity]) unless params[:opportunity].blank?
78
80
  end
@@ -6,7 +6,7 @@
6
6
  class OpportunitiesController < EntitiesController
7
7
  before_action :load_settings
8
8
  before_action :get_data_for_sidebar, only: :index
9
- before_action :set_params, only: [:index, :redraw, :filter]
9
+ before_action :set_params, only: %i[index redraw filter]
10
10
 
11
11
  # GET /opportunities
12
12
  #----------------------------------------------------------------------------
@@ -5,8 +5,8 @@
5
5
  #------------------------------------------------------------------------------
6
6
  class EntitiesController < ApplicationController
7
7
  before_action :require_user
8
- before_action :set_current_tab, only: [:index, :show]
9
- before_action :set_view, only: [:index, :show, :redraw]
8
+ before_action :set_current_tab, only: %i[index show]
9
+ before_action :set_view, only: %i[index show redraw]
10
10
 
11
11
  before_action :set_options, only: :index
12
12
  before_action :load_ransack_search, only: :index
@@ -87,7 +87,7 @@ class EntitiesController < ApplicationController
87
87
  render('fields/group') && return
88
88
  end
89
89
  end
90
- render text: ''
90
+ render plain: ''
91
91
  end
92
92
 
93
93
  protected
@@ -121,7 +121,7 @@ class EntitiesController < ApplicationController
121
121
  end
122
122
 
123
123
  def resource_params
124
- params[controller_name.singularize].permit!
124
+ params[controller_name.singularize].permit! if params[controller_name.singularize].present?
125
125
  end
126
126
 
127
127
  private
@@ -4,7 +4,7 @@
4
4
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
6
  class HomeController < ApplicationController
7
- before_action :require_user, except: [:toggle, :timezone]
7
+ before_action :require_user, except: %i[toggle timezone]
8
8
  before_action :set_current_tab, only: :index
9
9
 
10
10
  #----------------------------------------------------------------------------
@@ -50,16 +50,16 @@ class HomeController < ApplicationController
50
50
  else
51
51
  session[params[:id].to_sym] = true
52
52
  end
53
- render nothing: true
53
+ head :ok
54
54
  end
55
55
 
56
56
  # GET /home/timeline AJAX
57
57
  #----------------------------------------------------------------------------
58
58
  def timeline
59
59
  state = params[:state].to_s
60
- if %w(Collapsed Expanded).include?(state)
60
+ if %w[Collapsed Expanded].include?(state)
61
61
  if (model_type = params[:type].to_s).present?
62
- if %w(comment email).include?(model_type)
62
+ if %w[comment email].include?(model_type)
63
63
  model = model_type.camelize.constantize
64
64
  item = model.find(params[:id])
65
65
  item.update_attribute(:state, state)
@@ -71,7 +71,7 @@ class HomeController < ApplicationController
71
71
  end
72
72
  end
73
73
 
74
- render nothing: true
74
+ head :ok
75
75
  end
76
76
 
77
77
  # GET /home/timezone AJAX
@@ -85,7 +85,7 @@ class HomeController < ApplicationController
85
85
  session[:timezone_offset] = params[:offset].to_i * -60
86
86
  ActiveSupport::TimeZone[session[:timezone_offset]]
87
87
  end
88
- render nothing: true
88
+ head :ok
89
89
  end
90
90
 
91
91
  private
@@ -115,7 +115,7 @@ class HomeController < ApplicationController
115
115
  def activity_event
116
116
  event = current_user.pref[:activity_event]
117
117
  if event == "all_events"
118
- %w(create update destroy)
118
+ %w[create update destroy]
119
119
  else
120
120
  event
121
121
  end
@@ -155,8 +155,8 @@ class HomeController < ApplicationController
155
155
  duration = current_user.pref[:activity_duration]
156
156
  if duration
157
157
  words = duration.split("_") # "two_weeks" => 2.weeks
158
- if %w(one two).include?(words.first) && %w(hour day days week weeks month).include?(words.last)
159
- %w(zero one two).index(words.first).send(words.last)
158
+ if %w[one two].include?(words.first) && %w[hour day days week weeks month].include?(words.last)
159
+ %w[zero one two].index(words.first).send(words.last)
160
160
  end
161
161
  end
162
162
  end
@@ -4,7 +4,7 @@
4
4
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
6
  class PasswordsController < ApplicationController
7
- before_action :load_user_using_perishable_token, only: [:edit, :update]
7
+ before_action :load_user_using_perishable_token, only: %i[edit update]
8
8
  before_action :require_no_user
9
9
 
10
10
  #----------------------------------------------------------------------------
@@ -5,7 +5,7 @@
5
5
  #------------------------------------------------------------------------------
6
6
  class TasksController < ApplicationController
7
7
  before_action :require_user
8
- before_action :set_current_tab, only: [:index, :show]
8
+ before_action :set_current_tab, only: %i[index show]
9
9
  before_action :update_sidebar, only: :index
10
10
 
11
11
  # GET /tasks
@@ -170,6 +170,7 @@ class TasksController < ApplicationController
170
170
  protected
171
171
 
172
172
  def task_params
173
+ return {} unless params[:task]
173
174
  params[:task].permit!
174
175
  end
175
176
 
@@ -4,12 +4,12 @@
4
4
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
6
  class UsersController < ApplicationController
7
- before_action :set_current_tab, only: [:show, :opportunities_overview] # Don't hightlight any tabs.
7
+ before_action :set_current_tab, only: %i[show opportunities_overview] # Don't hightlight any tabs.
8
8
 
9
9
  check_authorization
10
10
  load_and_authorize_resource # handles all security
11
11
 
12
- respond_to :html, only: [:show, :new]
12
+ respond_to :html, only: %i[show new]
13
13
 
14
14
  # GET /users/1
15
15
  # GET /users/1.js
@@ -134,6 +134,7 @@ class UsersController < ApplicationController
134
134
  protected
135
135
 
136
136
  def user_params
137
+ return {} unless params[:user]
137
138
  params[:user][:email].try(:strip!)
138
139
  params[:user].permit(
139
140
  :username,
@@ -153,6 +154,7 @@ class UsersController < ApplicationController
153
154
  end
154
155
 
155
156
  def avatar_params
157
+ return {} unless params[:avatar]
156
158
  params[:avatar]
157
159
  .permit(:image)
158
160
  .merge(entity: @user)