fat_free_crm 0.11.1 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fat_free_crm might be problematic. Click here for more details.

Files changed (179) hide show
  1. data/Gemfile +30 -12
  2. data/Gemfile.lock +131 -119
  3. data/Procfile +1 -1
  4. data/README.md +1 -1
  5. data/app/assets/images/notifications.png +0 -0
  6. data/app/assets/javascripts/application.js.erb +3 -0
  7. data/app/assets/javascripts/crm_textarea_autocomplete.js +44 -0
  8. data/app/assets/stylesheets/application.css.erb +2 -0
  9. data/app/assets/stylesheets/common.scss +7 -11
  10. data/app/assets/stylesheets/textarea_autocomplete.scss +42 -0
  11. data/app/controllers/admin/application_controller.rb +5 -5
  12. data/app/controllers/admin/field_groups_controller.rb +11 -51
  13. data/app/controllers/admin/fields_controller.rb +13 -59
  14. data/app/controllers/admin/plugins_controller.rb +1 -4
  15. data/app/controllers/admin/settings_controller.rb +0 -4
  16. data/app/controllers/admin/tags_controller.rb +11 -66
  17. data/app/controllers/admin/users_controller.rb +20 -83
  18. data/app/controllers/application_controller.rb +83 -69
  19. data/app/controllers/comments_controller.rb +12 -29
  20. data/app/controllers/emails_controller.rb +1 -5
  21. data/app/controllers/entities/accounts_controller.rb +13 -32
  22. data/app/controllers/entities/campaigns_controller.rb +17 -32
  23. data/app/controllers/entities/contacts_controller.rb +20 -38
  24. data/app/controllers/entities/leads_controller.rb +33 -55
  25. data/app/controllers/entities/opportunities_controller.rb +26 -42
  26. data/app/controllers/entities_controller.rb +92 -83
  27. data/app/controllers/home_controller.rb +1 -10
  28. data/app/controllers/lists_controller.rb +1 -4
  29. data/app/controllers/{entities/tasks_controller.rb → tasks_controller.rb} +21 -32
  30. data/app/controllers/users_controller.rb +6 -5
  31. data/app/helpers/accounts_helper.rb +32 -9
  32. data/app/helpers/application_helper.rb +15 -1
  33. data/app/helpers/campaigns_helper.rb +1 -1
  34. data/app/helpers/comments_helper.rb +11 -1
  35. data/app/helpers/leads_helper.rb +1 -1
  36. data/app/helpers/opportunities_helper.rb +1 -1
  37. data/app/{models/mailers/notifier.rb → mailers/dropbox_mailer.rb} +5 -16
  38. data/app/mailers/subscription_mailer.rb +37 -0
  39. data/{lib/tasks/dropbox.rake → app/mailers/user_mailer.rb} +11 -13
  40. data/app/models/entities/account.rb +3 -1
  41. data/app/models/entities/campaign.rb +3 -1
  42. data/app/models/entities/contact.rb +3 -1
  43. data/app/models/entities/lead.rb +6 -5
  44. data/app/models/entities/opportunity.rb +3 -1
  45. data/app/models/fields/field.rb +1 -1
  46. data/app/models/polymorphic/comment.rb +34 -0
  47. data/app/models/{entities → polymorphic}/task.rb +16 -3
  48. data/app/models/setting.rb +15 -15
  49. data/app/models/users/ability.rb +12 -5
  50. data/app/models/users/user.rb +7 -2
  51. data/app/views/accounts/index.html.haml +1 -1
  52. data/app/views/accounts/index.js.rjs +1 -1
  53. data/app/views/admin/plugins/index.html.haml +1 -7
  54. data/app/views/{shared/auto_complete.html.haml → application/_auto_complete.html.haml} +0 -0
  55. data/app/views/{shared → application}/index.atom.builder +1 -1
  56. data/app/views/{shared → application}/index.rss.builder +1 -1
  57. data/app/views/campaigns/index.html.haml +1 -1
  58. data/app/views/campaigns/index.js.rjs +1 -1
  59. data/app/views/comments/_new.html.haml +6 -0
  60. data/app/views/comments/_subscription_links.html.haml +13 -0
  61. data/app/views/comments/new.js.rjs +2 -0
  62. data/app/views/contacts/_top_section.html.haml +3 -13
  63. data/app/views/contacts/index.html.haml +1 -1
  64. data/app/views/contacts/index.js.rjs +1 -1
  65. data/app/views/{notifier/dropbox_ack_notification.html.haml → dropbox_mailer/dropbox_notification.html.haml} +2 -2
  66. data/app/views/{shared → entities}/attach.js.rjs +1 -1
  67. data/app/views/entities/contacts.js.rjs +1 -1
  68. data/app/views/{shared/discard.rjs → entities/discard.js.rjs} +0 -0
  69. data/app/views/entities/leads.js.rjs +1 -1
  70. data/app/views/entities/opportunities.js.rjs +1 -1
  71. data/app/views/entities/subscription_update.js.rjs +4 -0
  72. data/app/views/entities/versions.js.rjs +1 -1
  73. data/app/views/layouts/_footer.html.haml +1 -1
  74. data/app/views/layouts/application.html.haml +3 -0
  75. data/app/views/leads/_contact.html.haml +1 -0
  76. data/app/views/leads/index.html.haml +1 -1
  77. data/app/views/leads/index.js.rjs +1 -1
  78. data/app/views/opportunities/_top_section.html.haml +4 -14
  79. data/app/views/opportunities/index.html.haml +1 -1
  80. data/app/views/opportunities/index.js.rjs +1 -1
  81. data/app/views/subscription_mailer/comment_notification.text.erb +7 -0
  82. data/app/views/{notifier → user_mailer}/password_reset_instructions.html.haml +0 -0
  83. data/config/application.rb +3 -1
  84. data/config/environments/development.rb +1 -1
  85. data/config/environments/test.rb +3 -0
  86. data/config/initializers/action_mailer.rb +8 -5
  87. data/config/initializers/cancan.rb +151 -0
  88. data/config/initializers/constants.rb +1 -0
  89. data/config/initializers/locale.rb +20 -0
  90. data/config/initializers/paper_trail.rb +4 -5
  91. data/config/initializers/relative_url_root.rb +0 -1
  92. data/config/initializers/squeel.rb +5 -0
  93. data/config/locales/cz_fat_free_crm.yml +3 -3
  94. data/config/locales/de.yml +2 -2
  95. data/config/locales/de_fat_free_crm.yml +651 -596
  96. data/config/locales/en-GB_fat_free_crm.yml +3 -3
  97. data/config/locales/en-US_fat_free_crm.yml +13 -3
  98. data/config/locales/es_fat_free_crm.yml +3 -3
  99. data/config/locales/fr-CA_fat_free_crm.yml +3 -3
  100. data/config/locales/fr_fat_free_crm.yml +3 -3
  101. data/config/locales/it_fat_free_crm.yml +3 -3
  102. data/config/locales/pl_fat_free_crm.yml +3 -3
  103. data/config/locales/pt-BR_fat_free_crm.yml +3 -3
  104. data/config/locales/ru_fat_free_crm.yml +3 -3
  105. data/config/locales/sv-SE_fat_free_crm.yml +3 -3
  106. data/config/locales/th_fat_free_crm.yml +3 -3
  107. data/config/routes.rb +10 -0
  108. data/config/settings.default.yml +29 -10
  109. data/config/unicorn.rb +4 -0
  110. data/db/migrate/20111201030535_add_field_groups_klass_name.rb +3 -1
  111. data/db/migrate/20120314080441_add_subscribed_users_to_entities.rb +23 -0
  112. data/db/migrate/20120405080727_change_subscribed_users_to_set.rb +24 -0
  113. data/db/migrate/20120405080742_change_further_subscribed_users_to_set.rb +27 -0
  114. data/db/migrate/20120413034923_add_index_on_versions_item_type.rb +5 -0
  115. data/db/schema.rb +109 -126
  116. data/fat_free_crm.gemspec +12 -18
  117. data/lib/fat_free_crm.rb +0 -1
  118. data/lib/fat_free_crm/core_ext/array.rb +1 -0
  119. data/lib/fat_free_crm/gem_dependencies.rb +1 -0
  120. data/lib/fat_free_crm/mail_processor/base.rb +226 -0
  121. data/lib/fat_free_crm/mail_processor/comment_replies.rb +86 -0
  122. data/lib/fat_free_crm/mail_processor/dropbox.rb +288 -0
  123. data/lib/fat_free_crm/permissions.rb +6 -19
  124. data/lib/fat_free_crm/renderers.rb +0 -8
  125. data/lib/fat_free_crm/tabs.rb +1 -1
  126. data/lib/fat_free_crm/version.rb +1 -1
  127. data/lib/plugins/country_select/lib/country_select.rb +2 -2
  128. data/lib/tasks/mail_processing.rake +60 -0
  129. data/spec/controllers/admin/users_controller_spec.rb +0 -2
  130. data/spec/controllers/{accounts_controller_spec.rb → entities/accounts_controller_spec.rb} +7 -9
  131. data/spec/controllers/{campaigns_controller_spec.rb → entities/campaigns_controller_spec.rb} +7 -7
  132. data/spec/controllers/{contacts_controller_spec.rb → entities/contacts_controller_spec.rb} +5 -9
  133. data/spec/controllers/{leads_controller_spec.rb → entities/leads_controller_spec.rb} +7 -9
  134. data/spec/controllers/{opportunities_controller_spec.rb → entities/opportunities_controller_spec.rb} +8 -15
  135. data/spec/controllers/tasks_controller_spec.rb +1 -5
  136. data/spec/controllers/users_controller_spec.rb +5 -9
  137. data/spec/factories/subscription_factories.rb +6 -0
  138. data/spec/lib/mail_processor/base_spec.rb +164 -0
  139. data/spec/lib/mail_processor/comment_replies_spec.rb +63 -0
  140. data/spec/lib/{dropbox_spec.rb → mail_processor/dropbox_spec.rb} +73 -181
  141. data/spec/lib/mail_processor/sample_emails/dropbox.rb +167 -0
  142. data/spec/mailers/subscription_mailer_spec.rb +17 -0
  143. data/spec/models/{base → entities}/account_contact_spec.rb +0 -0
  144. data/spec/models/{base → entities}/account_opportunity_spec.rb +0 -0
  145. data/spec/models/{base → entities}/account_spec.rb +4 -0
  146. data/spec/models/{base → entities}/campaign_spec.rb +4 -0
  147. data/spec/models/{base → entities}/contact_opportunity_spec.rb +0 -0
  148. data/spec/models/{base → entities}/contact_spec.rb +4 -0
  149. data/spec/models/{base → entities}/lead_spec.rb +4 -0
  150. data/spec/models/{base → entities}/opportunity_spec.rb +4 -0
  151. data/spec/models/polymorphic/comment_spec.rb +15 -0
  152. data/spec/models/{base → polymorphic}/task_spec.rb +124 -30
  153. data/spec/models/polymorphic/version_spec.rb +1 -1
  154. data/spec/shared/controllers.rb +5 -7
  155. data/spec/shared/models.rb +46 -0
  156. data/spec/spec_helper.rb +3 -4
  157. data/spec/support/mail_processor_mocks.rb +30 -0
  158. data/spec/support/uploaded_file.rb +3 -0
  159. data/spec/views/{common → application}/auto_complete.haml_spec.rb +1 -1
  160. data/vendor/assets/images/jquery-ui/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  161. data/vendor/assets/images/jquery-ui/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  162. data/vendor/assets/images/jquery-ui/ui-bg_flat_10_000000_40x100.png +0 -0
  163. data/vendor/assets/images/jquery-ui/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  164. data/vendor/assets/images/jquery-ui/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  165. data/vendor/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  166. data/vendor/assets/images/jquery-ui/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  167. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  168. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  169. data/vendor/assets/images/jquery-ui/ui-icons_222222_256x240.png +0 -0
  170. data/vendor/assets/images/jquery-ui/ui-icons_228ef1_256x240.png +0 -0
  171. data/vendor/assets/images/jquery-ui/ui-icons_ef8c08_256x240.png +0 -0
  172. data/vendor/assets/images/jquery-ui/ui-icons_ffd27a_256x240.png +0 -0
  173. data/vendor/assets/images/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
  174. data/vendor/assets/javascripts/textarea_autocomplete.js +605 -0
  175. data/vendor/assets/stylesheets/jquery-ui.custom.css.erb +565 -0
  176. metadata +234 -154
  177. data/config/locales/simple_form.en.yml +0 -24
  178. data/lib/fat_free_crm/dropbox.rb +0 -439
  179. data/spec/lib/dropbox/email_samples.rb +0 -77
