helpdesk 0.0.14 → 0.0.20

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/helpdesk/admin/base_controller.rb +1 -1
  3. data/app/controllers/helpdesk/admin/faqs_controller.rb +7 -2
  4. data/app/controllers/helpdesk/admin/subscribers_controller.rb +8 -2
  5. data/app/controllers/helpdesk/admin/ticket_types_controller.rb +9 -3
  6. data/app/controllers/helpdesk/admin/tickets_controller.rb +10 -3
  7. data/app/controllers/helpdesk/application_controller.rb +2 -11
  8. data/app/controllers/helpdesk/dashboard_controller.rb +1 -1
  9. data/app/controllers/helpdesk/subscribers_controller.rb +8 -31
  10. data/app/controllers/helpdesk/tickets_controller.rb +14 -9
  11. data/app/helpers/helpdesk/admin/tickets_helper.rb +9 -0
  12. data/app/helpers/helpdesk/tickets_helper.rb +3 -0
  13. data/app/mailers/helpdesk/notifications_mailer.rb +2 -1
  14. data/app/models/helpdesk/comment.rb +2 -3
  15. data/app/models/helpdesk/faq.rb +1 -1
  16. data/app/models/helpdesk/ticket.rb +19 -23
  17. data/app/models/helpdesk/ticket_type.rb +4 -4
  18. data/app/views/helpdesk/admin/tickets/_form.html.haml +2 -2
  19. data/app/views/helpdesk/admin/tickets/_ticket.html.haml +2 -1
  20. data/app/views/helpdesk/admin/tickets/show.html.haml +2 -2
  21. data/app/views/helpdesk/faqs/index.html.haml +1 -1
  22. data/app/views/helpdesk/notifications_mailer/comment_by_helpdesk_confirmation.html.haml +15 -0
  23. data/app/views/helpdesk/notifications_mailer/comment_by_helpdesk_notification.html.haml +19 -0
  24. data/app/views/helpdesk/notifications_mailer/comment_by_requester_confirmation.html.haml +16 -0
  25. data/app/views/helpdesk/notifications_mailer/comment_by_requester_notification.html.haml +27 -0
  26. data/app/views/helpdesk/notifications_mailer/ticket_created_confirmation.html.haml +16 -0
  27. data/app/views/helpdesk/notifications_mailer/ticket_created_notification.html.haml +21 -0
  28. data/app/views/helpdesk/tickets/_form.html.haml +3 -3
  29. data/app/views/layouts/helpdesk/_topmenu.html.haml +16 -14
  30. data/app/views/layouts/helpdesk/_topuser.html.haml +13 -0
  31. data/app/views/layouts/mailer_layout.html.haml +20 -0
  32. data/config/initializers/globalize.rb +4 -4
  33. data/config/locales/helpdesk.en.yml +34 -4
  34. data/config/locales/helpdesk.pl.yml +38 -0
  35. data/config/routes.rb +1 -1
  36. data/db/migrate/20130521105605_create_helpdesk_ticket_types.rb +1 -0
  37. data/lib/generators/helpdesk/install_generator.rb +6 -7
  38. data/lib/generators/helpdesk/templates/README +14 -6
  39. data/lib/generators/helpdesk/templates/helpdesk.rb +3 -6
  40. data/lib/helpdesk.rb +0 -2
  41. data/lib/helpdesk/engine.rb +3 -1
  42. data/lib/helpdesk/version.rb +1 -1
  43. metadata +40 -26
  44. data/app/mailers/helpdesk/comment_by_requester_confirmation +0 -38
  45. data/app/views/helpdesk/notifications_mailer/comment_by_helpdesk_confirmation.pl.html.haml +0 -32
  46. data/app/views/helpdesk/notifications_mailer/comment_by_helpdesk_notification.pl.html.haml +0 -33
  47. data/app/views/helpdesk/notifications_mailer/comment_by_requester_confirmation.pl.html.haml +0 -32
  48. data/app/views/helpdesk/notifications_mailer/comment_by_requester_notification.pl.html.haml +0 -42
  49. data/app/views/helpdesk/notifications_mailer/ticket_created_confirmation.pl.html.haml +0 -34
  50. data/app/views/helpdesk/notifications_mailer/ticket_created_notification.pl.html.haml +0 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e94a6de04562f6bca0ed76c04992ad1b1103f3b9
