ifd_tools 0.1.1 → 0.1.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.
@@ -0,0 +1,55 @@
1
+ ActiveAdmin.register IfdTools::ContactRequest, as: "Contact Request" do
2
+
3
+ config.sort_order = "created_at_desc"
4
+ controller.authorize_resource class: "IfdTools::ContactRequest"
5
+
6
+ menu parent: "Administration", if: proc { can? :manage, IfdTools::ContactRequest }
7
+
8
+ scope :all
9
+ scope :unread, default: true
10
+ scope :read
11
+
12
+ batch_action :read, confirm: "Are you sure you want to mark these messages as read?" do |selection_ids|
13
+ IfdTools::ContactRequest.where(id: selection_ids).update_all read_status: true
14
+ redirect_to collection_path, notice: "Messages have been marked as read"
15
+ end
16
+
17
+ batch_action :Unread, confirm: "Are you sure you want to mark these messages as unread?" do |selection_ids|
18
+ IfdTools::ContactRequest.where(id: selection_ids).update_all read_status: false
19
+ redirect_to collection_path, notice: "Messages have been marked as unread"
20
+ end
21
+
22
+ index do
23
+ selectable_column
24
+ column :first_name
25
+ column :last_name
26
+ column(:email, sortable: :email) { |c| mail_to c.email, c.email }
27
+ column(:read, sortable: :read_status) { |c| status_tag c.read_status? ? "Read" : "Unread", c.read_status? ? :green : :error }
28
+ column(:submitted, sortable: :created_at) { |c| c.created_at.humanize }
29
+ default_actions
30
+ end
31
+
32
+ form partial: "form"
33
+
34
+ show title: "Contact Request" do
35
+ panel "Contact Request Info" do
36
+ attributes_table_for resource do
37
+ row(:name) { resource.to_s }
38
+ row(:email) { link_to resource.email, "mailto:%s" % resource.email }
39
+ row(:phone) { phone_number resource.phone }
40
+ row(:submitted) { resource.created_at.humanize }
41
+ row(:read) { status_tag resource.read_status? ? "Read" : "Unread", resource.read_status? ? :green : :error }
42
+ row(:body)
43
+ end
44
+ end
45
+ end
46
+
47
+ controller do
48
+ def resource
49
+ r = super
50
+ r.read! unless r.new_record?
51
+ r
52
+ end
53
+ end
54
+
55
+ end
@@ -0,0 +1,8 @@
1
+ module IfdTools
2
+ class ContactRequestMailer < ActionMailer::Base
3
+ def admin_notification(contact_request)
4
+ @contact = contact_request
5
+ mail to: Settings.contact_request_to, from: Settings.notifications_email, reply_to: @contact_request.email, subject: "[#{ActiveAdmin.application.site_title}]: Contact Request"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,34 @@
1
+ module IfdTools
2
+ class ContactRequest < ActiveRecord::Base
3
+
4
+ belongs_to :customer
5
+ attr_accessible :body, :email, :first_name, :last_name, :phone, :read_status, :customer_id
6
+
7
+ validates :first_name, :last_name, :body, presence: true
8
+ validates :email, :body, :customer, presence: true
9
+
10
+ after_create :send_notification_email
11
+
12
+ scope :unread, where(read_status: false)
13
+ scope :read, where(read_status: true)
14
+
15
+ def to_s
16
+ "#{first_name} #{last_name}"
17
+ end
18
+
19
+ def display_name
20
+ to_s
21
+ end
22
+
23
+ def read!
24
+ update_attribute :read_status, true
25
+ end
26
+
27
+ private
28
+
29
+ def send_notification_email
30
+ IfdTools::ContactRequestMailer.delay.admin_notification(self)
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,10 @@
1
+ = semantic_form_for [:admin, @contact_request] do |f|
2
+ = f.inputs "Request Details" do
3
+ = f.input :customer
4
+ = f.input :email
5
+ = f.input :first_name, label: "First Name"
6
+ = f.input :last_name, label: "Last Name"
7
+ = f.input :phone
8
+ = f.input :body
9
+ = f.actions do
10
+ = f.action :submit
@@ -0,0 +1,12 @@
1
+ xml.instruct!
2
+ xml.response do
3
+ if @contact_request.valid?
4
+ xml.request true
5
+ else
6
+ xml.errors do
7
+ @contact_request.errors.each do |key, message|
8
+ xml.error(key: key) { xml.cdata! message }
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ %html
2
+ %head
3
+ %title== #{ActiveAdmin.application.site_title} Support Request
4
+ %body
5
+ #wrapper
6
+ #content
7
+ %h2 Name:
8
+ %p== #{@contact.first_name} #{@contact.last_name}
9
+ %h2 Email Address:
10
+ %p== #{@contact.email}
11
+ %h2 Phone Number:
12
+ %p==#{@contact.phone}
13
+ %h2 Message:
14
+ %p==#{@contact.body}
15
+ #footer
16
+ %p== <strong>Sent On:</strong> #{Time.now.strftime("%b %-d, %Y %I:%M %P %Z")}
@@ -0,0 +1,16 @@
1
+ class CreateIfdToolsContactRequests < ActiveRecord::Migration
2
+ def change
3
+ create_table :ifd_tools_contact_requests do |t|
4
+ t.string :first_name
5
+ t.string :last_name
6
+ t.string :phone
7
+ t.string :email
8
+ t.references :customer
9
+ t.boolean :read_status, default: false
10
+ t.text :body
11
+
12
+ t.timestamps
13
+ end
14
+ add_index :ifd_tools_contact_requests, :customer_id
15
+ end
16
+ end
@@ -6,7 +6,7 @@ class Ability
6
6
  user ||= User.new
