helpdesk 0.0.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.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +28 -0
  4. data/app/assets/javascripts/helpdesk/admin/dashboard.js +2 -0
  5. data/app/assets/javascripts/helpdesk/admin/tickets.js +20 -0
  6. data/app/assets/javascripts/helpdesk/application.js +19 -0
  7. data/app/assets/javascripts/helpdesk/ckeditor.js +11 -0
  8. data/app/assets/javascripts/helpdesk/dashboard.js +2 -0
  9. data/app/assets/javascripts/helpdesk/faqs.js +2 -0
  10. data/app/assets/javascripts/helpdesk/subscribers.js +2 -0
  11. data/app/assets/stylesheets/helpdesk/admin/bootstrap_overrides.css +8 -0
  12. data/app/assets/stylesheets/helpdesk/admin/dashboard.css +4 -0
  13. data/app/assets/stylesheets/helpdesk/admin/tickets.css +44 -0
  14. data/app/assets/stylesheets/helpdesk/admin.css +8 -0
  15. data/app/assets/stylesheets/helpdesk/application.css +16 -0
  16. data/app/assets/stylesheets/helpdesk/dashboard.css +4 -0
  17. data/app/assets/stylesheets/helpdesk/faqs.css.scss +3 -0
  18. data/app/assets/stylesheets/helpdesk/imports.css.sass +0 -0
  19. data/app/assets/stylesheets/helpdesk/subscribers.css.scss +3 -0
  20. data/app/assets/stylesheets/helpdesk/tickets.css.sass +49 -0
  21. data/app/controllers/helpdesk/admin/base_controller.rb +32 -0
  22. data/app/controllers/helpdesk/admin/dashboard_controller.rb +6 -0
  23. data/app/controllers/helpdesk/admin/faqs_controller.rb +100 -0
  24. data/app/controllers/helpdesk/admin/subscribers_controller.rb +49 -0
  25. data/app/controllers/helpdesk/admin/ticket_types_controller.rb +52 -0
  26. data/app/controllers/helpdesk/admin/tickets_controller.rb +76 -0
  27. data/app/controllers/helpdesk/application_controller.rb +20 -0
  28. data/app/controllers/helpdesk/dashboard_controller.rb +26 -0
  29. data/app/controllers/helpdesk/faqs_controller.rb +7 -0
  30. data/app/controllers/helpdesk/subscribers_controller.rb +62 -0
  31. data/app/controllers/helpdesk/tickets_controller.rb +91 -0
  32. data/app/helpers/helpdesk/admin/dashboard_helper.rb +6 -0
  33. data/app/helpers/helpdesk/admin/tickets_helper.rb +13 -0
  34. data/app/helpers/helpdesk/dashboard_helper.rb +4 -0
  35. data/app/helpers/helpdesk/faqs_helper.rb +4 -0
  36. data/app/helpers/helpdesk/helpdesk_helper.rb +59 -0
  37. data/app/helpers/helpdesk/subscribers_helper.rb +4 -0
  38. data/app/helpers/helpdesk/tickets_helper.rb +7 -0
  39. data/app/mailers/helpdesk/notifications_mailer.rb +42 -0
  40. data/app/models/helpdesk/comment.rb +31 -0
  41. data/app/models/helpdesk/faq.rb +12 -0
  42. data/app/models/helpdesk/subscriber.rb +10 -0
  43. data/app/models/helpdesk/ticket.rb +85 -0
  44. data/app/models/helpdesk/ticket_type.rb +13 -0
  45. data/app/views/helpdesk/admin/dashboard/index.html.erb +2 -0
  46. data/app/views/helpdesk/admin/faqs/_form.html.haml +20 -0
  47. data/app/views/helpdesk/admin/faqs/_menu.html.haml +9 -0
  48. data/app/views/helpdesk/admin/faqs/edit.html.haml +11 -0
  49. data/app/views/helpdesk/admin/faqs/index.html.haml +59 -0
  50. data/app/views/helpdesk/admin/faqs/new.html.haml +7 -0
  51. data/app/views/helpdesk/admin/faqs/show.html.haml +19 -0
  52. data/app/views/helpdesk/admin/subscribers/_form.html.haml +12 -0
  53. data/app/views/helpdesk/admin/subscribers/_menu.html.haml +9 -0
  54. data/app/views/helpdesk/admin/subscribers/edit.html.haml +10 -0
  55. data/app/views/helpdesk/admin/subscribers/index.html.haml +31 -0
  56. data/app/views/helpdesk/admin/subscribers/new.html.haml +7 -0
  57. data/app/views/helpdesk/admin/ticket_types/_form.html.haml +20 -0
  58. data/app/views/helpdesk/admin/ticket_types/_menu.html.haml +11 -0
  59. data/app/views/helpdesk/admin/ticket_types/edit.html.haml +10 -0
  60. data/app/views/helpdesk/admin/ticket_types/index.html.haml +28 -0
  61. data/app/views/helpdesk/admin/ticket_types/new.html.haml +8 -0
  62. data/app/views/helpdesk/admin/ticket_types/show.html.haml +11 -0
  63. data/app/views/helpdesk/admin/tickets/_form.html.haml +23 -0
  64. data/app/views/helpdesk/admin/tickets/_menu.html.haml +17 -0
  65. data/app/views/helpdesk/admin/tickets/_ticket.html.haml +59 -0
  66. data/app/views/helpdesk/admin/tickets/edit.html.haml +30 -0
  67. data/app/views/helpdesk/admin/tickets/index.html.haml +42 -0
  68. data/app/views/helpdesk/admin/tickets/list.html.haml +18 -0
  69. data/app/views/helpdesk/admin/tickets/new.html.haml +4 -0
  70. data/app/views/helpdesk/admin/tickets/show.html.haml +36 -0
  71. data/app/views/helpdesk/dashboard/index.html.erb +3 -0
  72. data/app/views/helpdesk/faqs/index.html.haml +20 -0
  73. data/app/views/helpdesk/notifications_mailer/comment_by_helpdesk_confirmation.html.haml +15 -0
  74. data/app/views/helpdesk/notifications_mailer/comment_by_helpdesk_notification.html.haml +19 -0
  75. data/app/views/helpdesk/notifications_mailer/comment_by_requester_confirmation.html.haml +16 -0
  76. data/app/views/helpdesk/notifications_mailer/comment_by_requester_notification.html.haml +27 -0
  77. data/app/views/helpdesk/notifications_mailer/ticket_created_confirmation.html.haml +16 -0
  78. data/app/views/helpdesk/notifications_mailer/ticket_created_notification.html.haml +21 -0
  79. data/app/views/helpdesk/subscribers/_form.html.erb +37 -0
  80. data/app/views/helpdesk/subscribers/edit.html.erb +6 -0
  81. data/app/views/helpdesk/subscribers/index.html.erb +31 -0
  82. data/app/views/helpdesk/subscribers/new.html.erb +5 -0
  83. data/app/views/helpdesk/subscribers/show.html.erb +30 -0
  84. data/app/views/helpdesk/tickets/_form.html.haml +36 -0
  85. data/app/views/helpdesk/tickets/_menu.html.haml +10 -0
  86. data/app/views/helpdesk/tickets/_ticket.html.haml +54 -0
  87. data/app/views/helpdesk/tickets/index.html.haml +16 -0
  88. data/app/views/helpdesk/tickets/new.html.haml +4 -0
  89. data/app/views/helpdesk/tickets/show.html.haml +38 -0
  90. data/app/views/layouts/helpdesk/_topmenu.html.haml +28 -0
  91. data/app/views/layouts/helpdesk/_topuser.html.haml +32 -0
  92. data/app/views/layouts/helpdesk/admin.html.haml +35 -0
  93. data/app/views/layouts/helpdesk/user.html.haml +33 -0
  94. data/app/views/layouts/mailer_layout.html.haml +20 -0
  95. data/config/initializers/globalize.rb +4 -0
  96. data/config/initializers/simple_form.rb +117 -0
  97. data/config/locales/helpdesk.en.yml +111 -0
  98. data/config/locales/helpdesk.pl.yml +119 -0
  99. data/config/locales/helpdesk_routes.yml +6 -0
  100. data/config/locales/simple_form.en.yml +24 -0
  101. data/config/locales/simple_form.pl.yml +15 -0
  102. data/config/routes.rb +22 -0
  103. data/db/migrate/20120420104051_create_helpdesk_tickets.rb +14 -0
  104. data/db/migrate/20120423113938_create_helpdesk_comments.rb +12 -0
  105. data/db/migrate/20130521105605_create_helpdesk_ticket_types.rb +36 -0
  106. data/db/migrate/20130522085614_create_helpdesk_faqs.rb +17 -0
  107. data/db/migrate/20130522090420_create_helpdesk_subscribers.rb +13 -0
  108. data/lib/generators/helpdesk/install_generator.rb +35 -0
  109. data/lib/generators/helpdesk/templates/README +31 -0
  110. data/lib/generators/helpdesk/templates/helpdesk.rb +33 -0
  111. data/lib/helpdesk/engine.rb +29 -0
  112. data/lib/helpdesk/version.rb +3 -0
  113. data/lib/helpdesk.rb +39 -0
  114. data/lib/tasks/prepare_ci_env.rake +27 -0
  115. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  116. metadata +508 -0