4
- data.tar.gz: bb708658e68b3826ef85a0f4e7907d4c5ff197e6
3
+ metadata.gz: 3c06e151a2b309e2e7638027643791b305bea162
4
+ data.tar.gz: 64749502ac0b65a9084953eb41c527f0bc1799e5
5
5
  SHA512:
6
- metadata.gz: f477d1e08a738315940da0a43b82da6d0bdb065b44d3e2b25f9a35cbff1da17093a825c18d3e8b1c9f5d637311474e2a10219044896b348d857487bb461b93c2
7
- data.tar.gz: 0dbc29b8a24e193f53ed6db944444d60940f3309a841d8e868b540318bb80a21b395d469c585190bad6cf5c7595fc4d39e6e293fb90e146b876bc0bd458d9f95
6
+ metadata.gz: 1619c60b75d9f06027bc8bf47db24e1c7490dfc9e6fe6ee33ec8bd8c0e4e2ee43be875beb8a19cef1aca360b162de2032befcd5df289c25669bac681c4819f28
7
+ data.tar.gz: 29b82d23b895834502a5f524564e684a768082c98f1ebab815dd21aebef852a6659eed0f5d7a4fcf527153fd214158985c9e1d522ea17fa4910f3fbae9a171e8
@@ -14,7 +14,7 @@ module Helpdesk
14
14
 
15
15
  def authenticate_helpdesk_admin
16
16
  unless helpdesk_admin?
17
- redirect_to main_app.root_url
17
+ redirect_to main_app.root_url, notice:'You have no power here!'
18
18
  end
19
19
  end
20
20
 
@@ -52,7 +52,7 @@ class Helpdesk::Admin::FaqsController < Helpdesk::Admin::BaseController
52
52
  # POST /faqs
53
53
  # POST /faqs.json
54
54
  def create
55
- @faq = Helpdesk::Faq.new(params[:faq])
55
+ @faq = Helpdesk::Faq.new(faq_params)
56
56
 
57
57
  respond_to do |format|
58
58
  if @faq.save
@@ -71,7 +71,7 @@ class Helpdesk::Admin::FaqsController < Helpdesk::Admin::BaseController
71
71
  @faq = Helpdesk::Faq.find(params[:id])
72
72
 
73
73
  respond_to do |format|
74
- if @faq.update_attributes(params[:faq])
74
+ if @faq.update_attributes(faq_params)
75
75
  format.html { redirect_to admin_faqs_url, notice: 'Faq was successfully updated.' }
76
76
  format.json { head :no_content }
77
77
  else
@@ -92,4 +92,9 @@ class Helpdesk::Admin::FaqsController < Helpdesk::Admin::BaseController
92
92
  format.json { head :no_content }
93
93
  end
94
94
  end
95
+
96
+ private
97
+ def faq_params
98
+ params.require(:faq).permit(:active, :position, :title, :text, translations_attributes:[:id,:locale,:title,:text])
99
+ end
95
100
  end
@@ -9,7 +9,7 @@ class Helpdesk::Admin::SubscribersController < Helpdesk::Admin::BaseController
9
9
  end
10
10
 
11
11
  def create
12
- @subscriber = Helpdesk::Subscriber.new(params[:subscriber])
12
+ @subscriber = Helpdesk::Subscriber.new(subscriber_params)
13
13
  if @subscriber.save
14
14
  redirect_to admin_subscribers_path, notice: t('subscribers.created')
15
15
  else
@@ -26,7 +26,7 @@ class Helpdesk::Admin::SubscribersController < Helpdesk::Admin::BaseController
26
26
  def update
27
27
  @subscriber = Helpdesk::Subscriber.find(params[:id])
28
28
 
29
- if @subscriber.update_attributes(params[:subscriber])
29
+ if @subscriber.update_attributes(subscriber_params)
30
30
  redirect_to admin_subscribers_path, notice: 'Subscriber was successfully updated.'
31
31
  else
