Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added sms support

  • Loading branch information...
commit ae81c8dbbe22365ba497425ac58f7a4984a8fddf 1 parent 5008361
BIG Folio authored
7 app/controllers/messages_controller.rb
@@ -53,6 +53,13 @@ def create
53 53 if current_user
54 54 @ticket.close! if params[:close_ticket]
55 55 format.html { redirect_to(@ticket) }
  56 +
  57 + # Send a text message to the customer
  58 + # This should really be done in the model, but sms-fu doesn't seem to like that
  59 + url = view_by_key_url(@ticket.key, :host => 'bighelp.bigfolio.com')
  60 + deliver_sms(@ticket.mobile_number.gsub(/[^0-9]/,""), @ticket.carrier_name, "We have an update to your support request (#{@ticket.key}). Please visit #{url}") unless @ticket.mobile_number.blank?
  61 +
  62 +
56 63 else
57 64 format.html { redirect_to(view_by_key_url(@ticket.key)) }
58 65 end
6 app/controllers/tickets_controller.rb
@@ -4,6 +4,7 @@ class TicketsController < ApplicationController
4 4 before_filter :login_required, :except => [:new, :create]
5 5
6 6 has_mobile_fu
  7 + has_sms_fu
7 8
8 9 # GET /tickets
9 10 # GET /tickets.xml
@@ -88,6 +89,11 @@ def create
88 89 flash[:notice] = 'Ticket was successfully created.'
89 90 format.html { redirect_to(view_by_key_url(@ticket.key)) }
90 91 format.xml { render :xml => @ticket, :status => :created, :location => @ticket }
  92 +
  93 + # Send a text message
  94 + deliver_sms(@ticket.mobile_number.gsub(/[^0-9]/,""), @ticket.carrier_name, "Your support ticket has been received.") unless @ticket.mobile_number.blank?
  95 +
  96 +
91 97 else
92 98 format.html { render :action => "new" }
93 99 format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }
9 app/models/ticket.rb
... ... @@ -1,4 +1,6 @@
1 1 class Ticket < ActiveRecord::Base
  2 +
  3 +
2 4
3 5 belongs_to :category
4 6 belongs_to :user
@@ -11,6 +13,7 @@ class Ticket < ActiveRecord::Base
11 13 state :closed
12 14
13 15 before_create :generate_key
  16 + after_create :strip_mobile
14 17 after_create :send_alerts
15 18
16 19 event :research do
@@ -36,12 +39,16 @@ def classes
36 39
37 40 protected
38 41
  42 + def strip_mobile
  43 + self.mobile_number.gsub!(/[^0-9]/,"") unless self.mobile_number.blank?
  44 + self.save
  45 + end
  46 +
39 47 def send_alerts
40 48 users = User.find(:all)
41 49 users.each { |u| TicketMailer.deliver_ticket_alert(u, self) if u.categories.include?(self.category) }
42 50
43 51 TicketMailer.deliver_ticket_confirmation(self)
44   -
45 52 end
46 53
47 54 def generate_key
5 app/views/tickets/new.html.erb
@@ -22,6 +22,11 @@
22 22 <%= f.label :domain, "Domain name" %><br />
23 23 <%= f.text_field :domain %>
24 24 </p>
  25 + <p>
  26 + <%= f.label :mobile_number, "Mobile phone" %><br />
  27 + <%= f.text_field :mobile_number %>
  28 + </p>
  29 + <p><%= carrier_select('ticket[carrier_name]', "Please choose your carrier") %></p>
25 30 </fieldset>
26 31
27 32
9 db/migrate/20090708221732_add_mobile_info_to_tickets.rb
... ... @@ -0,0 +1,9 @@
  1 +class AddMobileInfoToTickets < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :tickets, :mobile_number, :string
  4 + add_column :tickets, :carrier_name, :string
  5 + end
  6 +
  7 + def self.down
  8 + end
  9 +end
10 db/schema.rb
@@ -9,12 +9,13 @@
9 9 #
10 10 # It's strongly recommended to check this file into your version control system.
11 11
12   -ActiveRecord::Schema.define(:version => 20090221212303) do
  12 +ActiveRecord::Schema.define(:version => 20090708221732) do
13 13
14 14 create_table "categories", :force => true do |t|
15 15 t.string "name"
16 16 t.datetime "created_at"
17 17 t.datetime "updated_at"
  18 + t.string "help_url", :default => "http://www.bigfolio.com/help"
18 19 end
19 20
20 21 create_table "faqs", :force => true do |t|
@@ -56,6 +57,8 @@
56 57 t.string "os"
57 58 t.string "email_client"
58 59 t.string "browser"
  60 + t.string "mobile_number"
  61 + t.string "carrier_name"
59 62 end
60 63
61 64 create_table "user_notifications", :id => false, :force => true do |t|
@@ -75,6 +78,11 @@
75 78 t.datetime "updated_at"
76 79 t.string "remember_token", :limit => 40
77 80 t.datetime "remember_token_expires_at"
  81 + t.datetime "avatar_updated_at"
  82 + t.string "avatar_file_name"
  83 + t.string "avatar_content_type"
  84 + t.integer "avatar_file_size"
  85 + t.datetime "avatar_uploaded_at"
78 86 end
79 87
80 88 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
1  vendor/plugins/sms_fu
... ... @@ -0,0 +1 @@
  1 +Subproject commit 899050db2a8877fe508738811c121247571aaea2

0 comments on commit ae81c8d

Please sign in to comment.
Something went wrong with that request. Please try again.