data/Procfile CHANGED
@@ -1 +1 @@
1
- web: bundle exec unicorn -p $PORT -c config/unicorn.rb
1
+ web: ./bin/unicorn -p $PORT -c config/unicorn.rb
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Fat Free CRM
2
2
 
3
- [![TravisCI][travis-img]][travis-ci] [![Dependency Status][gemnasium-img]][gemnasium]
3
+ [![TravisCI][travis-img]][travis-ci]
4
4
 
5
5
  [travis-img]: https://secure.travis-ci.org/fatfreecrm/fat_free_crm.png?branch=master
6
6
  [travis-ci]: http://travis-ci.org/fatfreecrm/fat_free_crm
Binary file
@@ -16,6 +16,7 @@
16
16
  //------------------------------------------------------------------------------
17
17
 
18
18
  //= require jquery
19
+ //= require jquery-ui
19
20
  //= require jquery-noconflict
20
21
  //= require prototype
21
22
  //= require effects
@@ -27,6 +28,8 @@
27
28
  //= require crm_classes
28
29
  //= require crm_loginout
29
30
  //= require crm_fields
31
+ //= require textarea_autocomplete
32
+ //= require crm_textarea_autocomplete
30
33
  //= require calendar_date_select/calendar_date_select
31
34
  //= require event.simulate
