e9_crm 0.1.26 → 0.1.27
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.
- data/app/controllers/e9_crm/base_controller.rb +1 -1
- data/app/controllers/e9_crm/campaigns_controller.rb +1 -1
- data/app/controllers/e9_crm/leads_controller.rb +0 -1
- data/app/controllers/e9_crm/page_views_controller.rb +57 -8
- data/app/controllers/e9_crm/resources_controller.rb +1 -0
- data/app/controllers/e9_crm/visits_controller.rb +60 -0
- data/app/helpers/e9_crm/contacts_helper.rb +2 -9
- data/app/helpers/e9_crm/page_views_helper.rb +45 -0
- data/app/models/campaign.rb +23 -23
- data/app/models/contact.rb +17 -4
- data/app/models/page_view.rb +3 -20
- data/app/models/tracking_cookie.rb +16 -0
- data/app/views/e9_crm/affiliate_campaigns/_form_inner.html.haml +2 -1
- data/app/views/e9_crm/campaigns/_reports_table.html.haml +3 -3
- data/app/views/e9_crm/campaigns/_table.html.haml +1 -1
- data/app/views/e9_crm/campaigns/reports.js.erb +1 -1
- data/app/views/e9_crm/contacts/_sidebar_email_form.html.haml +7 -5
- data/app/views/e9_crm/contacts/index.html.haml +1 -1
- data/app/views/e9_crm/contacts/show.html.haml +1 -0
- data/app/views/e9_crm/dated_costs/index.html.haml +1 -3
- data/app/views/e9_crm/deals/_leads_table.html.haml +3 -0
- data/app/views/e9_crm/deals/_table.html.haml +3 -0
- data/app/views/e9_crm/deals/leads.js.erb +1 -1
- data/app/views/e9_crm/deals/show.html.haml +14 -5
- data/app/views/e9_crm/page_views/_header.html.haml +15 -0
- data/app/views/e9_crm/page_views/_table.html.haml +6 -6
- data/app/views/e9_crm/resources/index.html.haml +0 -3
- data/app/views/e9_crm/resources/index.js.erb +1 -1
- data/app/views/e9_crm/sales_campaigns/_form_inner.html.haml +2 -1
- data/app/views/e9_crm/visits/_header.html.haml +3 -0
- data/app/views/e9_crm/visits/_table.html.haml +27 -0
- data/config/locales/e9.en.yml +19 -12
- data/config/routes.rb +8 -16
- data/e9_crm.gemspec +0 -8
- data/lib/e9_crm/controller.rb +27 -12
- data/lib/e9_crm/model.rb +6 -5
- data/lib/e9_crm/rack/email_campaign_auto_completer.rb +29 -0
- data/lib/e9_crm/rails_extensions.rb +0 -33
- data/lib/e9_crm/tracking_controller.rb +3 -5
- data/lib/e9_crm/version.rb +1 -1
- data/lib/e9_crm.rb +7 -5
- metadata +48 -165
- data/app/controllers/e9_crm/email_templates.controller.rb +0 -46
- data/app/models/email_template.rb +0 -27
- data/app/views/e9_crm/email_templates/_form_inner.html.haml +0 -12
- data/app/views/e9_crm/email_templates/_header.html.haml +0 -7
- data/app/views/e9_crm/email_templates/select.html.haml +0 -5
- data/lib/e9_crm/email.rb +0 -18
@@ -1 +1 @@
|
|
1
|
-
$("
|
1
|
+
$("#records_table").html("<%= escape_javascript(render('table', :collection => collection)) %>");
|
@@ -4,8 +4,9 @@
|
|
4
4
|
%legend= e9_t(:salesperson_information_legend, :scope => 'e9_crm.campaigns')
|
5
5
|
.field
|
6
6
|
= f.label :sales_person, :class => :req, :for => 'campaign_sales_person_id'
|
7
|
-
|
7
|
+
|
8
8
|
- contact = f.object.sales_person
|
9
|
+
%input.contact-autocomplete{:type => 'text', :style => contact.blank? && '' || 'display:none'}
|
9
10
|
.contact-select{:style => contact.blank? && 'display:none' || ''}
|
10
11
|
%span.content= contact.try(:name)
|
11
12
|
%input{:type => :hidden, :name => "#{resource_instance_name}[sales_person_id]", :value => contact.try(:id)}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
%table.records
|
2
|
+
%thead
|
3
|
+
%tr
|
4
|
+
%th= orderable_column_link(:contact_name, :contact)
|
5
|
+
%th= orderable_column_link(:new_visits)
|
6
|
+
%th= orderable_column_link(:repeat_visits)
|
7
|
+
%th= t(:actions)
|
8
|
+
%tbody
|
9
|
+
- if collection.empty?
|
10
|
+
%tr
|
11
|
+
%td{:colspan => 5}= e9_t(:no_records_text)
|
12
|
+
- else
|
13
|
+
- collection.each do |record|
|
14
|
+
%tr{:id => "ids_#{record.id}", :class => cycle('odd', 'even')}
|
15
|
+
%td.record-contact-name
|
16
|
+
= record.contact_name
|
17
|
+
%td.record-new-visits.num
|
18
|
+
= record.new_visits.to_i
|
19
|
+
%td.record-repeat-visits.num
|
20
|
+
= record.repeat_visits.to_i
|
21
|
+
%td.links
|
22
|
+
- if record.contact_id
|
23
|
+
= link_to "View Contact", contact_url(record.contact_id)
|
24
|
+
= link_to "View Contact's Activity", page_views_url(:contact => record.contact_id, :campaign => parent.id)
|
25
|
+
|
26
|
+
- if controller.send(:should_paginate_index)
|
27
|
+
= will_paginate collection
|
data/config/locales/e9.en.yml
CHANGED
@@ -7,6 +7,18 @@ en:
|
|
7
7
|
new_title: "New %{model}"
|
8
8
|
actions: Actions
|
9
9
|
|
10
|
+
campaigns:
|
11
|
+
no_campaign: No Campaign
|
12
|
+
no_group: No Group
|
13
|
+
campaign_information_legend: Campaign Information
|
14
|
+
salesperson_information_legend: Salesperson Information
|
15
|
+
affiliate_information_legend: Affiliate Information
|
16
|
+
contact_emails:
|
17
|
+
prepare_title: Edit Your Template
|
18
|
+
send_email: Send Email
|
19
|
+
contact_merges:
|
20
|
+
new_title: Merge Contacts
|
21
|
+
no_value: (No Value)
|
10
22
|
contacts:
|
11
23
|
index_title_with_search: "%{models} matching \"%{search}\""
|
12
24
|
index_title_with_tags: "%{models} tagged \"%{tagged}\""
|
@@ -22,12 +34,6 @@ en:
|
|
22
34
|
email_actions_legend: Email Actions
|
23
35
|
search_options_legend: Search Filters
|
24
36
|
edit_title_with_name: "Edit %{contact}"
|
25
|
-
contact_merges:
|
26
|
-
new_title: Merge Contacts
|
27
|
-
no_value: (No Value)
|
28
|
-
contact_emails:
|
29
|
-
prepare_title: Edit Your Template
|
30
|
-
send_email: Send Email
|
31
37
|
deals:
|
32
38
|
new_title: Create Deal
|
33
39
|
email_templates:
|
@@ -35,12 +41,13 @@ en:
|
|
35
41
|
leads:
|
36
42
|
index_title: Leads
|
37
43
|
no_records_text: No leads exist.
|
44
|
+
page_views:
|
45
|
+
no_records_text: No activity exists.
|
46
|
+
visits:
|
47
|
+
no_records_text: No activity exists.
|
38
48
|
reports:
|
39
49
|
index_title: Marketing Report
|
40
50
|
no_records_text: No data exists for those query parameters.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
campaign_information_legend: Campaign Information
|
45
|
-
salesperson_information_legend: Salesperson Information
|
46
|
-
affiliate_information_legend: Affiliate Information
|
51
|
+
visits:
|
52
|
+
breadcrumb_title: Campaign Activity
|
53
|
+
index_title: "Campaign: %{parent}"
|
data/config/routes.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
crm_path = 'admin/crm'
|
3
3
|
|
4
|
-
get '/autocomplete/contacts'
|
5
|
-
get '/autocomplete/companies'
|
6
|
-
get '/
|
4
|
+
get '/autocomplete/contacts' => E9Crm::Rack::ContactAutoCompleter
|
5
|
+
get '/autocomplete/companies' => E9Crm::Rack::CompanyAutoCompleter
|
6
|
+
get '/autocomplete/email_campaigns' => E9Crm::Rack::EmailCampaignAutoCompleter
|
7
|
+
get '/users/email_test.json' => E9Crm::Rack::EmailAvailabilityChecker
|
7
8
|
|
8
9
|
scope :module => :e9_crm do
|
9
10
|
resources :offers, :as => :public_offer, :only => :show do
|
@@ -18,9 +19,6 @@ Rails.application.routes.draw do
|
|
18
19
|
|
19
20
|
resources :companies, :except => :show
|
20
21
|
resources :contacts do
|
21
|
-
# page_views currently not routed, but near working
|
22
|
-
#resources :page_views, :path => 'activity', :only => :index
|
23
|
-
|
24
22
|
collection { get :templates }
|
25
23
|
member do
|
26
24
|
post :upload_avatar
|
@@ -28,13 +26,9 @@ Rails.application.routes.draw do
|
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
31
|
-
resources :
|
29
|
+
resources :page_views, :path => 'activity', :only => :index
|
32
30
|
|
33
|
-
|
34
|
-
resources :contact_emails, :except => [:index, :show]
|
35
|
-
resources :email_templates do
|
36
|
-
collection { get :select }
|
37
|
-
end
|
31
|
+
resources :deals
|
38
32
|
|
39
33
|
resources :dated_costs, :path => 'advertising_costs', :only => [:index] do
|
40
34
|
collection do
|
@@ -43,11 +37,10 @@ Rails.application.routes.draw do
|
|
43
37
|
end
|
44
38
|
|
45
39
|
resources :campaigns, :only => [:index, :destroy, :new] do
|
46
|
-
|
47
|
-
#resources :page_views, :path => 'activity', :only => :index
|
40
|
+
resources :visits, :path => 'activity', :only => :index
|
48
41
|
end
|
49
42
|
scope :path => :campaigns do
|
50
|
-
|
43
|
+
|
51
44
|
resources :campaign_groups, :path => 'groups', :except => [:show]
|
52
45
|
|
53
46
|
resources :sales_campaigns, :path => 'sales', :except => [:show, :index]
|
@@ -79,7 +72,6 @@ Rails.application.routes.draw do
|
|
79
72
|
campaigns/sales
|
80
73
|
campaigns/groups
|
81
74
|
deals
|
82
|
-
email_templates
|
83
75
|
menu_options
|
84
76
|
offers
|
85
77
|
).each do |path|
|
data/e9_crm.gemspec
CHANGED
@@ -19,14 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency("rails", "~> 3.0.0")
|
23
|
-
s.add_dependency("inherited_resources", "~> 1.1.2")
|
24
|
-
s.add_dependency("has_scope")
|
25
22
|
s.add_dependency("money")
|
26
|
-
s.add_dependency("e9_rails")
|
27
|
-
s.add_dependency("e9_tags")
|
28
|
-
s.add_dependency("e9_attributes")
|
29
|
-
s.add_dependency("will_paginate")
|
30
23
|
s.add_dependency("kramdown", "~> 0.13")
|
31
|
-
s.add_dependency("state_machine", "~> 1.0")
|
32
24
|
end
|
data/lib/e9_crm/controller.rb
CHANGED
@@ -9,12 +9,10 @@ module E9Crm
|
|
9
9
|
included do
|
10
10
|
helper_method :tracking_cookie, :tracking_campaign
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
#
|
13
|
+
# monkey patch liquid_env to insert campaign
|
14
|
+
#
|
16
15
|
alias :liquid_env_without_crm :liquid_env
|
17
|
-
|
18
16
|
def liquid_env
|
19
17
|
liquid_env_without_crm.tap do |env|
|
20
18
|
env[:campaign] = tracking_campaign
|
@@ -37,6 +35,14 @@ module E9Crm
|
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
38
|
+
def _user_from_params
|
39
|
+
if user_id = params.delete(E9Crm.query_user_id)
|
40
|
+
@_user_from_params = User.find_by_id(user_id)
|
41
|
+
end
|
42
|
+
|
43
|
+
@_user_from_params
|
44
|
+
end
|
45
|
+
|
40
46
|
#
|
41
47
|
# Loads or installs the tracking cookie
|
42
48
|
#
|
@@ -44,7 +50,7 @@ module E9Crm
|
|
44
50
|
@_tracking_cookie ||= begin
|
45
51
|
E9Crm.log "Begin load or install cookie: cookie_name[#{E9Crm.cookie_name}] query_param[#{E9Crm.query_param}]"
|
46
52
|
|
47
|
-
code
|
53
|
+
code = params.delete(E9Crm.query_param)
|
48
54
|
|
49
55
|
if hid = cookies[E9Crm.cookie_name]
|
50
56
|
E9Crm.log("Installed cookie found: hid(#{hid})")
|
@@ -66,9 +72,14 @@ module E9Crm
|
|
66
72
|
else
|
67
73
|
attrs = {}
|
68
74
|
|
69
|
-
if
|
70
|
-
|
71
|
-
|
75
|
+
if @_tracking_cookie.user_id.nil?
|
76
|
+
if current_user
|
77
|
+
E9Crm.log("Cookie has no user, setting as current_user (#{current_user.id})")
|
78
|
+
attrs[:user] = current_user
|
79
|
+
elsif _user_from_params
|
80
|
+
E9Crm.log("Cookie has no user, setting as user from params (#{_user_from_params.id})")
|
81
|
+
attrs[:user] = _user_from_params
|
82
|
+
end
|
72
83
|
end
|
73
84
|
|
74
85
|
if code.present? && code != @_tracking_cookie.code && Campaign.find_by_code(code)
|
@@ -79,15 +90,19 @@ module E9Crm
|
|
79
90
|
session[:new_visit] = true
|
80
91
|
end
|
81
92
|
|
82
|
-
|
83
|
-
|
93
|
+
if attrs.blank?
|
94
|
+
E9Crm.log "Cookie unchanged, no update"
|
95
|
+
else
|
96
|
+
E9Crm.log "Cookie changed, new attrs: #{attrs.inspect}"
|
97
|
+
@_tracking_cookie.update_attributes(attrs)
|
98
|
+
end
|
84
99
|
end
|
85
100
|
end
|
86
101
|
|
87
102
|
@_tracking_cookie ||= begin
|
88
103
|
session[:new_visit] = true
|
89
104
|
|
90
|
-
TrackingCookie.create(:code => code, :user => current_user).tap do |cookie|
|
105
|
+
TrackingCookie.create(:code => code, :user => current_user || _user_from_params).tap do |cookie|
|
91
106
|
E9Crm.log "Installing new cookie (#{E9Crm.cookie_name} : #{cookie.hid})"
|
92
107
|
cookies.permanent[E9Crm.cookie_name] = cookie.hid
|
93
108
|
end
|
data/lib/e9_crm/model.rb
CHANGED
@@ -35,11 +35,12 @@ module E9Crm
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def create_contact_if_missing!
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
return true unless contact.blank?
|
39
|
+
|
40
|
+
# when creating a contact we should assume we're primary
|
41
|
+
self.options.primary = true
|
42
|
+
build_contact(create_contact_parameters)
|
43
|
+
save
|
43
44
|
end
|
44
45
|
|
45
46
|
protected
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module E9Crm::Rack
|
2
|
+
#
|
3
|
+
# Returns contacts and joins their primary user for their email if it exists,
|
4
|
+
# and will return a string like "firstname lastname (email)". If for whatever
|
5
|
+
# reason the contact has no primary user, it will drop the email.
|
6
|
+
#
|
7
|
+
class EmailCampaignAutoCompleter
|
8
|
+
DEFAULT_LIMIT = 10
|
9
|
+
|
10
|
+
def self.call(env)
|
11
|
+
params = Rack::Request.new(env).params
|
12
|
+
|
13
|
+
if term = params['term']
|
14
|
+
relation = EmailCampaign.
|
15
|
+
select('name, code').
|
16
|
+
limit(params['limit'] || DEFAULT_LIMIT).
|
17
|
+
attr_like(:code, term, :matcher => '%s%%')
|
18
|
+
|
19
|
+
json = ::ActiveRecord::Base.connection.send(:select, relation.to_sql, 'Email Campaign Autocomplete').map do |row|
|
20
|
+
{ :label => "#{row['code']} - #{row['name']}", :value => row['code'] }
|
21
|
+
end.to_json
|
22
|
+
else
|
23
|
+
json = []
|
24
|
+
end
|
25
|
+
|
26
|
+
[200, {"Content-Type" => "application/json", "Cache-Control" => "no-cache"}, [json]]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -110,36 +110,3 @@ module ActiveModel
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
113
|
-
|
114
|
-
module E9Crm
|
115
|
-
#
|
116
|
-
# Fairly straightforward hack to allow e9_crm views to inherit from resources.
|
117
|
-
# If a missing template error is raised by a view looking for a template prefixed with
|
118
|
-
# "e9_crm", redirect the lookup to "e9_crm/resources"
|
119
|
-
#
|
120
|
-
# This would be worth looking into further but inherited templates are a feature coming
|
121
|
-
# up in Rails anyway.
|
122
|
-
#
|
123
|
-
|
124
|
-
module ActionView
|
125
|
-
extend ActiveSupport::Concern
|
126
|
-
|
127
|
-
included do
|
128
|
-
def self.process_view_paths(value)
|
129
|
-
value.is_a?(::E9Crm::ActionView::PathSet) ?
|
130
|
-
value.dup : ::E9Crm::ActionView::PathSet.new(Array.wrap(value))
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
class PathSet < ::ActionView::PathSet
|
135
|
-
def find(path, prefix = nil, partial = false, details = {}, key = nil)
|
136
|
-
super
|
137
|
-
rescue ::ActionView::MissingTemplate
|
138
|
-
raise $! unless prefix =~ /^e9_crm/
|
139
|
-
super(path, "e9_crm/resources", partial, details, key)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
ActionView::Base.send(:include, E9Crm::ActionView)
|
@@ -3,11 +3,7 @@ module E9Crm
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
|
7
|
-
|
8
|
-
prepend_before_filter do
|
9
|
-
E9Crm.log("E9Crm tracking controller request")
|
10
|
-
end
|
6
|
+
after_filter :track_page_view
|
11
7
|
end
|
12
8
|
|
13
9
|
protected
|
@@ -35,6 +31,8 @@ module E9Crm
|
|
35
31
|
:campaign => tracking_campaign,
|
36
32
|
:new_visit => session[:new_visit].present?
|
37
33
|
})
|
34
|
+
|
35
|
+
E9Crm.log("Page View: #{@_page_view.inspect}")
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|
data/lib/e9_crm/version.rb
CHANGED
data/lib/e9_crm.rb
CHANGED
@@ -6,14 +6,14 @@ module E9Crm
|
|
6
6
|
autoload :VERSION, 'e9_crm/version'
|
7
7
|
autoload :Controller, 'e9_crm/controller'
|
8
8
|
autoload :Model, 'e9_crm/model'
|
9
|
-
autoload :Email, 'e9_crm/email'
|
10
9
|
autoload :TrackingController, 'e9_crm/tracking_controller'
|
11
10
|
autoload :SystemEmailsController, 'e9_crm/system_emails_controller'
|
12
11
|
|
13
12
|
module Rack
|
14
|
-
autoload :ContactAutoCompleter,
|
15
|
-
autoload :CompanyAutoCompleter,
|
16
|
-
autoload :
|
13
|
+
autoload :ContactAutoCompleter, 'e9_crm/rack/contact_auto_completer'
|
14
|
+
autoload :CompanyAutoCompleter, 'e9_crm/rack/company_auto_completer'
|
15
|
+
autoload :EmailCampaignAutoCompleter, 'e9_crm/rack/email_campaign_auto_completer'
|
16
|
+
autoload :EmailAvailabilityChecker, 'e9_crm/rack/email_availability_checker'
|
17
17
|
end
|
18
18
|
|
19
19
|
mattr_accessor :cookie_name
|
@@ -22,6 +22,9 @@ module E9Crm
|
|
22
22
|
mattr_accessor :query_param
|
23
23
|
@@query_param = 'code'
|
24
24
|
|
25
|
+
mattr_accessor :query_user_id
|
26
|
+
@@query_user_id = 'cuid'
|
27
|
+
|
25
28
|
mattr_accessor :log_level
|
26
29
|
@@log_level = :debug
|
27
30
|
|
@@ -54,7 +57,6 @@ module E9Crm
|
|
54
57
|
|
55
58
|
ApplicationController.send(:include, E9Crm::Controller)
|
56
59
|
|
57
|
-
::Email.send(:include, E9Crm::Email)
|
58
60
|
::Admin::SystemEmailsController.send(:include, E9Crm::SystemEmailsController)
|
59
61
|
|
60
62
|
E9Crm.tracking_controllers.each do |controller|
|