7
7
 
8
8
  can :manage, :all
9
- cannot [:create, :new], Customer
9
+ cannot [:create, :new], [Customer, IfdTools::ContactRequest]
10
10
 
11
11
  unless user.super_admin?
12
12
 
@@ -2,6 +2,7 @@ defaults: &defaults
2
2
  notifications_email: "notifications@domain.com"
3
3
  app_name: "Name of CMS"
4
4
  app_header_name: "Name of App Header"
5
+ contact_request_to: "matt@dmgx.com"
5
6
 
6
7
  development:
7
8
  <<: *defaults
@@ -0,0 +1,11 @@
1
+ module IfdTools
2
+ module ApiController
3
+ module ContactRequests
4
+ def contact
5
+ @contact_request = ContactRequest.new(params[:contact_request])
6
+ @contact_request.customer = current_customer
7
+ @contact_request.save
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,6 +1,7 @@
1
1
  require 'ifd_tools/api_controller/emergency_messages'
2
2
  require 'ifd_tools/api_controller/software_updates'
3
3
  require 'ifd_tools/api_controller/notifier_updates'
4
+ require 'ifd_tools/api_controller/contact_requests'
4
5
  require 'ifd_tools/api_controller/tracking'
5
6
 
6
7
  module IfdTools
@@ -12,6 +13,7 @@ module IfdTools
12
13
  include IfdTools::ApiController::SoftwareUpdates
13
14
  include IfdTools::ApiController::NotifierUpdates
14
15
  include IfdTools::ApiController::Tracking
16
+ include IfdTools::ApiController::ContactRequests
15
17
  end
16
18
 
17
19
  end
@@ -1,3 +1,3 @@
1
1
  module IfdTools
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -0,0 +1,19 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ first_name: MyString
5
+ last_name: MyString
6
+ phone: MyString
7
+ email: MyString
8
+ customer:
9
+ read_status: false
10
+ body: MyText
11
+
12
+ two:
13
+ first_name: MyString
14
+ last_name: MyString
15
+ phone: MyString
16
+ email: MyString
17
+ customer:
18
+ read_status: false
19
+ body: MyText
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ module IfdTools
4
+ class ContactRequestTest < ActionMailer::TestCase
5
+ test "admin_notification" do
6
+ mail = ContactRequest.admin_notification
7
+ assert_equal "Admin notification", mail.subject
8
+ assert_equal ["to@example.org"], mail.to
9
+ assert_equal ["from@example.com"], mail.from
10
+ assert_match "Hi", mail.body.encoded
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module IfdTools
4
+ class ContactRequestTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ifd_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-12 00:00:00.000000000 Z
12
+ date: 2012-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -259,6 +259,7 @@ executables: []
259
259
  extensions: []
260
260
  extra_rdoc_files: []
261
261
  files:
262
+ - app/admin/contact_requests.rb
262
263
  - app/admin/emergency_messages.rb
263
264
  - app/admin/notifier_updates.rb
264
265
  - app/admin/software_updates.rb
@@ -274,6 +275,8 @@ files:
274
275
  - app/assets/swfs/usa_map.swf
275
276
  - app/controllers/ifd_tools/application_controller.rb
276
277
  - app/helpers/ifd_tools/application_helper.rb
278
+ - app/mailers/ifd_tools/contact_request_mailer.rb
279
+ - app/models/ifd_tools/contact_request.rb
277
280
  - app/models/ifd_tools/emergency_message.rb
278
281
  - app/models/ifd_tools/notifier_update.rb