32
35
  //= require ajax-chosen-prototype
@@ -0,0 +1,44 @@
1
+ // Fat Free CRM
2
+ // Copyright (C) 2008-2011 by Michael Dvorkin
3
+ //
4
+ // This program is free software: you can redistribute it and/or modify
5
+ // it under the terms of the GNU Affero General Public License as published by
6
+ // the Free Software Foundation, either version 3 of the License, or
7
+ // (at your option) any later version.
8
+ //
9
+ // This program is distributed in the hope that it will be useful,
10
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ // GNU Affero General Public License for more details.
13
+ //
14
+ // You should have received a copy of the GNU Affero General Public License
15
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ //------------------------------------------------------------------------------
17
+
18
+ crm.textarea_user_autocomplete = function(el_id) {
19
+ if (! jQuery('#areacomplete_' + el_id)[0]) {
20
+ jQuery('#' + el_id).areacomplete({
21
+ wordCount: 1,
22
+ mode: "outter",
23
+ on: {
24
+ query: function(text,cb) {
25
+ // Only autocomplete if search term starts with '@'
26
+ if (text.indexOf("@") != 0) { return []; }
27
+
28
+ var words = [];
29
+ for( var i=0; i < _ffcrm_users.length; i++ ) {
30
+ var name_query = text.replace("@",'').toLowerCase();
31
+ if (_ffcrm_users[i].toLowerCase().indexOf(name_query) != -1 ) {
32
+ words.push(_ffcrm_users[i]);
33
+ }
34
+ }
35
+ cb(words, text.replace("@",''));
36
+ },
37
+ selected: function(text, data) {
38
+ var username_regEx = new RegExp("\\((@[^)]+)\\)");
39
+ return text.match(username_regEx)[1];
40
+ }
41
+ }
42
+ });
43
+ }
44
+ }
@@ -18,6 +18,7 @@
18
18
  */
