Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle routes Radiant 0.9.1 style #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,22 @@ I'll be happy to work on this extension some more and make it support both multi

This extension was designed to be used with vhost_extension. If your using vhost extension then you can import leads from your web forms directly into the CRM using the LeadsController.

= Dependencies

The following need to be available in order for this extension to work properly:

* simple_column_search Rubygem
* acts_as_paranoid plugin (Using a later version of this may require that you change all "acts_as_paranoid" refs. to "include ActiveRecord::Paranoia". Also, the line "require 'active_record/dynamic_scope'" may need to be added to plugins/acts_as_paranoid/init.rb).
* acts_as_commentable plugin
* Prototype Javascript library (must be placed before facebox JS in CRM layout)
* Effects Javascript library (must be placed before facebox JS in CRM layout)
* settings.yml needs to be present in your RAILS_ROOT/config or RADIANT_ROOT/config directory

(Note: The DB migrations for the extension handle the required columns for acts_as_paranoid and the required "comments" table for acts_as_commentable.)

= Installation

git clone git://github.com:sbmsuite/radiant-crm-extension.git vendor/extensions/crm
git clone git://github.com/sbmsuite/radiant-crm-extension.git vendor/extensions/crm
rake radiant:extensions:crm:update
rake radiant:extensions:crm:migrate
rake crm:settings:load
4 changes: 2 additions & 2 deletions app/views/layouts/crm.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
- if tab.visible?(current_user)
%li{:class=>('current' if current_tab?(tab))}
%a{:href=>(tab.first.url if tab.first)}
= tab.proper_name
= tab.name
- if current_tab?(tab)
%ul#nav_sub
- tab.each do |sub_item|
- if sub_item.visible?(current_user)
%li
%a{:href => sub_item.url, :class => current_item?(sub_item) ? 'current' : ''}>
%span
= sub_item.proper_name
= sub_item.name
#header_bottom
%div
#main
Expand Down
62 changes: 62 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
ActionController::Routing::Routes.draw do |map|
map.create_lead 'leads/create_lead', :controller => 'leads', :action => 'create_lead'

map.with_options(:controller => 'admin/accounts') do |account|
account.options 'admin/accounts/options', :action => 'options'
account.redraw 'admin/accounts/redraw', :action => 'redraw'
account.search 'admin/accounts/search', :action => 'search'
end

map.with_options(:controller => 'admin/campaigns') do |campaign|
campaign.options 'admin/campaigns/options', :action => 'options'
campaign.redraw 'admin/campaigns/redraw', :action => 'redraw'
campaign.search 'admin/campaigns/search', :action => 'search'
campaign.filter 'admin/campaigns/filter', :action => 'filter'
end

map.with_options(:controller => 'admin/contacts') do |contact|
contact.options 'admin/contacts/options', :action => 'options'
contact.redraw 'admin/contacts/redraw', :action => 'redraw'
contact.search 'admin/contacts/convert', :action => 'convert'
end

map.with_options(:controller => 'admin/home') do |home|
home.toggle 'admin/home/toggle', :action => 'toggle'
home.options 'admin/home/options', :action => 'options'
home.redraw 'admin/home/redraw', :action => 'redraw'
home.toggle 'admin/home/toggle', :action => 'toggle'
home.timezone 'admin/home/timezone', :action => 'timezone'
end

map.with_options(:controller => 'admin/leads') do |lead|
lead.options 'admin/leads/options', :action => 'options'
lead.redraw 'admin/leads/redraw', :action => 'redraw'
lead.convert 'admin/leads/convert', :action => 'convert'
lead.reject 'admin/leads/reject', :action => 'reject'
lead.search 'admin/leads/search', :action => 'search'
lead.filter 'admin/leads/filter', :action => 'filter'
end

map.with_options(:controller => 'admin/opportunities') do |opportunity|
opportunity.options 'admin/opportunities/options', :action => 'options'
opportunity.redraw 'admin/opportunities/redraw', :action => 'redraw'
opportunity.search 'admin/opportunities/search', :action => 'search'
opportunity.filter 'admin/opportunities/filter', :action => 'filter'
end

map.with_options(:controller => 'admin/tasks') do |task|
task.complete 'admin/tasks/complete/:id', :action => 'complete'
task.filter 'admin/tasks/filter', :action => 'filter'
end

