ask module: dropdown, icon, big5 encoding, redirect, admin, send mail
This commit is contained in:
parent
97df100c64
commit
dcc5fc39a7
|
@ -0,0 +1,10 @@
|
|||
class SendAskNoticeMail
|
||||
@queue = :mail
|
||||
|
||||
def self.perform(ask_admin_id, ask_question_id)
|
||||
ask_admin = AskAdmin.find(ask_admin_id)
|
||||
ask_question = AskQuestion.find(ask_question_id)
|
||||
AskMailer.notice(ask_admin, ask_question).deliver
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class SendAskReplyMail
|
||||
@queue = :mail
|
||||
|
||||
def self.perform(ask_question_id)
|
||||
ask_question = AskQuestion.find(ask_question_id)
|
||||
AskMailer.reply(ask_question).deliver
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,21 @@
|
|||
class Panel::Ask::BackEnd::AskAcknowledgementsController < OrbitBackendController
|
||||
include AdminHelper
|
||||
include OrbitControllerLib::DivisionForDisable
|
||||
|
||||
def initialize
|
||||
super
|
||||
@app_title = 'ask_acknowledgement'
|
||||
end
|
||||
|
||||
def index
|
||||
@ask_acknowledgement = AskAcknowledgement.first || AskAcknowledgement.create
|
||||
@url = panel_ask_back_end_ask_acknowledgement_path(@ask_acknowledgement)
|
||||
end
|
||||
|
||||
def update
|
||||
@ask_acknowledgement = AskAcknowledgement.first
|
||||
@ask_acknowledgement.update_attributes(params[:ask_acknowledgement])
|
||||
redirect_to panel_ask_back_end_ask_acknowledgements_path, notice: t('ask.save_success')
|
||||
end
|
||||
|
||||
end
|
54
vendor/built_in_modules/ask/app/controllers/panel/ask/back_end/ask_admins_controller.rb
vendored
Normal file
54
vendor/built_in_modules/ask/app/controllers/panel/ask/back_end/ask_admins_controller.rb
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
class Panel::Ask::BackEnd::AskAdminsController < OrbitBackendController
|
||||
|
||||
include AdminHelper
|
||||
include OrbitControllerLib::DivisionForDisable
|
||||
|
||||
def initialize
|
||||
super
|
||||
@app_title = 'ask_admins'
|
||||
end
|
||||
|
||||
def index
|
||||
@ask_admins = AskAdmin.all
|
||||
@ask_admin = AskAdmin.new
|
||||
@url = panel_ask_back_end_ask_admins_path
|
||||
end
|
||||
|
||||
def create
|
||||
@ask_admin = AskAdmin.new(params[:ask_admin])
|
||||
@ask_admin.save
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@ask_admin = AskAdmin.find(params[:id])
|
||||
@url = panel_ask_back_end_ask_admin_path(@ask_admin)
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@ask_admin = AskAdmin.find(params[:id])
|
||||
@url = panel_ask_back_end_ask_admin_path(@ask_admin)
|
||||
@ask_admin.update_attributes(params[:ask_admin])
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@ask_admin = AskAdmin.find(params[:id])
|
||||
@ask_admin.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -80,6 +80,6 @@ class Panel::Ask::BackEnd::AskQuestionsController < OrbitBackendController
|
|||
ask_question.ask_reply.comment ]
|
||||
end
|
||||
end
|
||||
send_data csv, type: 'text/csv', filename: "#{t('ask.ask')}#{date_start}-#{date_end}.csv"
|
||||
send_data csv.encode('Big5'), type: 'text/csv', filename: "Questions-#{date_start}-#{date_end}.csv"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require File.expand_path('../../../../../mailers/ask_mailer', __FILE__)
|
||||
|
||||
class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController
|
||||
|
||||
include AdminHelper
|
||||
|
@ -16,19 +14,15 @@ class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController
|
|||
if @ask_question.ask_reply.send_email?
|
||||
::AskMailer.reply(@ask_question).deliver
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success')
|
||||
end
|
||||
|
||||
def update
|
||||
@ask_reply = AskReply.find(params[:id])
|
||||
@ask_reply.update_attributes(params[:ask_reply])
|
||||
if @ask_reply.send_email?
|
||||
::AskMailer.reply(@ask_reply.ask_question).deliver
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
Resque.enqueue(SendAskReplyMail, @reply.ask_question.id)
|
||||
end
|
||||
redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,14 @@ class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController
|
|||
def create
|
||||
@ask_question = AskQuestion.new(params[:ask_question])
|
||||
if verify_recaptcha model: @ask_question, private_key: '6Lfl7OESAAAAAD4rl5S16-zjt5yiKNYJ6jsqdwmL'
|
||||
@ask_acknowledgement = AskAcknowledgement.first
|
||||
@ask_question.save
|
||||
AskAdmin.all.each do |ask_admin|
|
||||
Resque.enqueue(SendAskNoticeMail, ask_admin.id, @ask_question.id)
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# encoding: utf-8
|
||||
class AskMailer < ActionMailer::Base
|
||||
default from: 'orbit_test@rulingcom.com'
|
||||
|
||||
|
@ -6,4 +5,10 @@ class AskMailer < ActionMailer::Base
|
|||
@ask_question = ask_question
|
||||
mail(:to => @ask_question.email, :subject => "#{t('ask.reply')}:#{@ask_question.title}")
|
||||
end
|
||||
|
||||
def notice(ask_admin, ask_question)
|
||||
@ask_admin = ask_admin
|
||||
@ask_question = ask_question
|
||||
mail(:to => @ask_admin.email, :subject => "#{t('ask.new_question')}:#{@ask_question.title}")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class AskAcknowledgement
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :content, type: String
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
class AskAdmin
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :email, type: String
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<h1><%= @ask_question.title %></h1>
|
||||
<table>
|
||||
<tr>
|
||||
<td><%= AskQuestion.human_attribute_name(:name) %>:</td>
|
||||
<td><%= @ask_question.name %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= AskQuestion.human_attribute_name(:identity) %>:</td>
|
||||
<td><%= @ask_question.identity %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= AskQuestion.human_attribute_name(:email) %>:</td>
|
||||
<td><%= @ask_question.email %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= AskQuestion.human_attribute_name(:phone) %>:</td>
|
||||
<td><%= @ask_question.phone %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= AskQuestion.human_attribute_name(:tax) %>:</td>
|
||||
<td><%= @ask_question.tax %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= AskQuestion.human_attribute_name(:content) %>:</td>
|
||||
<td><%= @ask_question.content %></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
14
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_acknowledgements/index.html.erb
vendored
Normal file
14
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_acknowledgements/index.html.erb
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
<div id="ask-acknowledgement">
|
||||
<%= form_for @ask_acknowledgement, url: @url, html: { class: 'form-horizontal' } do |f| %>
|
||||
<div class="control-group">
|
||||
<%= f.label :content, t('ask.acknowledgement'), class: 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= f.text_area :content, rows: 10 %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<%= f.button t('cancel'), type: 'reset', class: 'btn' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
13
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/_ask_admin.html.erb
vendored
Normal file
13
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/_ask_admin.html.erb
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
<tr id="<%= dom_id ask_admin %>" class="with_action">
|
||||
<td>
|
||||
<%= ask_admin.email %>
|
||||
<%if at_least_module_manager %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills hide">
|
||||
<li><%= link_to t(:edit), edit_panel_ask_back_end_ask_admin_path(ask_admin), :remote => true %></li>
|
||||
<li><%= link_to t(:delete), panel_ask_back_end_ask_admin_path(ask_admin), :confirm => t(:sure?), :method => :delete, :remote => true ,:class=> "archive_toggle"%></li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end -%>
|
||||
</td>
|
||||
</tr>
|
19
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/_form.html.erb
vendored
Normal file
19
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/_form.html.erb
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
<%= form_for(@ask_admin, :remote => true, :url => @url) do |f| %>
|
||||
|
||||
<h2><%= @ask_admin.new_record? ? t(:add) : t(:edit) %></h2>
|
||||
|
||||
<div id="widget-title">
|
||||
<div class="control-group">
|
||||
<%= f.label :email, class: 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= f.text_field :email, class: 'input-xxlarge' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.submit t(:submit), class: 'btn btn-primary' %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
2
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/create.js.erb
vendored
Normal file
2
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/create.js.erb
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
$('<%= j render :partial => 'ask_admin', :collection => [@ask_admin] %>').appendTo('#ask-admins').hide().fadeIn();
|
||||
$("#new_ask_admin")[0].reset();
|
1
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/destroy.js.erb
vendored
Normal file
1
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/destroy.js.erb
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
$("#<%= dom_id @ask_admin %>").fadeOut();
|
1
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/edit.js.erb
vendored
Normal file
1
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/edit.js.erb
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
$("#form > form").replaceWith("<%= j render "form" %>");
|
23
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/index.html.erb
vendored
Normal file
23
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/index.html.erb
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
<%= flash_messages %>
|
||||
<div id="filter" class="subnav">
|
||||
<div class="filters">
|
||||
<div id="sort_headers" class="table-label">
|
||||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span1-2"><%= t(:email) %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="ask-admins" class="table main-list">
|
||||
<tbody class="sort-holder">
|
||||
<%= render :partial => 'ask_admin', :collection => @ask_admins %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="form"><%= render :partial => "form" if at_least_module_manager%></div>
|
||||
|
4
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/update.js.erb
vendored
Normal file
4
vendor/built_in_modules/ask/app/views/panel/ask/back_end/ask_admins/update.js.erb
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
$("#<%= dom_id @ask_admin %>").replaceWith("<%= j render :partial => 'ask_admin', :collection => [@ask_admin] %>");
|
||||
<% @ask_admin = AskAdmin.new(:display => 'List') # reset for new form %>
|
||||
$(".edit_ask_admin").replaceWith("<%= j render "form" %>")
|
||||
$(".new_ask_admin")[0].reset();
|
|
@ -1,5 +1,5 @@
|
|||
<div id="ask_question_reply">
|
||||
<%= form_for @ask_question.ask_reply, url: @url, remote: true do |f| %>
|
||||
<%= form_for @ask_question.ask_reply, url: @url do |f| %>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td><%= AskQuestion.human_attribute_name(:name) %>:<%= @ask_question.name %></td>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
alert('<%= t('ask.reply_success') %>');
|
|
@ -1 +0,0 @@
|
|||
alert('<%= t('ask.reply_success') %>');
|
|
@ -1,5 +0,0 @@
|
|||
<% if @ask_question.errors.empty? %>
|
||||
alert('<%= t('ask.ask_question_success') %>');
|
||||
<% else %>
|
||||
alert('<%= @ask_question.errors.full_messages.join('\n') %>');
|
||||
<% end %>
|
7
vendor/built_in_modules/ask/app/views/panel/ask/front_end/ask_questions/create.js.erb
vendored
Normal file
7
vendor/built_in_modules/ask/app/views/panel/ask/front_end/ask_questions/create.js.erb
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<% if @ask_question.errors.empty? %>
|
||||
$('#acknowledgement').html('<p><%= t('ask.save_success') %>!</p><p><%= @ask_acknowledgement.content %></p>');
|
||||
$('html,body').scrollTop(0);
|
||||
<% else %>
|
||||
alert('<%= @ask_question.errors.full_messages.join('\n') %>');
|
||||
Recaptcha.reload()
|
||||
<% end %>
|
|
@ -1,4 +1,11 @@
|
|||
<style type="text/css">
|
||||
#acknowledgement {
|
||||
font-size: 14px;
|
||||
color: green;
|
||||
}
|
||||
</style>
|
||||
<div id="new-ask-question">
|
||||
<div id="acknowledgement"></div>
|
||||
<%= form_for @ask_question, url: panel_ask_front_end_ask_questions_path(standalone: true), remote: true,
|
||||
html: {class: 'form-horizontal'} do |f| %>
|
||||
<div class="control-group">
|
||||
|
@ -16,7 +23,11 @@
|
|||
<div class="control-group">
|
||||
<%= f.label :identity, class: 'control-label required' %>
|
||||
<div class="controls">
|
||||
<%= f.text_field :identity %>
|
||||
<%= f.select :identity, options_for_select( [t('ask.teacher'),
|
||||
t('ask.stuff'),
|
||||
t('ask.student'),
|
||||
t('ask.schoolfellow'),
|
||||
t('ask.others')].map{|i| [i, i]} ) %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
|
@ -67,10 +78,7 @@
|
|||
});
|
||||
|
||||
$('#new-ask-question form') .submit(function() {
|
||||
$.post($(this).attr('action'), $(this).serializeArray(), function(response) {
|
||||
eval(response)
|
||||
Recaptcha.reload()
|
||||
});
|
||||
$.post($(this).attr('action'), $(this).serializeArray());
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,7 +7,15 @@ en:
|
|||
to: To
|
||||
widget:
|
||||
index: Form
|
||||
ask_question_success: Successfully saved,jump back now
|
||||
save_success: Successfully saved
|
||||
teacher: Teacher
|
||||
stuff: Stuff
|
||||
student: Student
|
||||
schoolfellow: Schoolfellow
|
||||
others: Others
|
||||
acknowledgement: Acknowledgement
|
||||
admin: Administrator
|
||||
new_question: New question
|
||||
mongoid:
|
||||
attributes:
|
||||
ask_question:
|
||||
|
|
|
@ -12,7 +12,15 @@ zh_tw:
|
|||
no: 否
|
||||
widget:
|
||||
index: 表單
|
||||
ask_question_success: 儲存成功
|
||||
save_success: 儲存成功
|
||||
teacher: 教師
|
||||
stuff: 職員
|
||||
student: 學生
|
||||
schoolfellow: 校友
|
||||
others: 其他
|
||||
acknowledgement: 感謝詞
|
||||
admin: 管理者
|
||||
new_question: 新的發問
|
||||
mongoid:
|
||||
attributes:
|
||||
ask_question:
|
||||
|
|
|
@ -12,8 +12,9 @@ Rails.application.routes.draw do
|
|||
resources :ask_replies
|
||||
end
|
||||
|
||||
|
||||
resources :ask_categories
|
||||
resources :ask_acknowledgements
|
||||
resources :ask_admins
|
||||
end
|
||||
|
||||
namespace :front_end do
|
||||
|
|
|
@ -22,7 +22,7 @@ module Ask
|
|||
end
|
||||
|
||||
side_bar do
|
||||
head_label_i18n 'ask.ask', icon_class: 'icons-text'
|
||||
head_label_i18n 'ask.ask', icon_class: 'icons-light-bulb'
|
||||
available_for [:admin,:manager,:sub_manager]
|
||||
active_for_controllers({ private: ['ask_questions'] })
|
||||
head_link_path "panel_ask_back_end_ask_questions_path"
|
||||
|
@ -32,6 +32,14 @@ module Ask
|
|||
active_for_action: {:ask_categories=>:index},
|
||||
available_for: [:all]
|
||||
|
||||
context_link 'ask.acknowledgement', link_path: 'panel_ask_back_end_ask_acknowledgements_path',
|
||||
priority: 1,
|
||||
available_for: [:all]
|
||||
|
||||
context_link 'ask.admin', link_path: 'panel_ask_back_end_ask_admins_path',
|
||||
priority: 1,
|
||||
available_for: [:all]
|
||||
|
||||
context_link 'ask.export', link_path: 'export_panel_ask_back_end_ask_questions_path',
|
||||
priority: 1,
|
||||
available_for: [:all]
|
||||
|
|
Reference in New Issue