knitkit 3.0.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/{public → app/assets}/images/check.png +0 -0
  3. data/{public → app/assets}/images/credit_card.png +0 -0
  4. data/{public → app/assets}/images/inline_edit/close.png +0 -0
  5. data/{public → app/assets}/images/knitkit/icons/document.png +0 -0
  6. data/{public → app/assets}/images/knitkit/icons/multi_doc.png +0 -0
  7. data/{public → app/assets}/images/knitkit/logo.png +0 -0
  8. data/{public → app/assets}/images/knitkit/splash/images/add-site.png +0 -0
  9. data/app/assets/images/knitkit/splash/images/add_website_105x105-active.png +0 -0
  10. data/app/assets/images/knitkit/splash/images/add_website_105x105.png +0 -0
  11. data/{public → app/assets}/images/knitkit/splash/images/adjust-site.png +0 -0
  12. data/{public → app/assets}/images/knitkit/splash/images/browse-site.png +0 -0
  13. data/app/assets/images/knitkit/splash/images/browse_db_105x105-active.png +0 -0
  14. data/app/assets/images/knitkit/splash/images/browse_db_105x105.png +0 -0
  15. data/app/assets/images/knitkit/splash/images/console_105x105-active.png +0 -0
  16. data/app/assets/images/knitkit/splash/images/console_105x105.png +0 -0
  17. data/{public → app/assets}/images/knitkit/splash/images/find-themes.png +0 -0
  18. data/app/assets/images/knitkit/splash/images/find_themes_105x105-active.png +0 -0
  19. data/app/assets/images/knitkit/splash/images/find_themes_105x105.png +0 -0
  20. data/app/assets/images/knitkit/splash/images/learn_more_105x105-active.png +0 -0
  21. data/app/assets/images/knitkit/splash/images/learn_more_105x105.png +0 -0
  22. data/{public → app/assets}/images/knitkit/splash/images/settings.png +0 -0
  23. data/{public → app/assets}/images/knitkit/splash/images/tutorials.png +0 -0
  24. data/app/assets/images/knitkit/splash/splash.png +0 -0
  25. data/app/assets/images/widgets/manage_profile/contact_information.png +0 -0
  26. data/app/assets/images/widgets/manage_profile/password.png +0 -0
  27. data/app/assets/images/widgets/manage_profile/user_information.png +0 -0
  28. data/app/assets/javascripts/erp_app/desktop/applications/knitkit/app.js +24 -0
  29. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +15 -12
  30. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/center_region.js +69 -48
  31. data/app/assets/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +214 -0
  32. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/east_region.js +0 -0
  33. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/file_assets_panel.js +17 -19
  34. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_data_view.js +13 -3
  35. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_panel.js +59 -48
  36. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/widgets_panel.js +0 -0
  37. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +2 -2
  38. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/module.js +2 -2
  39. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +0 -0
  40. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +1 -1
  41. data/app/assets/javascripts/erp_app/desktop/applications/knitkit/splash_screen.js +268 -0
  42. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/top_menu/main_menu.js +85 -33
  43. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/top_menu/websites_combo.js +0 -0
  44. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +5 -28
  45. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/article.js +22 -8
  46. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/document.js +143 -25
  47. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/host.js +5 -1
  48. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js +2 -0
  49. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/section.js +181 -65
  50. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website_nav_items.js +0 -0
  51. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/hosts_tree_panel.js +0 -0
  52. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/menu_tree_panel.js +0 -0
  53. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/site_contents_tree_panel.js +121 -116
  54. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/themes_tree_panel.js +101 -10
  55. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/west_region.js +9 -5
  56. data/app/assets/javascripts/knitkit-web.js +22 -0
  57. data/app/assets/javascripts/knitkit/additional-methods.min.js +4 -0
  58. data/app/assets/javascripts/knitkit/bootstrap.min.js +7 -0
  59. data/app/assets/javascripts/knitkit/captcha.js +154 -0
  60. data/{public → app/assets}/javascripts/knitkit/confirm-bootstrap.js +1 -1
  61. data/{public → app/assets}/javascripts/knitkit/inline_editing.js +1 -1
  62. data/{public → app/assets}/javascripts/knitkit/jquery.maskedinput.min.js +0 -0
  63. data/app/assets/javascripts/knitkit/jquery.validate.min.js +4 -0
  64. data/app/assets/javascripts/knitkit/js.cookie.js +145 -0
  65. data/{public → app/assets}/javascripts/knitkit/theme.js +0 -0
  66. data/app/assets/stylesheets/erp_app/desktop/applications/knitkit/app.css +12 -0
  67. data/{public → app/assets}/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +23 -33
  68. data/app/assets/stylesheets/erp_app/shared/knitkit_shared.css +21 -0
  69. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.eot +0 -0
  70. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.svg +288 -0
  71. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.ttf +0 -0
  72. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.woff +0 -0
  73. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.woff2 +0 -0
  74. data/app/assets/stylesheets/knitkit-web.css +16 -0
  75. data/app/assets/stylesheets/knitkit/bootstrap.min.css +5 -0
  76. data/app/assets/stylesheets/knitkit/captcha.css +59 -0
  77. data/app/assets/stylesheets/knitkit/custom.css +144 -0
  78. data/{public → app/assets}/stylesheets/knitkit/inline_editing.css +0 -0
  79. data/app/assets/stylesheets/knitkit/submenu.css +93 -0
  80. data/app/controllers/api/v1/websites_controller.rb +14 -0
  81. data/app/controllers/captcha_controller.rb +53 -0
  82. data/app/controllers/knitkit/base_controller.rb +1 -5
  83. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +2 -9
  84. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +20 -7
  85. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +38 -28
  86. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +16 -9
  87. data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +69 -15
  88. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +45 -58
  89. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +64 -29
  90. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +36 -13
  91. data/app/controllers/knitkit/erp_app/desktop/website_host_controller.rb +12 -0
  92. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +4 -11
  93. data/app/controllers/knitkit/erp_app/desktop/website_nav_item_controller.rb +2 -9
  94. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +56 -20
  95. data/app/controllers/knitkit/online_document_sections_controller.rb +9 -3
  96. data/app/mailers/website_inquiry_mailer.rb +11 -3
  97. data/app/models/content.rb +16 -6
  98. data/app/models/documented_item.rb +12 -1
  99. data/app/models/online_document_section.rb +54 -20
  100. data/app/models/published_website.rb +16 -0
  101. data/app/models/theme.rb +53 -47
  102. data/app/models/website.rb +172 -191
  103. data/app/models/website_section.rb +64 -30
  104. data/app/views/knitkit/blogs/show.html.erb +5 -2
  105. data/app/views/layouts/knitkit/base.html.erb +54 -51
  106. data/app/views/menus/knitkit/_default_menu.html.erb +11 -11
  107. data/app/views/menus/knitkit/_default_section_menu.html.erb +2 -2
  108. data/app/views/menus/knitkit/_default_sub_menu.erb +27 -0
  109. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +30 -0
  110. data/app/views/website_inquiry_mailer/inquiry.html.erb +266 -0
  111. data/app/widgets/contact_us/base.rb +26 -16
  112. data/app/widgets/contact_us/javascript/contact_us.js +1 -1
  113. data/app/widgets/contact_us/views/error.html.erb +7 -3
  114. data/app/widgets/contact_us/views/index.html.erb +36 -28
  115. data/app/widgets/google_map/javascript/google_map.js +1 -1
  116. data/app/widgets/google_map/views/index.html.erb +1 -1
  117. data/app/widgets/login/javascript/login.js +1 -1
  118. data/app/widgets/login/views/index.html.erb +1 -1
  119. data/app/widgets/manage_profile/base.rb +141 -112
  120. data/app/widgets/manage_profile/javascript/manage_profile.js +2 -2
  121. data/app/widgets/manage_profile/views/_password_form.html.erb +1 -1
  122. data/app/widgets/manage_profile/views/_user_information_form.html.erb +1 -30
  123. data/app/widgets/manage_profile/views/index.html.erb +42 -40
  124. data/app/widgets/reset_password/base.rb +39 -8
  125. data/app/widgets/reset_password/javascript/reset_password.js +1 -1
  126. data/app/widgets/reset_password/views/index.html.erb +3 -3
  127. data/app/widgets/reset_password/views/invalid_reset_token.html.erb +7 -0
  128. data/app/widgets/reset_password/views/layouts/base.html.erb +1 -1
  129. data/app/widgets/reset_password/views/reset_password.html.erb +39 -0
  130. data/app/widgets/reset_password/views/reset_success.html.erb +5 -0
  131. data/app/widgets/search/base.rb +5 -5
  132. data/app/widgets/search/javascript/search.js +6 -6
  133. data/app/widgets/search/views/_inline_search_form.html.erb +23 -12
  134. data/app/widgets/search/views/_search_form.html.erb +34 -30
  135. data/app/widgets/search/views/layouts/base.html.erb +6 -1
  136. data/app/widgets/signup/base.rb +73 -30
  137. data/app/widgets/signup/javascript/signup.js +1 -1
  138. data/app/widgets/signup/views/_signup_form.html.erb +2 -1
  139. data/app/widgets/signup/views/layouts/base.html.erb +1 -1
  140. data/app/widgets/signup/views/success.html.erb +2 -3
  141. data/config/routes.rb +25 -4
  142. data/db/data_migrations/20110509223702_add_publisher_role.rb +0 -2
  143. data/db/data_migrations/20110816153456_add_knitkit_application.rb +7 -15
  144. data/db/data_migrations/20120127150505_create_website_default_configuration.rb +63 -3
  145. data/db/data_migrations/20150118180450_add_website_member_roles.rb +12 -0
  146. data/db/data_migrations/20150414150359_nest_knitkit_security_roles.rb +35 -0
  147. data/db/data_migrations/20150414173437_move_website_roles_under_website_builder.rb +19 -0
  148. data/db/migrate/20110211002317_setup_knitkit.rb +86 -39
  149. data/lib/knitkit.rb +8 -2
  150. data/lib/knitkit/config.rb +2 -3
  151. data/lib/knitkit/engine.rb +35 -4
  152. data/lib/knitkit/extensions.rb +2 -1
  153. data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +1 -1
  154. data/lib/knitkit/extensions/action_mailer/theme_support/acts_as_themed_mailer.rb +1 -1
  155. data/lib/knitkit/extensions/compass_ae/mailers/user_mailer.rb +31 -0
  156. data/lib/knitkit/extensions/compass_ae/widgets/base.rb +1 -1
  157. data/lib/knitkit/extensions/railties/action_controller/captcha_helper.rb +43 -0
  158. data/lib/knitkit/extensions/railties/action_view/helpers/content_helper.rb +1 -1
  159. data/lib/knitkit/extensions/railties/action_view/helpers/menu_helper.rb +11 -1
  160. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +83 -0
  161. data/lib/knitkit/routing_filter/section_router.rb +24 -14
  162. data/lib/knitkit/version.rb +1 -1
  163. data/lib/tasks/knitkit_tasks.rake +89 -4
  164. data/lib/tasks/theme_parser.rake +85 -0
  165. data/public/fonts/glyphicons-halflings-regular.eot +0 -0
  166. data/public/fonts/glyphicons-halflings-regular.svg +288 -0
  167. data/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  168. data/public/fonts/glyphicons-halflings-regular.woff +0 -0
  169. data/public/fonts/glyphicons-halflings-regular.woff2 +0 -0
  170. data/public/paypal-button.min.js +7 -0
  171. metadata +161 -82
  172. data/app/assets/javascripts/knitkit/application.js +0 -9
  173. data/app/assets/stylesheets/knitkit/application.css +0 -7
  174. data/app/mailers/document_mailer.rb +0 -10
  175. data/app/views/document_mailer/email_document.html.erb +0 -12
  176. data/app/views/knitkit/mobile/index.html.erb +0 -162
  177. data/app/views/knitkit/online_document_sections/index.html.erb +0 -279
  178. data/app/views/layouts/knitkit/online_document_sections.html.erb +0 -80
  179. data/app/views/website_inquiry_mailer/inquiry.erb +0 -24
  180. data/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.rb +0 -33
  181. data/db/data_migrations/20120316150424_add_is_template_to_default_website_config.rb +0 -16
  182. data/db/data_migrations/20120809020508_update_website_and_configuration.rb +0 -82
  183. data/db/data_migrations/20121129185611_upgrade_website_role_iid.rb +0 -20
  184. data/db/migrate/20130405184234_add_use_markdown_to_section.rb +0 -19
  185. data/db/migrate/20131112013052_add_knitkit_missing_indexes.rb +0 -33
  186. data/db/migrate/20140622212723_update_website_inquiries.rb +0 -22
  187. data/db/migrate/20140911185022_add_publishing_to_website.rb +0 -5
  188. data/db/migrate/20141013073349_add_custom_fields_to_documents.rb +0 -12
  189. data/db/migrate/20141016101936_upgrade_remove_dynamic_attributes.rb +0 -13
  190. data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +0 -49
  191. data/public/images/knitkit/close_window.png +0 -0
  192. data/public/images/knitkit/splash/splash.png +0 -0
  193. data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +0 -215
  194. data/public/javascripts/erp_app/desktop/applications/knitkit/select_roles_window.js +0 -108
  195. data/public/javascripts/erp_app/desktop/applications/knitkit/splash_screen.js +0 -170
  196. data/public/javascripts/knitkit/bootstrap-datepicker.js +0 -474
  197. data/public/javascripts/knitkit/bootstrap.min.js +0 -7
  198. data/public/javascripts/knitkit/mobile/app/view/Main.js +0 -108
  199. data/public/javascripts/knitkit/mobile/ux/slidenavigation/View.js +0 -734
  200. data/public/stylesheets/knitkit/bootstrap-responsive.min.css +0 -10
  201. data/public/stylesheets/knitkit/bootstrap.min.css +0 -7
  202. data/public/stylesheets/knitkit/custom.css +0 -122
  203. data/public/stylesheets/knitkit/datepicker.css +0 -182