32
32
  render action: "edit"
@@ -40,4 +40,10 @@ class Helpdesk::Admin::SubscribersController < Helpdesk::Admin::BaseController
40
40
  @subscriber.destroy
41
41
  redirect_to root_path
42
42
  end
43
+
44
+ private
45
+
46
+ def subscriber_params
47
+ params.require(:subscriber).permit(:confirmed, :email, :hashcode, :lang, :name)
48
+ end
43
49
  end
@@ -17,7 +17,7 @@ class Helpdesk::Admin::TicketTypesController < Helpdesk::Admin::BaseController
17
17
  end
18
18
 
19
19
  def create
20
- @ticket_type = Helpdesk::TicketType.new(params[:ticket_type])
20
+ @ticket_type = Helpdesk::TicketType.new(ticket_type_params)
21
21
  if @ticket_type.save
22
22
  redirect_to admin_ticket_types_url, notice: 'Ticket type was successfully created.'
23
23
  else
@@ -27,7 +27,7 @@ class Helpdesk::Admin::TicketTypesController < Helpdesk::Admin::BaseController
27
27
 
28
28
  def update
29
29
  @ticket_type = Helpdesk::TicketType.find(params[:id])
30
- if @ticket_type.update_attributes(params[:ticket_type])
30
+ if @ticket_type.update_attributes(ticket_type_params)
31
31
  redirect_to admin_ticket_types_url, notice: 'Ticket type was successfully updated.'
32
32
  else
33
33
  render action: "edit"
@@ -43,4 +43,10 @@ class Helpdesk::Admin::TicketTypesController < Helpdesk::Admin::BaseController
43
43
  format.json { head :no_content }
44
44
  end
45
45
  end
46
- end
46
+
47
+ private
48
+
49
+ def ticket_type_params
50
+ params.require(:ticket_type).permit(:active,:position,:title,:tr_class. translations_attributes:[:title])
51
+ end
52
+ end
@@ -10,7 +10,7 @@ class Helpdesk::Admin::TicketsController < Helpdesk::Admin::BaseController
10
10
  elsif params[:tickets] == 'all'
11
11
  @tickets = Helpdesk::Ticket.scoped
12
12
  else
13
- @tickets = my_tickets.active.scoped
13
+ @tickets = my_tickets.active
14
14
  end
15
15
  @tickets = @tickets.includes(:requester)
16
16
  .includes(:assignee)
@@ -46,7 +46,7 @@ class Helpdesk::Admin::TicketsController < Helpdesk::Admin::BaseController
46
46
  end
47
47
 
48
48
  def create
49
- @ticket = Helpdesk::Ticket.new(params[:ticket])
49
+ @ticket = Helpdesk::Ticket.new(ticket_params)
50
50
  if @ticket.save
51
51
  redirect_to admin_ticket_path(@ticket)
52
52
  else
@@ -56,7 +56,7 @@ class Helpdesk::Admin::TicketsController < Helpdesk::Admin::BaseController
56
56
 
57
57
  def update
58
58
  @ticket = Helpdesk::Ticket.find(params[:id])
59
- if @ticket.update_attributes(params[:ticket])
59
+ if @ticket.update_attributes(ticket_params)
60
60
  unless @ticket.assignee
61
61
  @ticket.update_column(:assignee_id, helpdesk_user)
62
62
  end
@@ -66,4 +66,11 @@ class Helpdesk::Admin::TicketsController < Helpdesk::Admin::BaseController
66
66
  end
67
67
  end
68
68
 
69
+
70
+ private
71
+
72
+ def ticket_params
73
+ params.require(:ticket).permit(:status, :assignee_id,:ticket_type_id, :subject, :description,comments_attributes:[:author_id, :comment, :public])
74
+ end
75
+
69
76
  end
@@ -1,15 +1,13 @@
1
1
  module Helpdesk
2
- class ApplicationController < ApplicationController
2
+ class ApplicationController < ::ApplicationController
3
3
  before_filter :ensure_user, :if => Proc.new { Helpdesk.require_user }
4
4
 
5
5
  helper Helpdesk::Engine.helpers
6
6
 
7
-
8
-
9
7
  layout 'helpdesk/user'