19
19
 
20
20
  /*
21
+ *= require jquery-ui.custom
21
22
  *= require modalbox
22
23
  *= require facebooklist
23
24
  *= require rails
@@ -28,6 +29,7 @@
28
29
  *= require chosen
29
30
  *= require ffcrm_chosen
30
31
  *= require fields
32
+ *= require textarea_autocomplete
31
33
  *= require_self
32
34
  */
33
35
 
@@ -335,7 +335,12 @@ $sidebar_width: 210px;
335
335
  padding: 0px;
336
336
  margin: -10px 0px 0px 36px;
337
337
  p {
338
- margin: 10px 0px 0px 0px; } } }
338
+ margin: 10px 0px 0px 0px; } }
339
+ .comment_subscriptions {
340
+ margin-top: 7px;
341
+ margin-left: 4px;
342
+ a {
343
+ font-size: 11px; } } }
339
344
 
340
345
  // Avoid collision with .email CSS class which is used to display Task category strip.
341
346
  .mail {
@@ -435,16 +440,7 @@ $sidebar_width: 210px;
435
440
  dt {
436
441
  color: #3f3f3f;
437
442
  font-size: 11px;
438
- padding: 2px 0px 0px 0px; }
439
- dt a:link, dt a:visited {
440
- color: #3f3f3f;
441
- font-weight: bold;
442
- text-decoration: none; }
443
- dt a:hover {
444
- background: dimgray;
445
- color: white;
446
- font-weight: bold;
447
- text-decoration: none; } } }
443
+ padding: 2px 0px 0px 0px; } } }
448
444
 
