From 214d24f928e696c464eb150e0ba064f95b49aea1 Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Wed, 19 Feb 2014 11:26:02 +0800 Subject: [PATCH] ntue --- Gemfile | 2 + app/assets/stylesheets/basic/global.css | 19 ++ .../admin/mail_cron_logs_controller.rb | 43 ++++ .../admin/mail_crons_controller.rb | 130 +++++++++++ app/controllers/admin/sites_controller.rb | 13 ++ app/controllers/sessions_controller.rb | 35 +++ app/jobs/email_cron.rb | 42 ++++ app/mailer/mail_cron_mailer.rb | 85 +++++++ app/models/mail_cron.rb | 70 ++++++ app/models/mail_cron_file.rb | 13 ++ app/models/mail_cron_log.rb | 14 ++ app/views/admin/authorizations/index.html.erb | 2 +- app/views/admin/designs/_design.html.erb | 23 +- app/views/admin/designs/_designs.html.erb | 21 +- app/views/admin/designs/index.html.erb | 221 +----------------- .../mail_cron_logs/_clear_filters.html.erb | 3 + .../admin/mail_cron_logs/_filter.html.erb | 11 + .../mail_cron_logs/_mail_cron_log.html.erb | 29 +++ .../mail_cron_logs/_sort_headers.html.erb | 6 + app/views/admin/mail_cron_logs/delete.js.erb | 5 + app/views/admin/mail_cron_logs/destroy.js.erb | 1 + app/views/admin/mail_cron_logs/index.html.erb | 28 +++ app/views/admin/mail_cron_logs/index.js.erb | 4 + .../admin/mail_crons/_clear_filters.html.erb | 3 + app/views/admin/mail_crons/_filter.html.erb | 11 + app/views/admin/mail_crons/_form.html.erb | 122 ++++++++++ .../admin/mail_crons/_form_file.html.erb | 35 +++ .../admin/mail_crons/_mail_cron.html.erb | 26 +++ .../admin/mail_crons/_sort_headers.html.erb | 5 + app/views/admin/mail_crons/delete.js.erb | 5 + app/views/admin/mail_crons/destroy.js.erb | 1 + app/views/admin/mail_crons/edit.html.erb | 9 + app/views/admin/mail_crons/index.html.erb | 27 +++ app/views/admin/mail_crons/index.js.erb | 4 + app/views/admin/mail_crons/new.html.erb | 12 + app/views/admin/sites/_mail_cron.html.erb | 20 ++ app/views/admin/sites/_mail_cron_log.html.erb | 19 ++ app/views/admin/sites/_user_action.html.erb | 6 + app/views/admin/sites/system_info.html.erb | 64 ++++- app/views/admin/sites/system_info.js.erb | 8 + app/views/front/show_banner.html.erb | 2 +- built_in_extensions.rb | 3 +- config/routes.rb | 17 ++ 43 files changed, 979 insertions(+), 240 deletions(-) create mode 100644 app/controllers/admin/mail_cron_logs_controller.rb create mode 100644 app/controllers/admin/mail_crons_controller.rb create mode 100644 app/controllers/sessions_controller.rb create mode 100644 app/jobs/email_cron.rb create mode 100644 app/mailer/mail_cron_mailer.rb create mode 100644 app/models/mail_cron.rb create mode 100644 app/models/mail_cron_file.rb create mode 100644 app/models/mail_cron_log.rb create mode 100644 app/views/admin/mail_cron_logs/_clear_filters.html.erb create mode 100644 app/views/admin/mail_cron_logs/_filter.html.erb create mode 100644 app/views/admin/mail_cron_logs/_mail_cron_log.html.erb create mode 100644 app/views/admin/mail_cron_logs/_sort_headers.html.erb create mode 100644 app/views/admin/mail_cron_logs/delete.js.erb create mode 100644 app/views/admin/mail_cron_logs/destroy.js.erb create mode 100644 app/views/admin/mail_cron_logs/index.html.erb create mode 100644 app/views/admin/mail_cron_logs/index.js.erb create mode 100644 app/views/admin/mail_crons/_clear_filters.html.erb create mode 100644 app/views/admin/mail_crons/_filter.html.erb create mode 100644 app/views/admin/mail_crons/_form.html.erb create mode 100644 app/views/admin/mail_crons/_form_file.html.erb create mode 100644 app/views/admin/mail_crons/_mail_cron.html.erb create mode 100644 app/views/admin/mail_crons/_sort_headers.html.erb create mode 100644 app/views/admin/mail_crons/delete.js.erb create mode 100644 app/views/admin/mail_crons/destroy.js.erb create mode 100644 app/views/admin/mail_crons/edit.html.erb create mode 100644 app/views/admin/mail_crons/index.html.erb create mode 100644 app/views/admin/mail_crons/index.js.erb create mode 100644 app/views/admin/mail_crons/new.html.erb create mode 100644 app/views/admin/sites/_mail_cron.html.erb create mode 100644 app/views/admin/sites/_mail_cron_log.html.erb create mode 100644 app/views/admin/sites/_user_action.html.erb create mode 100644 app/views/admin/sites/system_info.js.erb diff --git a/Gemfile b/Gemfile index 0876fbc..fa19540 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,8 @@ source 'http://rubygems.org' gem 'rails', "~> 3.2.16" +gem 'savon', '~> 2.2.0' + gem "brakeman" gem 'mime-types' diff --git a/app/assets/stylesheets/basic/global.css b/app/assets/stylesheets/basic/global.css index 1880808..4f92e52 100644 --- a/app/assets/stylesheets/basic/global.css +++ b/app/assets/stylesheets/basic/global.css @@ -549,11 +549,30 @@ legend { margin-left: -45%; } #show_preview .modal-body { + background-color: #fff; padding: 0; max-height: none; height: 100%; overflow: hidden; } +#show_preview .modal-body > div { + height: 100%; +} +#show_preview .modal-body .modal-left { + overflow: auto; + float: left; + width: 19.8%; + border-right: 1px solid #DFDFDF; +} +#show_preview .modal-body .modal-left > * { + padding: 1em; + margin: 0; + list-style: none; +} +#show_preview .modal-body .modal-right { + float: right; + width: 80%; +} #show_preview iframe { border: 0; outline: none; diff --git a/app/controllers/admin/mail_cron_logs_controller.rb b/app/controllers/admin/mail_cron_logs_controller.rb new file mode 100644 index 0000000..7909427 --- /dev/null +++ b/app/controllers/admin/mail_cron_logs_controller.rb @@ -0,0 +1,43 @@ +class Admin::MailCronLogsController < OrbitBackendController + + # layout "new_admin" + before_filter :authenticate_user! + before_filter :is_admin? + + def index + + # @mail_cron_logs = MailCronLog.all.desc(:created_at).page(params[:page_main] ).per('20') + @mail_cron_logs = (params[:sort]) ? get_sorted_and_filtered("mail_cron_log") : get_viewable("mail_cron_log") + + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @mail_crons } + format.js + end + + end + + def destroy + @mail_cron_log = MailCronLog.find(params[:id]) + @mail_cron_log.destroy + + respond_to do |format| + # format.html { redirect_to(admin_mail_cron_logs_url) } + # format.xml { head :ok } + format.js { render :layout => false } + end + end + + def delete + if params[:ids] + # @mail_cron_logs = MailCronLog.any_in(:_id => params[:ids]).destroy_all + @mail_cron_logs = MailCronLog.any_in(:_id => params[:ids]) + end + + respond_to do |format| + format.js { render :layout => false } + end + # redirect_to admin_mail_cron_logs_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + +end diff --git a/app/controllers/admin/mail_crons_controller.rb b/app/controllers/admin/mail_crons_controller.rb new file mode 100644 index 0000000..d0ff698 --- /dev/null +++ b/app/controllers/admin/mail_crons_controller.rb @@ -0,0 +1,130 @@ +class Admin::MailCronsController < OrbitBackendController + + # layout "new_admin" + before_filter :authenticate_user! + before_filter :is_admin? + + def index + + # @mail_crons = MailCron.all.asc(:mail_sentdate).page(params[:page_main] ).per('20') + @mail_crons = (params[:sort]) ? get_sorted_and_filtered("mail_cron") : get_viewable("mail_cron") + + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @mail_crons } + format.js + end + + end + + def show + end + + def new + @mail_cron = MailCron.new + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @mail_cron } + end + end + + def create + @mail_cron = MailCron.new(params[:mail_cron]) + + @mail_cron.create_user_id = current_user.id + @mail_cron.update_user_id = current_user.id + + respond_to do |format| + if @mail_cron.save + format.html { redirect_to(admin_mail_crons_url) } + format.xml { render :xml => @mail_cron, :status => :created, :location => @mail_cron } + else + format.html { render :action => "new" } + format.xml { render :xml => @mail_cron.errors, :status => :unprocessable_entity } + end + end + end + + def edit + @mail_cron = MailCron.find(params[:id]) + end + + def update + + + + @datas = MailCron.where(:mail_sentdate.lte => Time.now, :mail_sent => false) + + @datas.each do |mail_data| + + @mail_j = 0 + @read_mails = Array.new + + @mails = mail_data.mail_to.split(",") + + @mails.each do |send_mail| + + @read_mails << send_mail + + @mail_j += 1 + + if 0 == @mail_j % 30 + MailCronMailer.cron_mail( mail_data.id, @read_mails.join(',') ).deliver + @read_mails = Array.new + + sleep 10 + end + + end + + if !@read_mails.join(',').blank? + MailCronMailer.cron_mail( mail_data.id, @read_mails.join(',') ).deliver + @read_mails = Array.new + + sleep 10 + end + + end + + @mail_cron = MailCron.find(params[:id]) + + @mail_cron.update_user_id = current_user.id + + respond_to do |format| + if @mail_cron.update_attributes(params[:mail_cron]) + format.html { redirect_to(admin_mail_crons_url) } + format.js { render 'toggle_enable' } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @mail_cron.errors, :status => :unprocessable_entity } + end + end + end + + def destroy + @mail_cron = MailCron.find(params[:id]) + @mail_cron.destroy + + respond_to do |format| + # format.html { redirect_to(admin_mail_crons_url) } + # format.xml { head :ok } + format.js { render :layout => false } + end + end + + def delete + if params[:ids] + # mail_crons = MailCron.any_in(:_id => params[:ids]).destroy_all + @mail_crons = MailCron.any_in(:_id => params[:ids]) + end + respond_to do |format| + format.js { render :layout => false } + end + # redirect_to admin_mail_crons_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + + protected + +end diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index 5e355b0..d2dbc83 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -76,6 +76,18 @@ class Admin::SitesController < OrbitBackendController @nginx_version = %x[/opt/nginx/sbin/nginx -v 2>&1].gsub("\n","
").html_safe @mongo_version = `mongod --version`.split("\n")[0].html_safe @linux_version = `lsb_release -d`.split(":")[1].html_safe + + @user_actions = UserAction.all.desc(:created_at).page(params[:page]).per(100) + + @mail_crons = MailCron.desc(:created_at) + + @mail_cron_logs = MailCronLog.desc(:created_at).page(params[:page]).per(100) + + respond_to do |format| + format.html # index.html.erb + format.js + end + end def search_engine @@ -139,6 +151,7 @@ class Admin::SitesController < OrbitBackendController result = "success" Bundler.with_clean_env { `cd #{Rails.root} && bundle install && touch tmp/restart.txt` } end + %x(git stash pop) unless need_stash render :text => result end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000..c1a027d --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,35 @@ +# encoding: utf-8 + +class SessionsController < Devise::SessionsController + prepend_before_filter :require_no_authentication, :only => [ :new, :create ] + + require 'savon' + + def create + + @sys_id = params["sys_id"] + + client = Savon.client(wsdl: 'http://sso.ntue.edu.tw/soap/soapserver.php?wsdl') + + client.operations + + response = client.call(:chkidno, message: { sys_id: @sys_id }) + + @id = response.body[:chkidno_response][:return][:id] + + login_uid = @id + + resource = User.first(conditions:{user_id: login_uid}) + + if !resource.blank? + resource_name = resource.class.to_s.downcase + sign_in(resource_name, resource) + redirect_to after_sign_in_path_for(resource) + else + flash[:error] = "很抱歉,您無此權限或帳號登入本站,請洽本站管理員
Sorry, you don't have the account or authority to login. Please contact the website administrator." + redirect_to :root + end + + end + +end \ No newline at end of file diff --git a/app/jobs/email_cron.rb b/app/jobs/email_cron.rb new file mode 100644 index 0000000..51dec11 --- /dev/null +++ b/app/jobs/email_cron.rb @@ -0,0 +1,42 @@ +class EmailCron + @queue = :mail + + def self.perform + + @datas = MailCron.where(:mail_sentdate.lte => Time.now) + + @datas.each do |mail_data| + + @mail_j = 0 + @read_mails = Array.new + + @mails = mail_data.mail_to.split(",") + + @mails.each do |send_mail| + + @read_mails << send_mail + + @mail_j += 1 + + if 0 == @mail_j % 30 + MailCronMailer.cron_mail( mail_data.id, @read_mails.join(',') ).deliver + @read_mails = Array.new + + sleep 10 + end + + end + + if !@read_mails.join(',').blank? + MailCronMailer.cron_mail( mail_data.id, @read_mails.join(',') ).deliver + @read_mails = Array.new + + sleep 10 + end + + end + + end + + +end \ No newline at end of file diff --git a/app/mailer/mail_cron_mailer.rb b/app/mailer/mail_cron_mailer.rb new file mode 100644 index 0000000..ba4228a --- /dev/null +++ b/app/mailer/mail_cron_mailer.rb @@ -0,0 +1,85 @@ +# encoding: utf-8 + +class MailCronMailer < ActionMailer::Base + default :from => "orbit_test@rulingcom.com" + + def get_settings + + @site = Site.first + + @smtp_settings = { + :address => @site['site_settings']['address'], + :port => @site['site_settings']['port'], + :domain => @site['site_settings']['domain'], + :authentication => @site['site_settings']['authentication'], + :enable_starttls_auto => @site['site_settings']['enable_starttls_auto'] + } + + if !@site['site_settings']['user_name'].blank? + @smtp_settings[:user_name] = @site['site_settings']['user_name'] + end + + if !@site['site_settings']['password'].blank? + @smtp_settings[:password] = @site['site_settings']['password'] + end + + + ActionMailer::Base.smtp_settings = @smtp_settings + + end + + + def cron_mail( data_id, group_mail ) + + get_settings + + @data = MailCron.find(data_id) + + if @data + + @user = User.find(@data.create_user_id) + + unit_field = User.get_member_list_attribute_field("staff","Unit") + unit = User.get_member_list_attribute_value(@data.create_user_id,unit_field.id).get_value_by_locale(I18n.locale) rescue nil + + + if !@data.mail_cron_files.blank? + @data.mail_cron_files.each_with_index do |mail_cron_file, i| + file_type = File.extname(mail_cron_file.file.to_s) + file_content = Mongo::GridFileSystem.new(Mongoid.database).open(mail_cron_file.file.url.gsub("/gridfs/", "").force_encoding("UTF-8"), 'r') + attachments["#{mail_cron_file.title}#{file_type}"] = file_content.read + end + end + + if !@data.mail_content["text"].blank? + mail( :from => "\"#{unit}\" <#{@data.mail_from}>", :reply_to => @data.mail_reply_to, :bcc => group_mail, :subject => @data.mail_subject ) do |format| + format.html { render :text => @data.mail_content["text"] } + end + elsif !@data.mail_content["template"].blank? + mail( :from => "\"#{unit}\" <#{@data.mail_from}>", :reply_to => @data.mail_reply_to, :bcc => group_mail, :subject => @data.mail_subject ) do |format| + format.html { render :template => @data.mail_content["template"], :collection => @data.mail_content } + end + end + + + @mail_cron_log = { + :mail_subject => @data.mail_subject, + :mail_to => group_mail, + :mail_user => "#{!unit.blank? ? unit : @user.name} <#{@data.mail_from}>", + # :mail_user => @user.name, + :mailer_count => group_mail.split(",").size, + :mail_from_app => @data.mail_from_app + } + + @mail_cron_log = MailCronLog.new(@mail_cron_log) + + + @mail_cron_log.save + + @data.destroy + + end + + end + +end \ No newline at end of file diff --git a/app/models/mail_cron.rb b/app/models/mail_cron.rb new file mode 100644 index 0000000..ba9a00d --- /dev/null +++ b/app/models/mail_cron.rb @@ -0,0 +1,70 @@ +class MailCron + + include Mongoid::Document + include Mongoid::Timestamps + + + field :mail_from_app + field :mail_from + field :mail_to + field :mail_reply_to + field :mail_subject + field :mail_content, :type => Hash + field :mail_sentdate , :type => DateTime + + field :create_user_id + field :update_user_id + + has_many :mail_cron_files, :autosave => true, :dependent => :destroy + + accepts_nested_attributes_for :mail_cron_files, :allow_destroy => true + + after_save :save_mail_cron_files + + + def save_mail_cron_files + self.mail_cron_files.each do |t| + if t.should_destroy + t.destroy + end + end + end + + def self.send_mail_now(mail_cron_id) + + mail_data = MailCron.find(mail_cron_id) + + if !mail_data.blank? + + @mail_j = 0 + @read_mails = Array.new + + @mails = mail_data.mail_to.split(",") + + @mails.each do |send_mail| + + @read_mails << send_mail + + @mail_j += 1 + + if 0 == @mail_j % 30 + MailCronMailer.cron_mail( mail_data.id, @read_mails.join(',') ).deliver + @read_mails = Array.new + + sleep 10 + end + + end + + if !@read_mails.join(',').blank? + MailCronMailer.cron_mail( mail_data.id, @read_mails.join(',') ).deliver + @read_mails = Array.new + + sleep 10 + end + + end + + end + +end \ No newline at end of file diff --git a/app/models/mail_cron_file.rb b/app/models/mail_cron_file.rb new file mode 100644 index 0000000..ceaa2d0 --- /dev/null +++ b/app/models/mail_cron_file.rb @@ -0,0 +1,13 @@ +class MailCronFile + + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :file, AssetUploader + + field :should_destroy, :type => Boolean + field :title + + belongs_to :mail_cron + +end diff --git a/app/models/mail_cron_log.rb b/app/models/mail_cron_log.rb new file mode 100644 index 0000000..8aed7e2 --- /dev/null +++ b/app/models/mail_cron_log.rb @@ -0,0 +1,14 @@ +class MailCronLog + + include Mongoid::Document + include Mongoid::Timestamps + + + field :mail_subject + field :mail_to + field :mail_user + field :mailer_count + field :mail_from_app + + +end \ No newline at end of file diff --git a/app/views/admin/authorizations/index.html.erb b/app/views/admin/authorizations/index.html.erb index 8e01d0e..1f81d94 100644 --- a/app/views/admin/authorizations/index.html.erb +++ b/app/views/admin/authorizations/index.html.erb @@ -35,6 +35,6 @@
<%= link_to content_tag(:i, nil, class: "icons-plus") + ' ' + t(:add), '#', class: 'btn btn-primary select_user_modal', rel: admin_modal_select_authorizations_path(@module_app.key, @type, @object) %> - <%= link_to content_tag(:i, nil, class: "icon-trash") + ' ' + t(:delete_), '#', id: 'remove_users', class: 'btn btn-danger', rel: admin_remove_users_authorizations_path(@module_app.key, @type, @object) %> + <%= link_to content_tag(:i, nil, class: "icon-trash") + ' ' + t(:delete), '#', id: 'remove_users', class: 'btn btn-danger', rel: admin_remove_users_authorizations_path(@module_app.key, @type, @object) %>
diff --git a/app/views/admin/designs/_design.html.erb b/app/views/admin/designs/_design.html.erb index bcf8e0a..d0d5add 100644 --- a/app/views/admin/designs/_design.html.erb +++ b/app/views/admin/designs/_design.html.erb @@ -1,20 +1,15 @@ - - -
- <%= design.title %> -
- - - -