map.namespace :admin, :member => { :remove => :get } do |admin|
admin.resources :home
admin.resources :tasks, :has_many => :comments, :member => { :complete => :put }
admin.resources :comments
admin.resources :leads, :has_many => :comments, :collection => { :search => :get, :auto_complete => :post, :options => :get, :redraw => :post }, :member => { :convert => :get, :promote => :put, :reject => :put }
admin.resources :opportunities, :has_many => :comments, :collection => { :search => :get, :auto_complete => :post, :options => :get, :redraw => :post }
admin.resources :campaigns, :has_many => :comments, :collection => { :search => :get, :auto_complete => :post, :options => :get, :redraw => :post }
admin.resources :accounts, :has_many => :comments, :collection => { :search => :get, :auto_complete => :post, :options => :get, :redraw => :post }
admin.resources :contacts, :has_many => :comments, :collection => { :search => :get, :auto_complete => :post, :options => :get, :redraw => :post }
end
end
142 changes: 142 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Fat Free CRM
# Copyright (C) 2008-2009 by Michael Dvorkin
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
#------------------------------------------------------------------------------

# Default application settings to be loaded during installation:
#
# rake crm:settings:load
#
:tabs: [
{ :active : true, :text : "Dashboard", :url : { :controller : "/" } },
{ :active : false, :text : "Tasks", :url : { :controller : "tasks" } },
{ :active : false, :text : "Campaigns", :url : { :controller : "campaigns" } },
{ :active : false, :text : "Leads", :url : { :controller : "leads" } },
{ :active : false, :text : "Accounts", :url : { :controller : "accounts" } },
{ :active : false, :text : "Contacts", :url : { :controller : "contacts" } },
{ :active : false, :text : "Opportunities", :url : { :controller : "opportunities" } }
]

:admin_tabs: [
{ :active : true, :text : "Users", :url : { :controller : "admin/users" } },
{ :active : true, :text : "Settings", :url : { :controller : "admin/settings" } },
{ :active : true, :text : "Plugins", :url : { :controller : "admin/plugins" } }
]

# The following setting controls user signup. Possible values are:
# :allowed -- users can sign up and use the system once they have registered.
# :needs_approval -- users can sign up but must be approved before they can use the system.
# :not_allowed -- users can only be added by system administrator. This is the default.

:user_signup: :not_allowed

campaign_status:
:planned : Planned
:started : Started
:completed : Completed
:on_hold : On Hold
:called_off : Called Off

campaign_status_color:
:planned : palegreen
:started : paleturquoise
:completed : bisque
:on_hold : pink
:called_off : thistle

lead_status:
:new : New
:contacted : Contacted
:converted : Converted
:rejected : Rejected

lead_status_color:
:new : palegreen
:contacted : paleturquoise
:converted : bisque
:rejected : thistle

lead_source:
:campaign : Campaign
:cold_call : Cold Call
:conference : Conference
:online : Online Marketing
:referral : Referral
:self : Self Generated
:web : Web Site
:word_of_mouth : Word of Mouth
:other : Other

# Use array of hashes for now to preserve sort order. For Ruby 1.9 or later
# we can use regular hash since its insertion order will be preserved.
opportunity_stage: [
[ "Prospecting", :prospecting ],
[ "Analysis", :analysis ],
[ "Presentation", :presentation ],
[ "Proposal", :proposal ],
[ "Negotiation", :negotiation ],
[ "Final Review", :final_review ],
[ "Closed/Won", :won ],
[ "Closed/Lost", :lost ]
]

opportunity_stage_color:
:prospecting : lavender
:qualification : paleturquoise
:analysis : mistyrose
:presentation : wheat
:proposal : thistle
:negotiation : skyblue
:final_review : aquamarine
:won : lightgreen
:lost : pink

task_category:
:call : Call
:email : Email
:folowup : Follow-up
:lunch : Lunch
:meeting : Meeting
:money : Money
:presentation : Presentation
:trip : Trip

task_category_color:
:call : lavender
:email : paleturquoise
:folowup : mistyrose
:lunch : wheat
:meeting : thistle
:money : lightgreen
:presentation : aquamarine
:trip : skyblue

task_bucket: [
[ "Overdue" , :overdue ],
[ "As Soon As Possible", :due_asap ],
[ "Today", :due_today ],
[ "Tomorrow", :due_tomorrow ],
[ "This Week", :due_this_week ],
[ "Next Week", :due_next_week ],
[ "Sometime Later", :due_later ]
]

task_completed: [
[ "Today", :completed_today ],
[ "Yesterday", :completed_yesterday ],
[ "Last week", :completed_last_week ],
[ "This month", :completed_this_month ],
[ "Last month", :completed_last_month ]
]
89 changes: 10 additions & 79 deletions crm_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,86 +35,17 @@ class CrmExtension < Radiant::Extension
description "Describe your extension here"
url "http://yourwebsite.com/crm"

define_routes do |map|

map.create_lead 'leads/create_lead', :controller => 'leads', :action => 'create_lead'

map.with_options(:controller => 'admin/accounts') do |account|
account.options 'admin/accounts/options', :action => 'options'
account.redraw 'admin/accounts/redraw', :action => 'redraw'
account.search 'admin/accounts/search', :action => 'search'
end