449
445
  // Sidebar, filters, and selectors.
450
446
  //------------------------------------------------------------------------------
@@ -0,0 +1,42 @@
1
+ .areacomplete-dropdown {
2
+ ul.auto-list {
3
+ display: none;
4
+ position: absolute;
5
+ top: 0px;
6
+ left: 0px;
7
+ background: white;
8
+ padding: 0;
9
+ margin: 0 4px 4px 0;
10
+ list-style:none;
11
+ overflow-x: hidden;
12
+ overflow-y: auto;
13
+ max-height: 230px;
14
+ border: 1px solid #AAA;
15
+ -webkit-border-radius: 0 0 4px 4px;
16
+ -moz-border-radius: 0 0 4px 4px;
17
+ border-radius: 0 0 4px 4px;
18
+ -moz-background-clip: padding;
19
+ -webkit-background-clip: padding-box;
20
+ background-clip: padding-box;
21
+ font-family: "Lucida Grande", Geneva, Arial, Helvetica, sans-serif;
22
+ }
23
+
24
+ ul.auto-list > li:hover, ul.auto-list > li[data-selected=true] {
25
+ background: #3875D7;
26
+ color: white;
27
+ em{
28
+ background: inherit;
29
+ }
30
+ }
31
+
32
+ ul.auto-list > li {
33
+ line-height: 15px;
34
+ padding: 4px 7px 4px;
35
+ border-bottom: none;
36
+ }
37
+
38
+ em{
39
+ background: #FEFFDE;
40
+ font-style: normal;
41
+ }
42
+ }
@@ -15,10 +15,10 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  #------------------------------------------------------------------------------
17
17
 
18
- class Admin::ApplicationController < EntitiesController
19
- layout "admin/application"
18
+ class Admin::ApplicationController < ApplicationController
20
19
  before_filter :require_admin_user
21
20
 
21
+ layout "admin/application"
22
22
  helper "admin/field_groups"
23
23
 
24
24
  # Autocomplete handler for all admin controllers.
@@ -26,10 +26,11 @@ class Admin::ApplicationController < EntitiesController
26
26
  def auto_complete
27
27
  @query = params[:auto_complete_query]
28
28
  @auto_complete = klass.text_search(@query).limit(10)
29
- render "shared/auto_complete", :layout => nil
29
+ render :partial => 'auto_complete'
30
30
  end
31
31
 
32
- private
32
+ private
33
+
33
34
  #----------------------------------------------------------------------------
34
35
  def require_admin_user
35
36
  require_user
@@ -39,4 +40,3 @@ class Admin::ApplicationController < EntitiesController
39
40
  end
40
41
  end
41
42
  end
42
-
@@ -16,7 +16,6 @@
16
16
  #------------------------------------------------------------------------------
17
17
 
18
18
  class Admin::FieldGroupsController < Admin::ApplicationController
19
- before_filter :require_user
20
19
 
21
20
  # GET /admin/field_groups/new
22
21
  # GET /admin/field_groups/new.xml AJAX
@@ -24,13 +23,7 @@ class Admin::FieldGroupsController < Admin::ApplicationController
24
23
  def new
25
24
  @field_group = FieldGroup.new(:klass_name => params[:klass_name])
26
25
 
27
- respond_to do |format|
28
- format.js # new.js.rjs
29
- format.xml { render :xml => @field_group }
30
- end
31
-
32
- rescue ActiveRecord::RecordNotFound
33
- respond_to_not_found(:html, :xml)
26
+ respond_with(@field_group)
34
27
  end
35
28
 
36
29
  # GET /admin/field_groups/1/edit AJAX
@@ -39,29 +32,19 @@ class Admin::FieldGroupsController < Admin::ApplicationController
39
32
  @field_group = FieldGroup.find(params[:id])
40
33
 
41
34
  if params[:previous].to_s =~ /(\d+)\z/