<%= design.author %>

- - -
-
\ No newline at end of file diff --git a/app/views/admin/mail_cron_logs/_clear_filters.html.erb b/app/views/admin/mail_cron_logs/_clear_filters.html.erb new file mode 100644 index 0000000..3b9cc61 --- /dev/null +++ b/app/views/admin/mail_cron_logs/_clear_filters.html.erb @@ -0,0 +1,3 @@ +
+ <%= link_to content_tag(:i, nil, :class => 'icons-cycle') + t(:clear), admin_mail_crons_path(:filter => @filter, :sort => params[:sort], :direction => params[:direction], :clear => true, :type => type), :class => "btn btn-small js_history" %> +
\ No newline at end of file diff --git a/app/views/admin/mail_cron_logs/_filter.html.erb b/app/views/admin/mail_cron_logs/_filter.html.erb new file mode 100644 index 0000000..63882b8 --- /dev/null +++ b/app/views/admin/mail_cron_logs/_filter.html.erb @@ -0,0 +1,11 @@ + + +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "sort_header" %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/mail_cron_logs/_mail_cron_log.html.erb b/app/views/admin/mail_cron_logs/_mail_cron_log.html.erb new file mode 100644 index 0000000..35c59b3 --- /dev/null +++ b/app/views/admin/mail_cron_logs/_mail_cron_log.html.erb @@ -0,0 +1,29 @@ + + + <% if is_manager? %> + <%= check_box_tag 'to_delete[]', mail_cron_log.id, false, :class => "checkbox_in_list" %> + <% end -%> + + + <%= mail_cron_log.mail_subject %> +
+ +
+ + + <%= mail_cron_log.mail_to.gsub(/,/, "
").html_safe %> + + + <%= mail_cron_log.mail_user %> + + + <%= mail_cron_log.mail_from_app %> + + + <%= display_date_time(mail_cron_log.created_at) %> + + \ No newline at end of file diff --git a/app/views/admin/mail_cron_logs/_sort_headers.html.erb b/app/views/admin/mail_cron_logs/_sort_headers.html.erb new file mode 100644 index 0000000..e8a7d33 --- /dev/null +++ b/app/views/admin/mail_cron_logs/_sort_headers.html.erb @@ -0,0 +1,6 @@ +<%= render_sort_bar(true, delete_admin_mail_cron_logs_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]), + ['subject', 'mail_subject','span2', :subject] , + ['mail_to', 'mail_to','span2', :mail_to] , + ['mail_user', 'mail_user','span2', :mail_user] , + ['mail_from_app', 'mail_from_app','span2', :mail_from_app] , + ['sentdate', 'created_at','span2', :sentdate] ).html_safe %> \ No newline at end of file diff --git a/app/views/admin/mail_cron_logs/delete.js.erb b/app/views/admin/mail_cron_logs/delete.js.erb new file mode 100644 index 0000000..1aefe25 --- /dev/null +++ b/app/views/admin/mail_cron_logs/delete.js.erb @@ -0,0 +1,5 @@ +<% @mail_cron_logs.collect do |mail_cron_log| %> +$("#<%= dom_id mail_cron_log %>").remove(); +<% end %> + +<% MailCronLog.any_in(:_id => params[:ids]).destroy_all %> \ No newline at end of file diff --git a/app/views/admin/mail_cron_logs/destroy.js.erb b/app/views/admin/mail_cron_logs/destroy.js.erb new file mode 100644 index 0000000..9e65f17 --- /dev/null +++ b/app/views/admin/mail_cron_logs/destroy.js.erb @@ -0,0 +1 @@ +$("#<%= dom_id @mail_cron_log %>").remove(); \ No newline at end of file diff --git a/app/views/admin/mail_cron_logs/index.html.erb b/app/views/admin/mail_cron_logs/index.html.erb new file mode 100644 index 0000000..07d13f2 --- /dev/null +++ b/app/views/admin/mail_cron_logs/index.html.erb @@ -0,0 +1,28 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('site.settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %> +<% end %> + + <%= render 'filter' %> + + + + + + + + + + + + + <%= render :partial => "mail_cron_log",:collection=> @mail_cron_logs%> + +
+ + +
+ +
+ \ No newline at end of file diff --git a/app/views/admin/mail_cron_logs/index.js.erb b/app/views/admin/mail_cron_logs/index.js.erb new file mode 100644 index 0000000..504d3ab --- /dev/null +++ b/app/views/admin/mail_cron_logs/index.js.erb @@ -0,0 +1,4 @@ +$("#delete_all").attr("action", "<%= delete_admin_mail_cron_logs_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]) %>"); +$("#sort_headers").html("<%= j render 'sort_headers' %>"); +$("#tbody_mail_cron_logs").html("<%= j render :partial => 'mail_cron_log', :collection => @mail_cron_logs %>"); +$("#mail_cron_log_pagination").html("<%= j paginate @mail_cron_logs, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>"); \ No newline at end of file diff --git a/app/views/admin/mail_crons/_clear_filters.html.erb b/app/views/admin/mail_crons/_clear_filters.html.erb new file mode 100644 index 0000000..3b9cc61 --- /dev/null +++ b/app/views/admin/mail_crons/_clear_filters.html.erb @@ -0,0 +1,3 @@ +
+ <%= link_to content_tag(:i, nil, :class => 'icons-cycle') + t(:clear), admin_mail_crons_path(:filter => @filter, :sort => params[:sort], :direction => params[:direction], :clear => true, :type => type), :class => "btn btn-small js_history" %> +
\ No newline at end of file diff --git a/app/views/admin/mail_crons/_filter.html.erb b/app/views/admin/mail_crons/_filter.html.erb new file mode 100644 index 0000000..63882b8 --- /dev/null +++ b/app/views/admin/mail_crons/_filter.html.erb @@ -0,0 +1,11 @@ + + +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "sort_header" %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/mail_crons/_form.html.erb b/app/views/admin/mail_crons/_form.html.erb new file mode 100644 index 0000000..40d7bde --- /dev/null +++ b/app/views/admin/mail_crons/_form.html.erb @@ -0,0 +1,122 @@ +
+<% # encoding: utf-8 %> + + <%= f.error_messages %> + + + +
+ +
+

<%= t(:date_) %>

+
+
+ <%= f.datetime_picker :mail_sentdate, :picker_type => 'separated', :label => t(:start) %> +
+
+
+ +
+ + + + + +
+
+ + <%= f.label :mail_subject ,t(:mail_subject)%> + <%= f.text_field :mail_subject %> + + <%= f.label :mail_from ,t(:mail_from)%> + <%= f.text_field :mail_from %> + + <%= f.label :mail_reply_to ,t(:mail_reply_to)%> + <%= f.text_field :mail_reply_to %> + + <%= f.label :mail_to ,t(:mail_to)%> + <%= f.text_field :mail_to %> + + <%= f.label :mail_content ,t(:mail_content)%> + <%= f.text_area :mail_content, :class=>"span12", :cols=>"25", :rows=>"10" %> + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + + + + + <% @mail_cron.mail_cron_files.each_with_index do |mail_cron_file, i| %> + <%= f.fields_for :mail_cron_files, mail_cron_file do |f| %> + <%= render :partial => 'form_file', :object => mail_cron_file, :locals => {:f => f, :i => i} %> + <% end %> + <% end %> + +
FileFile Name
+
+ <%= hidden_field_tag 'plugin_file_field_count', @mail_cron.mail_cron_files.count %> + ADD/新增 +
+
+ +
+ +
+ + + +
+ + +
+ <%= f.submit t('submit'), :class=>'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+ + + + +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "archive_plugin_form" %> + +<% end %> + + +
\ No newline at end of file diff --git a/app/views/admin/mail_crons/_form_file.html.erb b/app/views/admin/mail_crons/_form_file.html.erb new file mode 100644 index 0000000..e7fe526 --- /dev/null +++ b/app/views/admin/mail_crons/_form_file.html.erb @@ -0,0 +1,35 @@ +<% # encoding: utf-8 %> + + " class='list_item'> + +
+
+ <%= f.file_field :file %> + <%= form_file.file.file ? ( link_to t(:view), form_file.file.url, {:class => 'btn', :target => '_blank', :title => t(:view)} ) : '' %> +
+
+ + + +
+ + <%= f.text_field :title %> + +
+ + + + + + <% if form_file.new_record? %> + + <% else %> + <%= f.hidden_field :id %> + + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> + <% end %> + + + + + diff --git a/app/views/admin/mail_crons/_mail_cron.html.erb b/app/views/admin/mail_crons/_mail_cron.html.erb new file mode 100644 index 0000000..be7cf80 --- /dev/null +++ b/app/views/admin/mail_crons/_mail_cron.html.erb @@ -0,0 +1,26 @@ + + + <% if is_manager? %> + <%= check_box_tag 'to_delete[]', mail_cron.id, false, :class => "checkbox_in_list" %> + <% end -%> + + + <%= mail_cron.mail_subject %> +
+ +
+ + + <%= mail_cron.mail_to.gsub(/,/, "
").html_safe %> + + + <%= mail_cron.mail_from_app %> + + + <%= display_date_time(mail_cron.mail_sentdate) %> + + \ No newline at end of file diff --git a/app/views/admin/mail_crons/_sort_headers.html.erb b/app/views/admin/mail_crons/_sort_headers.html.erb new file mode 100644 index 0000000..2d1e6ca --- /dev/null +++ b/app/views/admin/mail_crons/_sort_headers.html.erb @@ -0,0 +1,5 @@ +<%= render_sort_bar(true, delete_admin_mail_crons_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]), + ['subject', 'mail_subject','span2', :mail_subject] , + ['mail_to', 'mail_to','span2', :mail_to] , + ['mail_from_app', 'mail_from_app','span2', :mail_from_app] , + ['sentdate', 'mail_sentdate','span2', :mail_sentdate] ).html_safe %> \ No newline at end of file diff --git a/app/views/admin/mail_crons/delete.js.erb b/app/views/admin/mail_crons/delete.js.erb new file mode 100644 index 0000000..1869e51 --- /dev/null +++ b/app/views/admin/mail_crons/delete.js.erb @@ -0,0 +1,5 @@ +<% @mail_crons.collect do |mail_cron| %> +$("#<%= dom_id mail_cron %>").remove(); +<% end %> + +<% MailCron.any_in(:_id => params[:ids]).destroy_all %> \ No newline at end of file diff --git a/app/views/admin/mail_crons/destroy.js.erb b/app/views/admin/mail_crons/destroy.js.erb new file mode 100644 index 0000000..7c22134 --- /dev/null +++ b/app/views/admin/mail_crons/destroy.js.erb @@ -0,0 +1 @@ +$("#<%= dom_id @mail_cron %>").remove(); \ No newline at end of file diff --git a/app/views/admin/mail_crons/edit.html.erb b/app/views/admin/mail_crons/edit.html.erb new file mode 100644 index 0000000..e3d8b2d --- /dev/null +++ b/app/views/admin/mail_crons/edit.html.erb @@ -0,0 +1,9 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('site.settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %> +<% end %> + +

<%= t('mail_cron.editing_mail_cron') %>

+ +<%= form_for @mail_cron, :url => admin_mail_cron_path(@mail_cron), :html => {:class => 'clear'} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> diff --git a/app/views/admin/mail_crons/index.html.erb b/app/views/admin/mail_crons/index.html.erb new file mode 100644 index 0000000..04bd455 --- /dev/null +++ b/app/views/admin/mail_crons/index.html.erb @@ -0,0 +1,27 @@ +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('site.settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %> +<% end %> + + <%= render 'filter' %> + + + + + + + + + + + + <%= render :partial => "mail_cron",:collection=> @mail_crons%> + +
+ + +
+ +
+ \ No newline at end of file diff --git a/app/views/admin/mail_crons/index.js.erb b/app/views/admin/mail_crons/index.js.erb new file mode 100644 index 0000000..7a90902 --- /dev/null +++ b/app/views/admin/mail_crons/index.js.erb @@ -0,0 +1,4 @@ +$("#delete_all").attr("action", "<%= delete_admin_mail_crons_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]) %>"); +$("#sort_headers").html("<%= j render 'sort_headers' %>"); +$("#tbody_mail_crons").html("<%= j render :partial => 'mail_cron', :collection => @mail_crons %>"); +$("#mail_cron_pagination").html("<%= j paginate @mail_crons, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>"); \ No newline at end of file diff --git a/app/views/admin/mail_crons/new.html.erb b/app/views/admin/mail_crons/new.html.erb new file mode 100644 index 0000000..06d3c78 --- /dev/null +++ b/app/views/admin/mail_crons/new.html.erb @@ -0,0 +1,12 @@ + +<% content_for :side_bar do %> + <%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('site.settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %> +<% end %> + +
+

<%= t('mail_cron.new_mail_cron') %>

+<%= form_for @mail_cron, :url => admin_mail_crons_path, :html => {:class => 'clear'} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> +
+ diff --git a/app/views/admin/sites/_mail_cron.html.erb b/app/views/admin/sites/_mail_cron.html.erb new file mode 100644 index 0000000..d720562 --- /dev/null +++ b/app/views/admin/sites/_mail_cron.html.erb @@ -0,0 +1,20 @@ + + + + <% if is_manager? %> + <%= check_box_tag 'to_delete[]', mail_cron.id, false, :class => "list-check" %> + <% end -%> + + <%= display_date_time(mail_cron.mail_sentdate) %> + <%= mail_cron.mail_subject %> +
+ +
+ + <%= mail_cron.mail_to.gsub(/,/, "
").html_safe %> + <%= mail_cron.mail_from_app %> + \ No newline at end of file diff --git a/app/views/admin/sites/_mail_cron_log.html.erb b/app/views/admin/sites/_mail_cron_log.html.erb new file mode 100644 index 0000000..7569c34 --- /dev/null +++ b/app/views/admin/sites/_mail_cron_log.html.erb @@ -0,0 +1,19 @@ + + + + <% if is_manager? %> + <%= check_box_tag 'to_delete[]', mail_cron_log.id, false, :class => "list-check" %> + <% end -%> + + <%= display_date_time(mail_cron_log.created_at) %> + <%= mail_cron_log.mail_subject %> +
+ +
+ + <%= mail_cron_log.mail_to.gsub(/,/, "
").html_safe %> + <%= mail_cron_log.mail_user %> + <%= mail_cron_log.mail_from_app %> + \ No newline at end of file diff --git a/app/views/admin/sites/_user_action.html.erb b/app/views/admin/sites/_user_action.html.erb new file mode 100644 index 0000000..7cd27a4 --- /dev/null +++ b/app/views/admin/sites/_user_action.html.erb @@ -0,0 +1,6 @@ + + + <%= user_action.created_at %> + <%= user_action.user.name %> + <%= user_action.page %> + \ No newline at end of file diff --git a/app/views/admin/sites/system_info.html.erb b/app/views/admin/sites/system_info.html.erb index 7dce7b3..65c7480 100644 --- a/app/views/admin/sites/system_info.html.erb +++ b/app/views/admin/sites/system_info.html.erb @@ -18,6 +18,7 @@ @@ -52,6 +53,23 @@ + +
+

<%= t("user_actions") %>

+ + + + + + + <%= render :partial => "user_action", :collection=> @user_actions%> +
<%= I18n.t 'user_action.time' %><%= I18n.t 'user_action.name' %><%= I18n.t 'user_action.page' %>
+ + +
+
\ No newline at end of file + + + + diff --git a/app/views/admin/sites/system_info.js.erb b/app/views/admin/sites/system_info.js.erb new file mode 100644 index 0000000..6e7a88c --- /dev/null +++ b/app/views/admin/sites/system_info.js.erb @@ -0,0 +1,8 @@ +$("<%= j(render :partial => 'user_action', :collection => @user_actions) %>").appendTo($("#user_actions")); +$(".user-paginate").html("<%= j(paginate @user_actions, :remote => true) %>"); + +$("<%= j(render :partial => 'mail_cron_log', :collection => @mail_cron_logs) %>").appendTo($("#mail_cron_logs")); +$(".paginate").html("<%= j(paginate @mail_cron_logs, :remote => true) %>"); + +checkScroll(); +$('.list-check').listCheck(); \ No newline at end of file diff --git a/app/views/front/show_banner.html.erb b/app/views/front/show_banner.html.erb index 37cb4e9..c425d17 100644 --- a/app/views/front/show_banner.html.erb +++ b/app/views/front/show_banner.html.erb @@ -2,7 +2,7 @@
<% @ad_banner.ad_images.can_display.each do |ad_image| %> <% link = ad_image_link(ad_image) %> - <%= image_tag ad_image.file, width: @ad_banner.width, height: @ad_banner.height, link_open: ad_image.link_open, link_url: link, style: "display:none; #{'cursor:pointer;' if link.present?}" %> + <%= image_tag ad_image.file, alt: ad_image.title, title: ad_image.title, width: @ad_banner.width, height: @ad_banner.height, link_open: ad_image.link_open, link_url: link, style: "display:none; #{'cursor:pointer;' if link.present?}" %> <% end %>
diff --git a/built_in_extensions.rb b/built_in_extensions.rb index 10b154c..df182b3 100644 --- a/built_in_extensions.rb +++ b/built_in_extensions.rb @@ -1,5 +1,6 @@ #built-in-modules -gem 'announcement', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-announcement.git' +gem 'announcement', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-announcement.git', :branch => 'ntue' +gem 'er_email', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-eremail.git', :branch => 'ntue' gem 'gallery', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-gallery.git' gem 'member', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-member.git' gem 'member_staff', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-memberstaff.git' diff --git a/config/routes.rb b/config/routes.rb index 8631269..759e1e6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,6 +8,10 @@ Orbit::Application.routes.draw do match "/users_passwd" => "desktop/registrations#update", :as => :users_passwd, :via => :put end + devise_scope :user do + get 'soap_login' => 'sessions#create' + end + mount Resque::Server, :at => "/admin/resque" mount Rack::GridFS::Endpoint.new(:db => Mongoid.database,:lookup=>:path), :at => "gridfs" @@ -37,6 +41,19 @@ Orbit::Application.routes.draw do post 'delete_files' end end + + resources :mail_crons do + collection do + get 'delete' + end + end + + resources :mail_cron_logs do + collection do + get 'delete' + end + end + resources :asset_categories resources :asset_tags resources :app_auths