@@ -0,0 +1,62 @@
1
+ module Helpdesk
2
+ class SubscribersController < Helpdesk::ApplicationController
3
+
4
+
5
+ def new
6
+ @subscriber = Subscriber.new
7
+
8
+ respond_to do |format|
9
+ format.html # new.html.erb
10
+ format.json { render json: @subscriber }
11
+ end
12
+ end
13
+
14
+ def create
15
+ @subscriber = Subscriber.new(subscriber_params)
16
+
17
+ respond_to do |format|
18
+ if @subscriber.save
19
+ format.html { redirect_to @subscriber, notice: 'Subscriber was successfully created.' }
20
+ format.json { render json: @subscriber, status: :created, location: @subscriber }
21
+ else
22
+ format.html { render action: "new" }
23
+ format.json { render json: @subscriber.errors, status: :unprocessable_entity }
24
+ end
25
+ end
26
+ end
27
+
28
+ # PUT /subscribers/1
29
+ # PUT /subscribers/1.json
30
+ def update
31
+ @subscriber = Subscriber.find(params[:id])
32
+
33
+ respond_to do |format|
34
+ if @subscriber.update_attributes(subscriber_params)
35
+ format.html { redirect_to @subscriber, notice: 'Subscriber was successfully updated.' }
36
+ format.json { head :no_content }
37
+ else
38
+ format.html { render action: "edit" }
39
+ format.json { render json: @subscriber.errors, status: :unprocessable_entity }
40
+ end
41
+ end
42
+ end
43
+
44
+ # DELETE /subscribers/1
45
+ # DELETE /subscribers/1.json
46
+ def destroy
47
+ @subscriber = Subscriber.find(params[:id])
48
+ @subscriber.destroy
49
+
50
+ respond_to do |format|
51
+ format.html { redirect_to subscribers_url }
52
+ format.json { head :no_content }
53
+ end
54
+ end
55
+
56
+ private
57
+
58
+ def subscriber_params
59
+ params.require(:subscriber).permit(:email,:lang, :name)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,91 @@
1
+ module Helpdesk
2
+ class TicketsController < Helpdesk::ApplicationController
3
+
4
+ helper TicketsHelper
5
+
6
+ # GET /tickets
7
+ # GET /tickets.json
8
+ def index
9
+ if params[:tickets] == 'closed'
10
+ @tickets = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).closed.page(params[:page])
11
+ @tickets_count = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).active.count
12
+ else
13
+ @tickets = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).active.page(params[:page])
14
+ @tickets_count = @tickets.size
15
+ end
16
+
17
+
18
+ respond_to do |format|
19
+ format.html # index.html.erb
20
+ format.json { render json: @tickets }
21
+ end
22
+ end
23
+
24
+ # GET /tickets/1
25
+ # GET /tickets/1.json
26
+ def show
27
+ @tickets_count = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).active.count
28
+ @ticket = Helpdesk::Ticket.find(params[:id])
29
+
30
+ respond_to do |format|
31
+ format.html # show.html.erb
32
+ format.json { render json: @ticket }
33
+ end
34
+ end
35
+
36
+ # GET /tickets/new
37
+ # GET /tickets/new.json
38
+ def new
39
+ @tickets_count = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).active.count
40
+ @ticket = Helpdesk::Ticket.new
41
+ @ticket.status = Helpdesk::Ticket::STATUSES[0][0]
42
+
43
+ respond_to do |format|
44
+ format.html # new.html.erb
45
+ format.json { render json: @ticket }
46
+ end
47
+ end
48
+
49
+ def create
50
+ @ticket = Helpdesk::Ticket.new(ticket_params)
51
+ @ticket.requester = helpdesk_user
52
+ @ticket.status = Helpdesk::Ticket::STATUSES[0][0]
53
+
54
+ respond_to do |format|
55
+ if @ticket.save
56
+ format.html { redirect_to tickets_url, notice: 'Ticket was successfully created.' }
57
+ format.json { render json: @ticket, status: :created, location: @ticket }
58
+ else
59
+ format.html { render action: "new" }
60
+ format.json { render json: @ticket.errors, status: :unprocessable_entity }
61
+ end
62
+ end
63
+ end
64
+
65
+ # PUT /tickets/1
66
+ # PUT /tickets/1.json
67
+ def update
68
+ @ticket = Helpdesk::Ticket.find(params[:id])
69
+
70
+ respond_to do |format|
71
+ if @ticket.update_attributes(ticket_params)
72
+ puts ticket_params
73
+ puts paramsp
74
+ format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }
75
+ format.json { head :no_content }
76
+ else
77
+ format.html { render action: "edit" }
78
+ format.json { render json: @ticket.errors, status: :unprocessable_entity }
79
+ end
80
+ end
81
+ end
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
+
90
+ end
91
+ end
@@ -0,0 +1,6 @@
1
+ module Helpdesk
2
+ module Admin
3
+ module DashboardHelper
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ module Helpdesk
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
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ module Helpdesk
2
+ module DashboardHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Helpdesk
2
+ module FaqsHelper
3
+ end
4
+ end
@@ -0,0 +1,59 @@
1
+ module Helpdesk
2
+ module HelpdeskHelper
3
+
4
+
5
+ def menu_left(title,&block)
6
+ panel_menu(title,'default',&block)
7
+ end
8
+
9
+
10
+ def panel_menu(title,type,&block)
11
+ content_tag(:div,class: "panel panel-#{type}") do
12
+ content_tag(:div ,class: 'panel-heading') do
13
+ content_tag(:h3 ,title,class:'panel-title')
14
+ end +
15
+ content_tag( :ul, class: 'nav nav-pills nav-stacked ') do
16
+ capture(&block)
17
+ end
18
+ end
19
+ end
20
+
21
+
22
+ def panel(title,type,&block)
23
+ content_tag(:div,class: "panel panel-#{type}") do
24
+ content_tag(:div ,class: 'panel-heading') do
25
+ content_tag(:h3 ,title,class:'panel-title')
26
+ end +
27
+ content_tag( :div, class: 'panel-body') do
28
+ capture(&block)
29
+ end
30
+ end
31
+ end
32
+
33
+
34
+ def menu_li(lbl, path, *args)
35
+ options = args.extract_options!
36
+ (options[:class].nil? ? options.merge!(:class => "active") : options[:class] += " active" ) if url_for(path) == request.fullpath
37
+ content_tag(:li, link_to(lbl, path), options)
38
+ end
39
+
40
+ def status_label(lbl,cls)
41
+ content_tag(:span, class: "label #{cls}") do
42
+ lbl
43
+ end
44
+ end
45
+
46
+ def badge(num,css='pull-right')
47
+ raw("<span class=\"badge #{css}\">#{num}</span> ")
48
+ end
49
+
50
+ def ico(name)
51
+ raw("<i class=\"glyphicon glyphicon-#{name}\"></i> ")
52
+ end
53
+
54
+ def parent_layout(layout)
55
+ @view_flow.set(:layout,output_buffer)
56
+ self.output_buffer = render(:file => "layouts/#{layout}")
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,4 @@
1
+ module Helpdesk
2
+ module SubscribersHelper
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module Helpdesk
2
+ module TicketsHelper
3
+
4
+
5
+
6
+ end
7
+ end
@@ -0,0 +1,42 @@
1
+ class Helpdesk::NotificationsMailer < ActionMailer::Base
2
+
3
+ layout 'mailer_layout'
4
+
5
+ def ticket_created_notification(ticket)
6
+ @ticket = ticket
7
+ mail(:subject=>"#{Helpdesk.helpdesk_name} | #{ticket.subject}",
8
+ :to => Helpdesk.email)
9
+ end
10
+
11
+ def ticket_created_confirmation(ticket)
12
+ @ticket = ticket
13
+ mail(:subject=>"#{Helpdesk.helpdesk_name} | #{ticket.subject}",
14
+ :to => ticket.requester.email)
15
+ end
16
+
17
+ def comment_by_requester_notification(comment)
18
+ @comment = comment
19
+ mail(:subject=>"#{Helpdesk.helpdesk_name} | #{comment.ticket.subject}",
20
+ :to => Helpdesk.email)
21
+ end
22
+
23
+ def comment_by_requester_confirmation(comment)
24
+ @comment = comment
25
+ mail(:subject=>"#{Helpdesk.helpdesk_name} | #{comment.ticket.subject}",
26
+ :to => comment.ticket.requester.email)
27
+ end
28
+
29
+
30
+ def comment_by_helpdesk_notification(comment)
31
+ @comment = comment
32
+ mail(:subject=>"#{Helpdesk.helpdesk_name} | #{comment.ticket.subject}",
33
+ :to => comment.ticket.requester.email)
34
+ end
35
+
36
+ def comment_by_helpdesk_confirmation(comment)
37
+ @comment = comment
38
+ mail(:subject=>"#{t('helpdesk.name')} | #{comment.ticket.subject}",
39
+ :to => Helpdesk.email)
40
+ end
41
+
42
+ end
@@ -0,0 +1,31 @@
1
+ module Helpdesk
2
+ class Comment < ActiveRecord::Base
3
+ belongs_to :author, :class_name => Helpdesk.user_class.to_s
4
+ belongs_to :ticket
5
+
6
+ default_scope -> {includes(:author).order('id ASC')}
7
+ scope :pub, -> { where(:public, true)}
8
+
9
+ after_create :send_email
10
+ after_create :check_reopen
11
+
12
+ def check_reopen
13
+ if ticket.requester == author
14
+ ticket.update_column(:status ,:waiting)
15
+ end
16
+ end
17
+
18
+
19
+ def send_email
20
+ if self.public?
21
+ if ticket.requester == author
22
+ Helpdesk::NotificationsMailer.comment_by_requester_notification(self).deliver if ticket.requester
23
+ Helpdesk::NotificationsMailer.comment_by_requester_confirmation(self).deliver if Helpdesk.send_confirmation_emails
24
+ else
25
+ Helpdesk::NotificationsMailer.comment_by_helpdesk_notification(self).deliver if ticket.requester
26
+ Helpdesk::NotificationsMailer.comment_by_helpdesk_confirmation(self).deliver if Helpdesk.send_confirmation_emails
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,12 @@
1
+ module Helpdesk
2
+ class Faq < ActiveRecord::Base
3
+ translates :title, :text
4
+ accepts_nested_attributes_for :translations
5
+ #attr_accessible :active, :position, :text, :title,:translations_attributes
6
+
7
+ default_scope order('position ASC').includes(:translations)
8
+
9
+ scope :active, where('active = ? ', true)
10
+ scope :inactive, where('active = ? ', false)
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ module Helpdesk
2
+ class Subscriber < ActiveRecord::Base
3
+ attr_accessible :confirmed, :email, :hashcode, :lang, :name
4
+ scope :confirmed, where('confirmed = ? ',true)
5
+ scope :unconfirmed, where('confirmed = ? ',false)
6
+
7
+ validates_presence_of :email
8
+
9
+ end
10
+ end
@@ -0,0 +1,85 @@
1
+ module Helpdesk
2
+ class Ticket < ActiveRecord::Base
3
+
4
+ STATUSES = [
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
+ ]
13
+ STATUS_BY_KEY = Hash[*STATUSES.map { |i| [i[0], i[1]] }.flatten]
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
17
+
18
+
19
+ belongs_to :requester, :class_name => Helpdesk.user_class.to_s
20
+ belongs_to :assignee, :class_name => Helpdesk.user_class.to_s
21
+ belongs_to :ticket_type, :class_name => Helpdesk::TicketType
22
+ has_many :comments, -> {order("created_at DESC")},:dependent => :destroy
23
+
24
+
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])
29
+ .includes(:requester)
30
+ .includes(:assignee)
31
+ .includes(:ticket_type)
32
+ .order('id DESC')}
33
+
34
+ validates_presence_of :description,:requester_id,:ticket_type_id
35
+
36
+ accepts_nested_attributes_for :comments,:reject_if => lambda { |a| a[:comment].blank? }
37
+
38
+
39
+ before_create :set_subject
40
+ before_create :set_status
41
+ after_create :send_email
42
+
43
+ def set_status
44
+ if self.status.blank?
45
+ self.status = :new
46
+ end
47
+ end
48
+
49
+ def set_subject
50
+ if self.created_at.nil?
51
+ time = Time.now
52
+ else
53
+ time = self.created_at
54
+ end
55
+
56
+ new_subject = "#{sprintf '%02d',time.year-2000}#{sprintf '%02d',time.month}#{sprintf '%02d',time.day}"
57
+
58
+ day_num = Helpdesk::Ticket.where(created_at: Date.today.beginning_of_day..Date.today.end_of_day).count+1
59
+ new_subject += "-#{sprintf '%04d',day_num}: "
60
+ self.subject = new_subject + subject.to_s
61
+ self.subject.strip!
62
+ end
63
+
64
+
65
+
66
+ def send_email
67
+ Helpdesk::NotificationsMailer.ticket_created_notification(self).deliver
68
+ unless requester.email.empty?
69
+ Helpdesk::NotificationsMailer.ticket_created_confirmation(self).deliver if Helpdesk.send_confirmation_emails
70
+ end
71
+ end
72
+
73
+ def open?
74
+ if self.status.blank? || STATUS_STATUS_BY_KEY[self.status.to_sym] > 0
75
+ true
76
+ else
77
+ false
78
+ end
79
+ end
80
+
81
+
82
+
83
+
84
+ end
85
+ end
@@ -0,0 +1,13 @@
1
+ module Helpdesk
2
+ class TicketType < ActiveRecord::Base
3
+ translates :title
4
+ accepts_nested_attributes_for :translations
5
+ #attr_accessible :active, :position,:title,:translations_attributes,:tr_class
6
+
7
+ default_scope ->{order('position ASC')}
8
+
9
+ scope :active, -> {where(:active, true)}
10
+ scope :inactive, -> {where(:active, false)}
11
+
12
+ end
13
+ end
@@ -0,0 +1,2 @@
1
+ <h1>Dashboard</h1>
2
+
@@ -0,0 +1,20 @@
1
+ = simple_form_for [:admin,@faq],:html => {:novalidate => true} do |f|
2
+ - if @faq.errors.any?
3
+ #error_explanation
4
+ %h2= "#{pluralize(@faq.errors.count, "error")} prohibited this faq from being saved:"
5
+ %ul
6
+ - @faq.errors.full_messages.each do |msg|
7
+ %li= msg
8
+ = f.input :active
9
+
10
+
11
+
12
+ - I18n.available_locales.each do |locale|
13
+ %h1
14
+ = locale
15
+ = f.globalize_fields_for locale do |g|
16
+ = g.input :title
17
+ = g.input :text, :as => :ckeditor, :input_html => { :ckeditor => {:width=>'100%',:height => 200,:toolbar => 'Full'} }
18
+
19
+
20
+ = f.submit 'Save', :class=>'btn btn-primary'
@@ -0,0 +1,9 @@
1
+ - content_for :left do
2
+ = menu_left t('helpdesk.faqs.title') do
3
+ = menu_li ico('pencil') + t('helpdesk.faqs.new'), new_admin_faq_url
4
+ %li.divider
5
+ = menu_li ico('envelope') + "#{t('helpdesk.faqs.active')} (#{Helpdesk::Faq.active.count})", admin_faqs_url(:faqs => 'active')
6
+
7
+ = menu_li ico('info-sign') + "#{t('helpdesk.faqs.inactive')} (#{Helpdesk::Faq.inactive.count})", admin_faqs_url(:faqs => 'inactive')
8
+ %li.divider
9
+ = menu_li ico('list') + t('helpdesk.faqs.all'), admin_faqs_url(:faqs => 'all')
@@ -0,0 +1,11 @@
1
+ = render 'menu'
2
+
3
+
4
+ - content_for :title do
5
+ Edycja pytania
6
+
7
+ = render 'form'
8
+
9
+ = link_to 'Show', [:admin,@faq]
10
+ \|
11
+ = link_to 'Back', admin_faqs_path
@@ -0,0 +1,59 @@
1
+ = render 'menu'
2
+
3
+ - content_for :title do
4
+ -if params[:faqs] && params[:faqs] == 'active'
5
+ = t('helpdesk.faqs.active')
6
+ -elsif params[:faqs] && params[:faqs] == 'inactive'
7
+ = t('helpdesk.faqs.inactive')
8
+ -else
9
+ = t('helpdesk.faqs.all')
10
+
11
+
12
+
13
+
14
+ %ul.unstyled#faqs
15
+ - @faqs.each do |faq|
16
+ %li.row{id:"faqs_#{faq.id}",style:'padding:5px 0px;'}
17
+ %div.handle.span2{style:'cursor:move'}
18
+ %span
19
+ = ico('move')
20
+ %span.badge.badge-info
21
+ = "link#{faq.id}"
22
+ - if faq.active
23
+ %span.label.label-success
24
+ = t('helpdesk.faqs.faq.active')
25
+ - else
26
+ %span.label
27
+ = t('helpdesk.faqs.faq.inactive')
28
+ %div.span5
29
+ = faq.title
30
+ %div.span2
31
+ = link_to t('helpdesk.show'), admin_faq_path(faq), class: 'btn btn-info btn-mini'
32
+ = link_to t('helpdesk.edit'), edit_admin_faq_path(faq),class: 'btn btn-primary btn-mini'
33
+ = link_to t('helpdesk.destroy'), admin_faq_path(faq), method: :delete, data: { confirm: 'Are you sure?' },class: 'btn btn-danger btn-mini'
34
+
35
+
36
+ - content_for :scripts do
37
+ :javascript
38
+ $(document).ready(function(){
39
+ $('#faqs').sortable({
40
+ axis: 'y',
41
+ dropOnEmpty: false,
42
+ handle: '.handle',
43
+ cursor: 'crosshair',
44
+ items: 'li',
45
+ opacity: 0.4,
46
+ scroll: true,
47
+ update: function(){
48
+ $.ajax({
49
+ type: 'post',
50
+ data: $('#faqs').sortable('serialize'),
51
+ dataType: 'script',
52
+ complete: function(request){
53
+ $('#faqs').effect('highlight');
54
+ },
55
+ url: '#{sort_admin_faqs_path}'
56
+ })
57
+ }
58
+ });
59
+ });
@@ -0,0 +1,7 @@
1
+ = render 'menu'
2
+ - content_for :title do
3
+ New faq
4
+
5
+ = render 'form'
6
+
7
+ = link_to 'Back', admin_faqs_path
@@ -0,0 +1,19 @@
1
+ = render 'menu'
2
+
3
+ %p#notice= notice
4
+
5
+ %p
6
+ %b Aktywne:
7
+ = @faq.active
8
+ %p
9
+ %b Title:
10
+ = @faq.title
11
+ %p
12
+ %b Text:
13
+ = raw @faq.text
14
+
15
+
16
+
17
+ = link_to 'Edit', edit_admin_faq_path(@faq)
18
+ \|
19
+ = link_to 'Back', admin_faqs_path
@@ -0,0 +1,12 @@
1
+ = simple_form_for [:admin,@subscriber] do |f|
2
+ - if @subscriber.errors.any?
3
+ #error_explanation
4
+ %h2= "#{pluralize(@subscriber.errors.count, "error")} prohibited this subscriber from being saved:"
5
+ %ul
6
+ - @subscriber.errors.full_messages.each do |msg|
7
+ %li= msg
8
+
9
+ = f.input :confirmed
10
+ = f.input :name
11
+ = f.input :email
12
+ = f.submit 'Save',:class=>'btn btn-primary'
@@ -0,0 +1,9 @@
1
+ - content_for :left do
2
+ = menu_left t('helpdesk.subscribers.title') do
3
+ = menu_li ico('pencil') + t('helpdesk.subscribers.new'), new_admin_subscriber_url
4
+ %li.divider
5
+ = menu_li ico('envelope') + "#{t('helpdesk.subscribers.confirmed')} (#{Helpdesk::Subscriber.confirmed.count})", admin_subscribers_url(:subscribers => 'confirmed')
6
+
7
+ = menu_li ico('info-sign') + "#{t('helpdesk.subscribers.unconfirmed')} (#{Helpdesk::Subscriber.unconfirmed.count})", admin_subscribers_url(:subscribers => 'unconfirmed')
8
+ %li.divider
9
+ = menu_li ico('list') + t('helpdesk.subscribers.all'), admin_subscribers_url(:subscribers => 'all')
@@ -0,0 +1,10 @@
1
+ = render 'menu'
2
+
3
+ - content_for :title do
4
+ Editing sub
5
+
6
+ = render 'form'
7
+
8
+ = link_to 'Show', [:admin,@subscriber]
9
+ \|
10
+ = link_to 'Back', admin_subscribers_path
@@ -0,0 +1,31 @@
1
+ = render 'menu'
2
+
3
+ - content_for :title do
4
+ Subscribers
5
+
6
+ %table.table.table-hover
7
+ %tr
8
+ %th Confirmed
9
+ %th Name
10
+ %th Email
11
+ %th Lang
12
+ %th Created
13
+ %th
14
+ %th
15
+
16
+ - @subscribers.each do |subscriber|
17
+ %tr
18
+ %td
19
+ - if subscriber.confirmed
20
+ = ico('ok')
21
+ %td= subscriber.send Helpdesk.display_user.to_sym
22
+ %td= subscriber.email
23
+
24
+ %td= subscriber.lang
25
+ %td= I18n::l(subscriber.created_at, :format=>:short)
26
+ / %td= link_to 'Show', admin_subscriber_path(subscriber)
27
+ %td= link_to 'Edit', edit_admin_subscriber_path(subscriber)
28
+ %td= link_to 'Destroy', admin_subscriber_path(subscriber), method: :delete, data: { confirm: 'Are you sure?' }
29
+ = paginate @subscribers
30
+ %br
31
+
@@ -0,0 +1,7 @@
1
+ - content_for :title do
2
+ New subscriber
3
+
4
+ = render 'form'
5
+
6
+ \|
7
+ = link_to 'Back', admin_subscribers_path