10
8
 
11
9
  def ensure_user
12
- if !helpdesk_user
10
+ unless helpdesk_user
13
11
  redirect_to main_app.send(Helpdesk.sign_in_url)
14
12
  end
15
13
  end
@@ -18,12 +16,5 @@ module Helpdesk
18
16
  { :locale => I18n.locale}
19
17
  end
20
18
 
21
- # def helpdesk_admin?
22
- # helpdesk_user && (can? :manage, 'helpdesk')
23
- # end
24
- # helper_method :helpdesk_admin?
25
-
26
-
27
-
28
19
  end
29
20
  end
@@ -13,7 +13,7 @@ module Helpdesk
13
13
 
14
14
 
15
15
  def my_tickets
16
- @my_tickets = Ticket
16
+ @my_tickets = Helpdesk::Ticket
17
17
  .includes(:comments=>[:author])
18
18
  .includes(:requester)
19
19
  .includes(:assignee)
@@ -1,29 +1,7 @@
1
1
  module Helpdesk
2
2
  class SubscribersController < Helpdesk::ApplicationController
3
- # GET /subscribers
4
- # GET /subscribers.json
5
- def index
6
- @subscribers = Subscriber.all
7
3
 
8
- respond_to do |format|
9
- format.html # index.html.erb
10
- format.json { render json: @subscribers }
11
- end
12
- end
13
-
14
- # GET /subscribers/1
15
- # GET /subscribers/1.json
16
- def show
17
- @subscriber = Subscriber.find(params[:id])
18
-
19
- respond_to do |format|
20
- format.html # show.html.erb
21
- format.json { render json: @subscriber }
22
- end
23
- end
24
4
 
25
- # GET /subscribers/new
26
- # GET /subscribers/new.json
27
5
  def new
28
6
  @subscriber = Subscriber.new
29
7
 
@@ -33,15 +11,8 @@ module Helpdesk
33
11
  end
34
12
  end
35
13
 
36
- # GET /subscribers/1/edit
37
- def edit
38
- @subscriber = Subscriber.find(params[:id])
39
- end
40
-
41
- # POST /subscribers
42
- # POST /subscribers.json
43
14
  def create
44
- @subscriber = Subscriber.new(params[:subscriber])
15
+ @subscriber = Subscriber.new(subscriber_params)
45
16
 
46
17
  respond_to do |format|
47
18
  if @subscriber.save
@@ -60,7 +31,7 @@ module Helpdesk
60
31
  @subscriber = Subscriber.find(params[:id])
61
32
 
62
33
  respond_to do |format|
63
- if @subscriber.update_attributes(params[:subscriber])
34
+ if @subscriber.update_attributes(subscriber_params)
64
35
  format.html { redirect_to @subscriber, notice: 'Subscriber was successfully updated.' }
65
36
  format.json { head :no_content }
66
37
  else
@@ -81,5 +52,11 @@ module Helpdesk
81
52
  format.json { head :no_content }
82
53
  end
83
54
  end
55
+
56
+ private
57
+
58
+ def subscriber_params
59
+ params.require(:subscriber).permit(:email,:lang, :name)
60
+ end
84
61
  end
85
62
  end
@@ -1,5 +1,8 @@
1
1
  module Helpdesk
2
2
  class TicketsController < Helpdesk::ApplicationController
3
+
4
+ helper TicketsHelper
5
+
3
6
  # GET /tickets
4
7
  # GET /tickets.json
5
8
  def index
@@ -43,15 +46,8 @@ module Helpdesk
43
46
  end
44
47
  end
45
48
 
46
- # GET /tickets/1/edit
47
- def edit
48
- @ticket = Helpdesk::Ticket.find(params[:id])
49
- end
50
-
51
- # POST /tickets
52
- # POST /tickets.json
53
49
  def create
54
- @ticket = Helpdesk::Ticket.new(params[:ticket])
50
+ @ticket = Helpdesk::Ticket.new(ticket_params)
55
51
  @ticket.requester = helpdesk_user
56
52
  @ticket.status = Helpdesk::Ticket::STATUSES[0][0]
57
53
 