279
282
  - app/models/ifd_tools/software_update.rb
@@ -281,6 +284,7 @@ files:
281
284
  - app/models/ifd_tools/tracking/event.rb
282
285
  - app/models/ifd_tools/tracking.rb
283
286
  - app/uploaders/software_uploader.rb
287
+ - app/views/admin/contact_requests/_form.html.haml
284
288
  - app/views/admin/customers/_trend.html.haml
285
289
  - app/views/admin/customers/_trend_info_sidebar.html.haml
286
290
  - app/views/admin/customers/demographic_data.builder
@@ -294,10 +298,12 @@ files:
294
298
  - app/views/admin/shared/_footer.html.haml
295
299
  - app/views/admin/software_updates/_form.html.haml
296
300
  - app/views/admin/users/_form.html.haml
301
+ - app/views/api/contact.builder
297
302
  - app/views/api/emergency_messages.builder
298
303
  - app/views/api/notifier_updates.builder
299
304
  - app/views/api/software_updates.builder
300
305
  - app/views/api/track.builder
306
+ - app/views/ifd_tools/contact_request_mailer/admin_notification.html.haml
301
307
  - app/views/layouts/ifd_tools/application.html.erb
302
308
  - config/routes.rb
303
309
  - db/migrate/20121010183004_create_ifd_tools_emergency_messages.rb
@@ -306,6 +312,7 @@ files:
306
312
  - db/migrate/20121011205911_devise_create_users.rb
307
313
  - db/migrate/20121012123505_create_customers.rb
308
314
  - db/migrate/20121012133303_create_ifd_tools_tracking_events.rb
315
+ - db/migrate/20121015165949_create_ifd_tools_contact_requests.rb
309
316
  - lib/generators/ifd_tools/install/install_generator.rb
310
317
  - lib/generators/ifd_tools/install/templates/admin/customers.rb
311
318
  - lib/generators/ifd_tools/install/templates/admin/dashboard.rb
@@ -335,6 +342,7 @@ files:
335
342
  - lib/generators/ifd_tools/install/templates/views/customers/_form.html.haml
336
343
  - lib/generators/ifd_tools/install/USAGE
337
344
  - lib/ifd_tools/active_admin/base.rb
345
+ - lib/ifd_tools/api_controller/contact_requests.rb
338
346
  - lib/ifd_tools/api_controller/emergency_messages.rb
339
347
  - lib/ifd_tools/api_controller/notifier_updates.rb
340
348
  - lib/ifd_tools/api_controller/software_updates.rb
@@ -384,13 +392,16 @@ files:
384
392
  - test/dummy/Rakefile
385
393
  - test/dummy/README.rdoc
386
394
  - test/dummy/script/rails
395
+ - test/fixtures/ifd_tools/contact_requests.yml
387
396
  - test/fixtures/ifd_tools/emergency_messages.yml
388
397
  - test/fixtures/ifd_tools/notifier_updates.yml
389
398
  - test/fixtures/ifd_tools/software_updates.yml
390
399
  - test/fixtures/ifd_tools/tracking/events.yml
400
+ - test/functional/ifd_tools/contact_request_test.rb
391
401
  - test/ifd_tools_test.rb
392
402
  - test/integration/navigation_test.rb
393
403
  - test/test_helper.rb
404
+ - test/unit/ifd_tools/contact_request_test.rb
394
405
  - test/unit/ifd_tools/emergency_message_test.rb
395
406
  - test/unit/ifd_tools/notifier_update_test.rb
396
407
  - test/unit/ifd_tools/software_update_test.rb
@@ -451,13 +462,16 @@ test_files:
451
462
  - test/dummy/Rakefile
452
463
  - test/dummy/README.rdoc
453
464
  - test/dummy/script/rails
465
+ - test/fixtures/ifd_tools/contact_requests.yml
454
466
  - test/fixtures/ifd_tools/emergency_messages.yml
455
467
  - test/fixtures/ifd_tools/notifier_updates.yml
456
468
  - test/fixtures/ifd_tools/software_updates.yml
457
469
  - test/fixtures/ifd_tools/tracking/events.yml
470
+ - test/functional/ifd_tools/contact_request_test.rb
458
471
  - test/ifd_tools_test.rb
459
472
  - test/integration/navigation_test.rb
460
473
  - test/test_helper.rb
474
+ - test/unit/ifd_tools/contact_request_test.rb
461
475
  - test/unit/ifd_tools/emergency_message_test.rb
462
476
  - test/unit/ifd_tools/notifier_update_test.rb
463
477
  - test/unit/ifd_tools/software_update_test.rb