@@ -1,31 +1,41 @@
1
1
  module Widgets
2
2
  module ContactUs
3
3
  class Base < ErpApp::Widgets::Base
4
+
4
5
  include ActionView::Helpers::SanitizeHelper
6
+ include Knitkit::Extensions::Railties::ActionController::CaptchaHelper
5
7
 
6
8
  def index
7
9
  render
8
10
  end
9
11
 
10
12
  def new
11
- website = Website.find_by_host(request.host_with_port)
12
-
13
- website_inquiry = WebsiteInquiry.new
14
- website_inquiry.created_by = current_user unless current_user.nil?
15
- website_inquiry.website = website
16
- website_inquiry.first_name = params[:first_name].strip
17
- website_inquiry.last_name = params[:last_name].strip
18
- website_inquiry.message = params[:message].strip
19
- website_inquiry.email = params[:email].strip
20
-
21
- if website_inquiry.save
22
- if website.email_inquiries?
23
- WebsiteInquiryMailer.inquiry(website_inquiry).deliver
24
- end
25
- render :update => {:id => "#{@uuid}_result", :view => :success}
13
+ if captcha_valid?
14
+
15
+ website = Website.find_by_host(request.host_with_port)
16
+
17
+ website_inquiry = WebsiteInquiry.new
18
+ website_inquiry.created_by = current_user unless current_user.nil?
19
+ website_inquiry.website = website
20
+ website_inquiry.first_name = params[:first_name].strip
21
+ website_inquiry.last_name = params[:last_name].strip
22
+ website_inquiry.message = params[:message].strip
23
+ website_inquiry.email = params[:email].strip
24
+
25
+ if website_inquiry.save
26
+ if website.email_inquiries?
27
+ WebsiteInquiryMailer.inquiry(website_inquiry, website.dba_organization).deliver
28
+ end
29
+ render :update => {:id => "container", :view => :success}
26
30
 