42
- @previous = FieldGroup.find($1)
35
+ @previous = FieldGroup.find_by_id($1) || $1.to_i
43
36
  end
44
37
 
45
- rescue ActiveRecord::RecordNotFound
46
- @previous ||= $1.to_i
47
- respond_to_not_found(:js)
38
+ respond_with(@field_group)
48
39
  end
49
40
 
50
41
  # POST /admin/field_groups
51
42
  # POST /admin/field_groups.xml AJAX
52
43
  #----------------------------------------------------------------------------
53
44
  def create
54
- @field_group = FieldGroup.new(params[:field_group])
55
-
56
- respond_to do |format|
57
- if @field_group.save
58
- format.js # create.js.rjs
59
- format.xml { render :xml => @field_group, :status => :created, :location => @field_group }
60
- else
61
- format.js # create.js.rjs
62
- format.xml { render :xml => @field_group.errors, :status => :unprocessable_entity }
63
- end
64
- end
45
+ @field_group = FieldGroup.create(params[:field_group])
46
+
47
+ respond_with(@field_group)
65
48
  end
66
49
 
67
50
  # PUT /admin/field_groups/1
@@ -69,19 +52,9 @@ class Admin::FieldGroupsController < Admin::ApplicationController
69
52
  #----------------------------------------------------------------------------
70
53
  def update
71
54
  @field_group = FieldGroup.find(params[:id])
55
+ @field_group.update_attributes(params[:field_group])
72
56
 
73
- respond_to do |format|
74
- if @field_group.update_attributes(params[:field_group])
75
- format.js
76
- format.xml { head :ok }
77
- else
78
- format.js
79
- format.xml { render :xml => @field_group.errors, :status => :unprocessable_entity }
80
- end
81
- end
82
-
83
- rescue ActiveRecord::RecordNotFound
84
- respond_to_not_found(:js, :xml)
57
+ respond_with(@field_group)
85
58
  end
86
59
 
87
60
  # DELETE /admin/field_groups/1
@@ -89,18 +62,9 @@ class Admin::FieldGroupsController < Admin::ApplicationController
89
62
  #----------------------------------------------------------------------------
90
63
  def destroy
91
64
  @field_group = FieldGroup.find(params[:id])
65
+ @field_group.destroy
92
66
 
93
- respond_to do |format|
94
- if @field_group.destroy
95
- # Redirect to fields index
96
- format.js { render(:destroy) { |page| page.redirect_to admin_fields_url } }
97
- format.xml { head :ok }
98
- else
99
- flash[:warning] = t(:msg_cant_delete_field_group, @field_group.name)
100
- format.js # destroy.js.rjs
101
- format.xml { render :xml => @field_group.errors, :status => :unprocessable_entity }
102
- end
103
- end
67
+ respond_with(@field_group)
104
68
  end
105
69
 
106
70
  # POST /admin/field_groups/sort
@@ -115,14 +79,10 @@ class Admin::FieldGroupsController < Admin::ApplicationController
115
79
 
116
80
  render :nothing => true
117
81
  end
118
-
82
+
119
83
  # GET /admin/field_groups/1/confirm AJAX
120
84
  #----------------------------------------------------------------------------
121
85
  def confirm
122
86
  @field_group = FieldGroup.find(params[:id])
123
-
124
- rescue ActiveRecord::RecordNotFound
125
- respond_to_not_found(:js, :xml)
126
87
  end
127
-
128
88
  end
@@ -16,10 +16,9 @@
16
16
  #------------------------------------------------------------------------------
17
17
 
18
18
  class Admin::FieldsController < Admin::ApplicationController
19
- before_filter :require_user
20
- before_filter :set_current_tab, :only => [ :index, :show ]
21
19
  before_filter "set_current_tab('admin/fields')", :only => [ :index ]
22
- before_filter :auto_complete, :only => :auto_complete
20
+
21
+ load_resource
23
22
 
24
23
  # GET /fields
25
24
  # GET /fields.xml HTML
@@ -31,15 +30,7 @@ class Admin::FieldsController < Admin::ApplicationController
31
30
  # GET /fields/1.xml HTML
32
31
  #----------------------------------------------------------------------------
33
32
  def show