@@ -72,7 +68,9 @@ module Helpdesk
72
68
  @ticket = Helpdesk::Ticket.find(params[:id])
73
69
 
74
70
  respond_to do |format|
75
- if @ticket.update_attributes(params[:ticket])
71
+ if @ticket.update_attributes(ticket_params)
72
+ puts ticket_params
73
+ puts paramsp
76
74
  format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }
77
75
  format.json { head :no_content }
78
76
  else
@@ -82,5 +80,12 @@ module Helpdesk
82
80
  end
83
81
  end
84
82
 
83
+
84
+ private
85
+
86
+ def ticket_params
87
+ params.require(:ticket).permit( :ticket_type_id, :subject, :description,comments_attributes:[:author_id, :comment, :public])
88
+ end
89
+
85
90
  end
86
91
  end
@@ -1,4 +1,13 @@
1
1
  module Helpdesk
2
2
  module Admin::TicketsHelper
3
+ def humanize_with_i18n(string, scope = [])
4
+ I18n.t string, scope: scope, default: string.humanize
5
+ end
6
+
7
+ # The method prefix tells me that this should be in an object
8
+ # But it doesn't belong in our model, does it?
9
+ def tickets_statuses_for_select
10
+ Helpdesk::Ticket::STATUSES.map { |s| [humanize_with_i18n(s[0].to_s,'helpdesk.tickets.statuses'),s[0]] }
11
+ end
3
12
  end
4
13
  end
@@ -1,4 +1,7 @@
1
1
  module Helpdesk
2
2
  module TicketsHelper
3
+
4
+
5
+
3
6
  end
4
7
  end
@@ -1,5 +1,7 @@
1
1
  class Helpdesk::NotificationsMailer < ActionMailer::Base
2
2
 
3
+ layout 'mailer_layout'
4
+
3
5
  def ticket_created_notification(ticket)
4
6
  @ticket = ticket
5
7
  mail(:subject=>"#{Helpdesk.helpdesk_name} | #{ticket.subject}",
@@ -12,7 +14,6 @@ class Helpdesk::NotificationsMailer < ActionMailer::Base
12
14
  :to => ticket.requester.email)
13
15
  end
14
16
 
15
-
16
17
  def comment_by_requester_notification(comment)
17
18
  @comment = comment