map.with_options(:controller => 'admin/campaigns') do |campaign|
campaign.options 'admin/campaigns/options', :action => 'options'
campaign.redraw 'admin/campaigns/redraw', :action => 'redraw'
campaign.search 'admin/campaigns/search', :action => 'search'
campaign.filter 'admin/campaigns/filter', :action => 'filter'
end

map.with_options(:controller => 'admin/contacts') do |contact|
contact.options 'admin/contacts/options', :action => 'options'
contact.redraw 'admin/contacts/redraw', :action => 'redraw'
contact.search 'admin/contacts/convert', :action => 'convert'
end

map.with_options(:controller => 'admin/home') do |home|
home.toggle 'admin/home/toggle', :action => 'toggle'
home.options 'admin/home/options', :action => 'options'
home.redraw 'admin/home/redraw', :action => 'redraw'
home.toggle 'admin/home/toggle', :action => 'toggle'
home.timezone 'admin/home/timezone', :action => 'timezone'
end

map.with_options(:controller => 'admin/leads') do |lead|
lead.options 'admin/leads/options', :action => 'options'
lead.redraw 'admin/leads/redraw', :action => 'redraw'
lead.convert 'admin/leads/convert', :action => 'convert'
lead.reject 'admin/leads/reject', :action => 'reject'
lead.search 'admin/leads/search', :action => 'search'
lead.filter 'admin/leads/filter', :action => 'filter'
end

map.with_options(:controller => 'admin/opportunities') do |opportunity|
opportunity.options 'admin/opportunities/options', :action => 'options'
opportunity.redraw 'admin/opportunities/redraw', :action => 'redraw'
opportunity.search 'admin/opportunities/search', :action => 'search'
opportunity.filter 'admin/opportunities/filter', :action => 'filter'
end

map.with_options(:controller => 'admin/tasks') do |task|
task.complete 'admin/tasks/complete/:id', :action => 'complete'
task.filter 'admin/tasks/filter', :action => 'filter'
end

map.namespace :admin, :member => { :remove => :get } do |admin|
admin.resources :home
admin.resources :tasks, :has_many => :comments, :member => { :complete => :put }
admin.resources :comments
admin.resources :leads, :has_many => :comments, :collection => { :search => :get, :auto_complete => :post, :options => :get, :redraw => :post }, :member => { :convert => :get, :promote => :put, :reject => :put }

admin.resources :opportunities, :has_many => :comments, :collection => { :search => :get, :auto_complete => :post, :options => :get, :redraw => :post }

admin.resources :campaigns, :has_many => :comments, :collection => { :search => :get, :auto_complete => :post, :options => :get, :redraw => :post }

admin.resources :accounts, :has_many => :comments, :collection => { :search => :get, :auto_complete => :post, :options => :get, :redraw => :post }

admin.resources :contacts, :has_many => :comments, :collection => { :search => :get, :auto_complete => :post, :options => :get, :redraw => :post }
end

end

def activate
admin.nav << Radiant::AdminUI::NavTab.new(:crm, "CRM", [:crm, :free_crm])
#admin.nav[:crm] << admin.nav_item(:dashboard, "Dashboard", "/admin/home")
admin.nav[:crm] << admin.nav_item(:tasks, "Tasks", "/admin/tasks")
admin.nav[:crm] << admin.nav_item(:campaigns, "Campaigns", "/admin/campaigns")
admin.nav[:crm] << admin.nav_item(:leads, "Leads", "/admin/leads")
admin.nav[:crm] << admin.nav_item(:accounts, "Accounts", "/admin/accounts")
admin.nav[:crm] << admin.nav_item(:contacts, "Contacts", "/admin/contacts")
admin.nav[:crm] << admin.nav_item(:opportunites, "Opportunities", "/admin/opportunities")


tab 'CRM' do
#add_item "Dashboard", "/admin/home"
add_item "Tasks", "/admin/tasks"
add_item "Campaigns", "/admin/campaigns"
add_item "Leads", "/admin/leads"
add_item "Accounts", "/admin/accounts"
add_item "Contacts", "/admin/contacts"
add_item "Opportunities", "/admin/opportunities"
end
modify_classes
end

Expand Down
2 changes: 1 addition & 1 deletion lib/crm/helper_extensions/application_helper_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def inline(id, url, options = {})
#----------------------------------------------------------------------------
def link_to_inline(id, url, options = {})
text = options[:text] || id.to_s.titleize
text = (arrow_for(id) << "&nbsp;" << text) unless options[:plain]
text = (arrow_for(id) << " #{text}") unless options[:plain]
related = (options[:related] ? ", related: '#{options[:related]}'" : "")

link_to_remote(text,
Expand Down