34
- @custom_field = Field.find(params[:id])
35
-
36
- respond_to do |format|
37
- format.html # show.html.erb
38
- format.xml { render :xml => @custom_field }
39
- end
40
-
41
- rescue ActiveRecord::RecordNotFound
42
- respond_to_not_found(:html, :xml)
33
+ respond_with(@field)
43
34
  end
44
35
 
45
36
  # GET /fields/new
@@ -48,13 +39,7 @@ class Admin::FieldsController < Admin::ApplicationController
48
39
  def new
49
40
  @field = CustomField.new(:field_group_id => params[:field_group_id])
50
41
 
51
- respond_to do |format|
52
- format.js # new.js.rjs
53
- format.xml { render :xml => @field }
54
- end
55
-
56
- rescue ActiveRecord::RecordNotFound # Kicks in if related asset was not found.
57
- respond_to_not_found(:html, :xml)
42
+ respond_with(@custom_field)
58
43
  end
59
44
 
60
45
  # GET /fields/1/edit AJAX
@@ -63,29 +48,19 @@ class Admin::FieldsController < Admin::ApplicationController
63
48
  @field = Field.find(params[:id])
64
49
 
65
50
  if params[:previous].to_s =~ /(\d+)\z/
66
- @previous = Field.find($1)
51
+ @previous = Field.find_by_id($1) || $1.to_i
67
52
  end
68
53
 
69
- rescue ActiveRecord::RecordNotFound
70
- @previous ||= $1.to_i
71
- respond_to_not_found(:js)
54
+ respond_with(@field)
72
55
  end
73
56
 
74
57
  # POST /fields
75
58
  # POST /fields.xml AJAX
76
59
  #----------------------------------------------------------------------------
77
60
  def create
78
- @field = CustomField.new(params[:field])
79
-
80
- respond_to do |format|
81
- if @field.save
82
- format.js # create.js.rjs
83
- format.xml { render :xml => @field, :status => :created, :location => @field }
84
- else
85
- format.js # create.js.rjs
86
- format.xml { render :xml => @field.errors, :status => :unprocessable_entity }
87
- end
88
- end
61
+ @field = CustomField.create(params[:field])
62
+
63
+ respond_with(@field)
89
64
  end
90
65
 
91
66
  # PUT /fields/1
@@ -93,19 +68,9 @@ class Admin::FieldsController < Admin::ApplicationController
93
68
  #----------------------------------------------------------------------------
94
69
  def update
95
70
  @field = Field.find(params[:id])
71
+ @field.update_attributes(params[:field])
96
72
 
97
- respond_to do |format|
98
- if @field.update_attributes(params[:field])
99
- format.js
100
- format.xml { head :ok }
101
- else
102
- format.js
103
- format.xml { render :xml => @field.errors, :status => :unprocessable_entity }
104
- end
105
- end
106
-
107
- rescue ActiveRecord::RecordNotFound
108
- respond_to_not_found(:js, :xml)
73
+ respond_with(@field)
109
74
  end
110
75
 
111
76
  # DELETE /fields/1
@@ -113,19 +78,9 @@ class Admin::FieldsController < Admin::ApplicationController
113
78
  #----------------------------------------------------------------------------
114
79
  def destroy
115
80
  @field = CustomField.find(params[:id])
81
+ @field.destroy
116
82
 
117
- respond_to do |format|
118
- if @field.destroy
119
- format.js # destroy.js.rjs
120
- format.xml { head :ok }
121
- else
122
- format.js # destroy.js.rjs
123
- format.xml { render :xml => @field.errors, :status => :unprocessable_entity }
124
- end
125
- end
126
-
127
- rescue ActiveRecord::RecordNotFound
128
- respond_to_not_found(:html, :js, :xml)
83
+ respond_with(@field)
129
84
  end
130
85
 
131
86
  # POST /fields/sort
@@ -145,4 +100,3 @@ class Admin::FieldsController < Admin::ApplicationController
145
100
  #----------------------------------------------------------------------------
146
101
  # Handled by before_filter :auto_complete, :only => :auto_complete
147
102
  end
148
-
@@ -24,10 +24,7 @@ class Admin::PluginsController < Admin::ApplicationController
24
24
  def index
25
25
  @plugins = FatFreeCRM::Plugin.list
26
26
 
27
- respond_to do |format|
28
- format.html # index.html.haml
29
- format.xml { render :xml => nil }
30
- end
27
+ respond_with(@plugins)
31
28
  end
32
29
  end
33
30