18
19
  mail(:subject=>"#{Helpdesk.helpdesk_name} | #{comment.ticket.subject}",
@@ -1,11 +1,10 @@
1
1
  module Helpdesk
2
2
  class Comment < ActiveRecord::Base
3
- attr_accessible :author_id, :comment, :public, :ticket_id
4
3
  belongs_to :author, :class_name => Helpdesk.user_class.to_s
5
4
  belongs_to :ticket
6
5
 
7
- default_scope includes(:author).order('id ASC')
8
- scope :pub, where('public = ?',true)
6
+ default_scope -> {includes(:author).order('id ASC')}
7
+ scope :pub, -> { where(:public, true)}
9
8
 
10
9
  after_create :send_email
11
10
  after_create :check_reopen
@@ -2,7 +2,7 @@ module Helpdesk
2
2
  class Faq < ActiveRecord::Base
3
3
  translates :title, :text
4
4
  accepts_nested_attributes_for :translations
5
- attr_accessible :active, :position, :text, :title,:translations_attributes
5
+ #attr_accessible :active, :position, :text, :title,:translations_attributes
6
6
 
7
7
  default_scope order('position ASC').includes(:translations)
8
8
 
@@ -2,41 +2,34 @@ module Helpdesk
2
2
  class Ticket < ActiveRecord::Base
3
3
 
4
4
  STATUSES = [
5
- [ :new, 'Nowe:', 'label-important',3],
6
- [ :open, 'Otwarte:', 'label-warning',2],
7
- [ :waiting, 'Otwarte: oczekujące', 'label-info',2],
8
- [ :solved, 'Zamknięte: problem rozwiązany','label-success',0],
9
- [ :not_fixable, 'Zamknięte: nienaprawialne','label-inverse',-1],
10
- [ :unreachable, 'Zamknięte: klient nieosiągalny','label-inverse',-1],
11
- [ :bug, 'Zamknięte: Przeniesione do bug tracker\'a','label-inverse',-1]
5
+ [ :new, 'label-primary',3],
6
+ [ :open, 'label-warning',2],
7
+ [ :waiting, 'label-info',2],
8
+ [ :solved, 'label-success',0],
9
+ [ :not_fixable, 'label-default',-1],
10
+ [ :unreachable, 'label-default',-1],
11
+ [ :bug, 'label-default',-1]
12
12
  ]
13
- STATUS_OPTIONS = STATUSES.map { |i| [i[1], i[0]] }
14
13
  STATUS_BY_KEY = Hash[*STATUSES.map { |i| [i[0], i[1]] }.flatten]
15
- STATUS_CLASS_BY_KEY= Hash[*STATUSES.map { |i| [i[0], i[2]] }.flatten]
16
- STATUS_STATUS_BY_KEY= Hash[*STATUSES.map { |i| [i[0], i[3]] }.flatten]
17
- OPEN_STATUSES_KEYS = STATUSES.map { |i| (i[3]>0 ? i[0] : nil)}.compact
18
-
19
- attr_accessible :subject, :description
20
- attr_accessible :requester_id, :assignee_id, :status, :comments_attributes,:ticket_type_id
21
-
22
-
14
+ STATUS_CLASS_BY_KEY= Hash[*STATUSES.map { |i| [i[0], i[1]] }.flatten]
15
+ STATUS_STATUS_BY_KEY= Hash[*STATUSES.map { |i| [i[0], i[2]] }.flatten]
16
+ OPEN_STATUSES_KEYS = STATUSES.map { |i| (i[2]>0 ? i[0] : nil)}.compact
23
17
 
24
18
 
25
19
  belongs_to :requester, :class_name => Helpdesk.user_class.to_s
26
20
  belongs_to :assignee, :class_name => Helpdesk.user_class.to_s
27
21
  belongs_to :ticket_type, :class_name => Helpdesk::TicketType
28
- has_many :comments, :order => "created_at DESC",:dependent => :destroy
29
-
22
+ has_many :comments, -> {order("created_at DESC")},:dependent => :destroy
30
23
 
31
24
 
32
- scope :active, where('status IN (?) ',OPEN_STATUSES_KEYS)
33
- scope :unassigned, where('status IN (?) ',OPEN_STATUSES_KEYS).where('assignee_id is null')
34
- scope :closed, where('status NOT IN (?)',OPEN_STATUSES_KEYS)
35
- default_scope includes(:comments=>[:author])
25
+ scope :active, -> {where('status IN (?) ',OPEN_STATUSES_KEYS)}
26
+ scope :unassigned, -> {where('status IN (?) ',OPEN_STATUSES_KEYS).where('assignee_id is null')}
27
+ scope :closed, -> { where('status NOT IN (?)',OPEN_STATUSES_KEYS)}
28
+ default_scope -> { includes(:comments=>[:author])
36
29
  .includes(:requester)
37
30
  .includes(:assignee)
38
31
  .includes(:ticket_type)
39
- .order('id DESC')
32
+ .order('id DESC')}
40
33
 
41
34
  validates_presence_of :description,:requester_id,:ticket_type_id
42
35
 
@@ -85,5 +78,8 @@ module Helpdesk
85
78
  end
86
79
  end
87
80
 
81
+
82
+
83
+
88
84
  end
89
85
  end
@@ -2,12 +2,12 @@ module Helpdesk
2
2
  class TicketType < ActiveRecord::Base
3
3
  translates :title
4
4
  accepts_nested_attributes_for :translations
5
- attr_accessible :active, :position,:title,:translations_attributes,:tr_class
5
+ #attr_accessible :active, :position,:title,:translations_attributes,:tr_class
6
6
 
7
- default_scope order('position ASC')
7
+ default_scope ->{order('position ASC')}
8
8
 
9
- scope :active, where('active = ? ', true)
10
- scope :inactive, where('active = ? ', false)
9
+ scope :active, -> {where(:active, true)}
10
+ scope :inactive, -> {where(:active, false)}
11
11
 
12
12
  end
13
13
  end