31
+ else
32
+ @errors = website_inquiry.errors.full_messages
33
+ render :update => {:id => "#{@uuid}_result", :view => :error}
34
+
35
+ end
27
36
  else
28
- @errors = @website_inquiry.errors.full_messages
37
+ @errors = ['Captcha Invalid']
38
+
29
39
  render :update => {:id => "#{@uuid}_result", :view => :error}
30
40
 
31
41
  end
@@ -8,7 +8,7 @@ Compass.ErpApp.Widgets.ContactUs = {
8
8
 
9
9
  Compass.ErpApp.Widgets.AvailableWidgets.push({
10
10
  name: 'Contact Us',
11
- iconUrl: '/images/icons/mail/mail_48x48.png',
11
+ iconUrl: '/assets/icons/mail/mail_48x48.png',
12
12
  onClick: Compass.ErpApp.Widgets.ContactUs.addContactUs,
13
13
  about: 'This widget creates a form to allow for website inquiries.'
14
14
  });
@@ -1,8 +1,12 @@
1
1
  <div class="alert alert-danger">
2
2
  <strong>An Error Occurred</strong>
3
3
  <ul>
4
- <% @errors.each do |k, v| %>
5
- <li><%= v %></li>
4
+ <% @errors.each do |error| %>
5
+ <li><%= error %></li>
6
6
  <% end %>
7
7
  </ul>
8
- </div>
8
+ </div>
9
+
10
+ <script type="text/javascript">
11
+ Captcha.refresh();
12
+ </script>
@@ -1,28 +1,36 @@
1
- <div id="<%= widget_result_id %>"></div>
2
-
3
- <%= form_remote_tag build_widget_url(:new) do %>
4
- <div class="form-group">
5
- <%= label_tag :first_name %>
6
- <%= text_field_tag "first_name", nil, :class => "form-control", :required => true %>
7
- </div>
8
-
9
- <div class="form-group">
10
- <%= label_tag :last_name %>
11
- <%= text_field_tag "last_name", nil, :class => "form-control", :required => true %>
12
- </div>
13
-
14
- <div class="form-group">
15
- <%= label_tag :email %>
16
- <%= text_field_tag "email", nil, :class => "form-control", :required => true %>
17
- </div>
18
-
19
- <div class="form-group">
20
- <%= label_tag :message %>
21
- <%= text_area_tag "message", nil, :class => "form-control", :rows => 5, :required => true %>
22
- </div>
23
-
24
- <p class="text-center">
25
- <%= submit_tag "Submit", :disable_with => "Please wait...", :class => "btn btn-primary submit", :style => '' %>
26
- </p>
27
-
28
- <% end %>
1
+ <div id="container">
2
+ <div id="<%= widget_result_id %>"></div>
3
+
4
+ <%= form_remote_tag build_widget_url(:new) do %>
5
+ <div class="form-group">
6
+ <%= label_tag :first_name %>
7
+ <%= text_field_tag "first_name", nil, :class => "form-control", :required => true %>
8
+ </div>
9
+
10
+ <div class="form-group">
11
+ <%= label_tag :last_name %>
12
+ <%= text_field_tag "last_name", nil, :class => "form-control", :required => true %>
13
+ </div>
14
+
15
+ <div class="form-group">
16
+ <%= label_tag :email %>
17
+ <%= text_field_tag "email", nil, :class => "form-control", :required => true %>
18
+ </div>
19
+
20
+ <div class="form-group">
21
+ <%= label_tag :message %>
22
+ <%= text_area_tag "message", nil, :class => "form-control", :rows => 5, :required => true %>
23
+ </div>
24
+
25
+ <div id="captcha"></div>
26
+
27
+ <p class="text-center">
28
+ <%= submit_tag "Submit", :disable_with => "Please wait...", :class => "btn btn-primary submit", :style => '' %>
29
+ </p>
30
+
31
+ <% end %>
32
+
33
+ <script type="text/javascript">
34
+ Captcha.setup('captcha');
35
+ </script>
36
+ </div>
@@ -182,7 +182,7 @@ Compass.ErpApp.Widgets.GoogleMap = {
182
182
 
183
183
  Compass.ErpApp.Widgets.AvailableWidgets.push({
184
184
  name: 'Google Map',
185
- iconUrl: '/images/icons/map/map_48x48.png',
185
+ iconUrl: '/assets/icons/map/map_48x48.png',
186
186
  onClick: Compass.ErpApp.Widgets.GoogleMap.addGoogleMap,
187
187
  about: 'This widget creates a google map with drop points you setup.'
188
188
  });
@@ -1,4 +1,4 @@
1
- <div id='<%= @uuid %>' style='width:<%=@map_width%>px;height:<%=@map_height%>px;border:solid 1px black;'></div>
1
+ <div id='<%= @uuid %>' style='width: 100%;height:<%=@map_height%>px;border:solid 1px black;'></div>
2
2
  <script type='text/javascript'>
3
3
  //we do not want to load google libraries more than once.
4
4
  window.loadMap_<%=@uuid%> = function () {
@@ -161,7 +161,7 @@ Compass.ErpApp.Widgets.Login = {
161
161
 
162
162
  Compass.ErpApp.Widgets.AvailableWidgets.push({
163
163
  name: 'Login',
164
- iconUrl: '/images/icons/login/login_48x48.png',
164
+ iconUrl: '/assets/icons/login/login_48x48.png',
165
165
  onClick: Compass.ErpApp.Widgets.Login.addLogin,
166
166
  about: 'This widget creates a login form to allow users to log into the website.'
167
167
  });
@@ -1,4 +1,4 @@
1
- <div style="width:500px;" id="<%= widget_result_id %>">
1
+ <div id="<%= widget_result_id %>">
2
2
  <% if @message %>
3
3
  <div class="alert alert-info">
4
4
  <button type="button" class="close" data-dismiss="alert">&times;</button>
@@ -41,8 +41,6 @@ module Widgets
41
41
  @individual.current_first_name = params[:first_name]
42
42
  @individual.current_last_name = params[:last_name]
43
43
  @individual.current_middle_name = params[:middle_name]
44
- @individual.gender = params[:gender]
45
- @individual.birth_date = Date.strptime(params[:birth_date], '%m/%d/%Y')
46
44
  @user.email = params[:email]
47
45
 
48
46
  #### check validation then save and render message ####
@@ -65,159 +63,189 @@ module Widgets
65
63
 
66
64
  end
67
65
 
68
-
69
66
  def update_password
70
- if @user = User.authenticate(current_user.username, params[:old_password])
67
+ ActiveRecord::Base.connection.transaction do
68
+ begin
69
+ if @user = User.authenticate(current_user.username, params[:old_password])
70
+
71
+ if !params[:new_password].blank? && !params[:password_confirmation].blank? && params[:new_password] == params[:password_confirmation]
72
+
73
+ @user.password_confirmation= params[:password_confirmation]
74
+
75
+ if @user.change_password!(params[:new_password])
76
+ @message = "Password Updated"
71
77
 
72
- if !params[:new_password].blank? && !params[:password_confirmation].blank? && params[:new_password] == params[:password_confirmation]
78
+ render :update => {:id => "#{@uuid}_result", :view => :success}
79
+ else
80
+ @message = "Error Updating Password"
73
81
 
74
- @user.password_confirmation= params[:password_confirmation]
82
+ #### validation failed ####
83
+ render :update => {:id => "#{@uuid}_result", :view => :error}
84
+ end
75
85
 
76
- if @user.change_password!(params[:new_password])
77
- @message = "Password Updated"
86
+ else
87
+ #### password and password confirmation cant be blank or unequal ####
88
+ @message = "Password Confirmation Must Match Password"
78
89
 
79
- render :update => {:id => "#{@uuid}_result", :view => :success}
90
+ render :update => {:id => "#{@uuid}_result", :view => :error}
91
+ end
80
92
  else
81
- @message = "Error Updating Password"
93
+ #### old password wrong ####
94
+ @message = "Invalid Old Password"
82
95
 
83
- #### validation failed ####
84
96
  render :update => {:id => "#{@uuid}_result", :view => :error}
85
97
  end
98
+ rescue => ex
99
+ Rails.logger.error ex.message
100
+ Rails.logger.error ex.backtrace.join("\n")
86
101
 
87
- else
88
- #### password and password confirmation cant be blank or unequal ####
89
- @message = "Password Confirmation Must Match Password"
102
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
103
+
104
+ @message = 'Could not update password'
90
105
 
91
106
  render :update => {:id => "#{@uuid}_result", :view => :error}
92
107
  end
93
- else
94
- #### old password wrong ####
95
- @message = "Invalid Old Password"
96
-
97
- render :update => {:id => "#{@uuid}_result", :view => :error}
98
108
  end
99
109
 
100
110
  end
101
111
 
102
112
  def add_email_address
103
- begin
104
- email_address = params[:email_address].strip
105
- contact_purpose = params[:contact_purpose]
106
-
107
- email = current_user.party.add_contact(EmailAddress,
108
- {email_address: email_address},
109
- ContactPurpose.find_by_internal_identifier(contact_purpose))
110
-
111
- {:json => {success: true, message: 'Email added', email: email.to_hash(:only => [:id, :email_address],
112
- :contact_purpose => email.contact_purpose.description)}}
113
- rescue => ex
114
- Rails.logger.error ex.message
115
- Rails.logger.error ex.backtrace.join("\n")
116
- #TODO send out notification
117
-
118
- {:json => {success: false, message: 'Could not add email'}}
113
+ ActiveRecord::Base.connection.transaction do
114
+ begin
115
+ email_address = params[:email_address].strip
116
+ contact_purpose = params[:contact_purpose]
117
+
118
+ email = current_user.party.add_contact(EmailAddress,
119
+ {email_address: email_address},
120
+ ContactPurpose.find_by_internal_identifier(contact_purpose))
121
+
122
+ {:json => {success: true, message: 'Email added', email: email.to_hash(:only => [:id, :email_address],
123
+ :contact_purpose => ContactPurpose.find_by_internal_identifier(contact_purpose).description)}}
124
+ rescue => ex
125
+ Rails.logger.error ex.message
126
+ Rails.logger.error ex.backtrace.join("\n")
127
+
128
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
129
+
130
+ {:json => {success: false, message: 'Could not add email'}}
131
+ end
119
132
  end
120
133
  end
121
134
 
122
135
  def remove_email_address
123
- begin
124
- email_address_id = params[:email_address_id].strip
136
+ ActiveRecord::Base.connection.transaction do
137
+ begin
138
+ email_address_id = params[:email_address_id].strip
139
+
140
+ EmailAddress.find(email_address_id).destroy
125
141
 
126
- EmailAddress.find(email_address_id).destroy
142
+ {:json => {success: true, message: 'Email removed'}}
143
+ rescue => ex
144
+ Rails.logger.error ex.message
145
+ Rails.logger.error ex.backtrace.join("\n")
127
146
 
128
- {:json => {success: true, message: 'Email removed'}}
129
- rescue => ex
130
- Rails.logger.error ex.message
131
- Rails.logger.error ex.backtrace.join("\n")
132
- #TODO send out notification
147
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
133
148
 
134
- {:json => {success: false, message: 'Could not remove email'}}
149
+ {:json => {success: false, message: 'Could not remove email'}}
150
+ end
135
151
  end
136
152
  end
137
153
 
138
154
  def add_phone_number
139
- begin
140
- phone_number = params[:phone_number].strip
141
- contact_purpose = params[:contact_purpose]
142
-
143
- phone_number = current_user.party.add_contact(PhoneNumber,
144
- {phone_number: phone_number},
145
- ContactPurpose.find_by_internal_identifier(contact_purpose))
146
-
147
- {:json => {success: true, message: 'Phone number added', phone: phone_number.to_hash(:only => [:id, :phone_number],
148
- :contact_purpose => phone_number.contact_purpose.description)}}
149
- rescue => ex
150
- Rails.logger.error ex.message
151
- Rails.logger.error ex.backtrace.join("\n")
152
- #TODO send out notification
153
-
154
- {:json => {success: false, message: 'Could not add phone number'}}
155
+ ActiveRecord::Base.connection.transaction do
156
+ begin
157
+ phone_number = params[:phone_number].strip
158
+ contact_purpose = params[:contact_purpose]
159
+
160
+ phone_number = current_user.party.add_contact(PhoneNumber,
161
+ {phone_number: phone_number},
162
+ ContactPurpose.find_by_internal_identifier(contact_purpose))
163
+
164
+ {:json => {success: true, message: 'Phone number added', phone: phone_number.to_hash(:only => [:id, :phone_number],
165
+ :contact_purpose => ContactPurpose.find_by_internal_identifier(contact_purpose).description)}}
166
+ rescue => ex
167
+ Rails.logger.error ex.message
168
+ Rails.logger.error ex.backtrace.join("\n")
169
+
170
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
171
+
172
+ {:json => {success: false, message: 'Could not add phone number'}}
173
+ end
155
174
  end
156
175
  end
157
176
 
158
177
  def remove_phone_number
159
- begin
160
- phone_number_id = params[:phone_number_id].strip
178
+ ActiveRecord::Base.connection.transaction do
179
+ begin
180
+ phone_number_id = params[:phone_number_id].strip
161
181
 
162
- PhoneNumber.find(phone_number_id).destroy
182
+ PhoneNumber.find(phone_number_id).destroy
163
183
 
164
- {:json => {success: true, message: 'Phone number removed'}}
165
- rescue => ex
166
- Rails.logger.error ex.message
167
- Rails.logger.error ex.backtrace.join("\n")
168
- #TODO send out notification
184
+ {:json => {success: true, message: 'Phone number removed'}}
185
+ rescue => ex
186
+ Rails.logger.error ex.message
187
+ Rails.logger.error ex.backtrace.join("\n")
169
188
 
170
- {:json => {success: false, message: 'Could not remove phone number'}}
189
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
190
+
191
+ {:json => {success: false, message: 'Could not remove phone number'}}
192
+ end
171
193
  end
172
194
  end
173
195
 
174
196
  def add_address
175
- begin
176
- address_line_1 = params[:address_line_1].strip
177
- address_line_2 = params[:address_line_2].strip
178
- city = params[:city].strip
179
- geo_zone_id = params[:state].strip
180
- postal_code = params[:postal_code].strip
181
- contact_purpose = params[:contact_purpose]
182
-
183
- postal_address = current_user.party.add_contact(PostalAddress,
184
- {
185
- address_line_1: address_line_1,
186
- address_line_2: address_line_2,
187
- city: city,
188
- geo_zone_id: geo_zone_id,
189
- state: GeoZone.find(geo_zone_id).zone_name,
190
- zip: postal_code,
191
- },
192
- ContactPurpose.find_by_internal_identifier(contact_purpose))
193
-
194
- {:json => {success: true,
195
- message: 'Address added',
196
- address: postal_address.to_hash(:only => [:id, :address_line_1, :address_line_2,
197
- :city, :state, :zip],
198
- :contact_purpose => postal_address.contact_purpose.description)}}
199
- rescue => ex
200
- Rails.logger.error ex.message
201
- Rails.logger.error ex.backtrace.join("\n")
202
- #TODO send out notification
203
-
204
- {:json => {success: false, message: 'Could not add address'}}
197
+ ActiveRecord::Base.connection.transaction do
198
+ begin
199
+ address_line_1 = params[:address_line_1].strip
200
+ address_line_2 = params[:address_line_2].strip
201
+ city = params[:city].strip
202
+ geo_zone_id = params[:state].strip
203
+ postal_code = params[:postal_code].strip
204
+ contact_purpose = params[:contact_purpose]
205
+
206
+ postal_address = current_user.party.add_contact(PostalAddress,
207
+ {
208
+ address_line_1: address_line_1,
209
+ address_line_2: address_line_2,
210
+ city: city,
211
+ geo_zone_id: geo_zone_id,
212
+ state: GeoZone.find(geo_zone_id).zone_name,
213
+ zip: postal_code,
214
+ },
215
+ ContactPurpose.find_by_internal_identifier(contact_purpose))
216
+
217
+ {:json => {success: true,
218
+ message: 'Address added',
219
+ address: postal_address.to_hash(:only => [:id, :address_line_1, :address_line_2,
220
+ :city, :state, :zip],
221
+ :contact_purpose => ContactPurpose.find_by_internal_identifier(contact_purpose).description)}}
222
+ rescue => ex
223
+ Rails.logger.error ex.message
224
+ Rails.logger.error ex.backtrace.join("\n")
225
+
226
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
227
+
228
+ {:json => {success: false, message: 'Could not add address'}}
229
+ end
205
230
  end
206
231
  end
207
232
 
208
233
  def remove_address
209
- begin
210
- address_id = params[:address_id].strip
234
+ ActiveRecord::Base.connection.transaction do
235
+ begin
236
+ address_id = params[:address_id].strip
211
237
 
212
- PostalAddress.find(address_id).destroy
238
+ PostalAddress.find(address_id).destroy
213
239
 
214
- {:json => {success: true, message: 'address removed'}}
215
- rescue => ex
216
- Rails.logger.error ex.message
217
- Rails.logger.error ex.backtrace.join("\n")
218
- #TODO send out notification
240
+ {:json => {success: true, message: 'address removed'}}
241
+ rescue => ex
242
+ Rails.logger.error ex.message
243
+ Rails.logger.error ex.backtrace.join("\n")
219
244
 
220
- {:json => {success: false, message: 'Could not remove address'}}
245
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
246
+
247
+ {:json => {success: false, message: 'Could not remove address'}}
248
+ end
221
249
  end
222
250
  end
223
251
 
@@ -244,8 +272,9 @@ module Widgets
244
272
  return nil
245
273
  end
246
274
  end
247
- end
248
- end
249
- end
250
- end
275
+ end # Class Methods
276
+
277
+ end # Base
278
+ end # ManageProfile
279
+ end # Widgets
251
280