commit 34a13479d4aa267c092e3212b5bd6d6a259ac020 Author: Manson Wang Date: Wed Feb 19 11:22:48 2014 +0800 ntue er_email module diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..e9d2bcf --- /dev/null +++ b/Gemfile @@ -0,0 +1,17 @@ +source "http://rubygems.org" + +# Declare your gem's dependencies in er_email.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# jquery-rails is used by the dummy application +gem "jquery-rails" + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use debugger +# gem 'debugger' diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..5146945 --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2013 YOURNAME + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..5e75970 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += ErEmail + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..a021c8b --- /dev/null +++ b/Rakefile @@ -0,0 +1,40 @@ +#!/usr/bin/env rake +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end +begin + require 'rdoc/task' +rescue LoadError + require 'rdoc/rdoc' + require 'rake/rdoctask' + RDoc::Task = Rake::RDocTask +end + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'ErEmail' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +load 'rails/tasks/engine.rake' + + + +Bundler::GemHelper.install_tasks + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + + +task :default => :test diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..307a4ac --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,23 @@ +class ApplicationController < ActionController::Base + protect_from_forgery + before_filter :set_locale + + # Set I18n.locale + def set_locale + # update session if passed + session[:locale] = params[:locale] if params[:locale] + + # set locale based on session or default + begin + # check if locale is valid for non site pages + if !VALID_LOCALES.include?(session[:locale]) + I18n.locale = I18n.default_locale + else + I18n.locale = session[:locale] + end + rescue + I18n.locale = I18n.default_locale + end + end + +end diff --git a/app/controllers/panel/er_email/back_end/approvals_controller.rb b/app/controllers/panel/er_email/back_end/approvals_controller.rb new file mode 100644 index 0000000..b000ee6 --- /dev/null +++ b/app/controllers/panel/er_email/back_end/approvals_controller.rb @@ -0,0 +1,146 @@ +# encoding: utf-8 +class Panel::ErEmail::BackEnd::ApprovalsController < OrbitBackendController + before_filter :authenticate_user! + before_filter :is_admin? + include AdminHelper + # layout 'admin' + + + def preview_and_approve + email_group_data + @email_er = EmailEr.find params[:email_er_id] + end + + def approve + notice = "" + @email_er = EmailEr.find params[:email_er_id] + @email_er.proc_check(params[:email_er][:is_checked],params[:email_er][:not_checked_reason]) + @email_er.de_pending + if @email_er.save + + if @email_er.is_checked == true and !@email_er.is_rejected + send_email_data(@email_er) + end + + notice = t('er_email.approve_email_er_success') + else + notice = t('er_email.approve_email_er_fail') + end + redirect_to(panel_er_email_back_end_email_ers_url,:notice => notice) + end + + def setting + @sys_users = User.all(conditions: {admin: false}).includes(:avatar).not_guest_user + @email_er_categorys = EmailErCategory.all + @options_from_collection_for_select_email_er_categorys = @email_er_categorys.collect{|bc| [bc.title,bc.id] } + if params.has_key? :category + @email_er_category = EmailErCategory.find params[:category][:id] + else + @email_er_category = @email_er_categorys.first + end + preload_object_auth = @email_er_category.get_object_auth_by_title('fact_check') + @users_array = preload_object_auth.privilege_users rescue [] + respond_to do |format| + format.html + format.js + end + end + + def update_setting + object_auth = update_setting_by_params + if object_auth.save! + flash[:notice] = t('update.success_') + else + flash[:notice] = t('update.fail') + end + end + + def user_list + @email_er_category = EmailErCategory.find params[:category][:id] + end + + protected + def update_setting_by_params + category = EmailErCategory.find params[:category][:id] + privilege_users = params[:users].collect{|key,value| User.find key } rescue [] + object_auth_ary = category.object_auths.where(title: 'fact_check') || (category.object_auths.create :title=> 'fact_check') + object_auth = object_auth_ary.first + object_auth.privilege_users = privilege_users + object_auth + end + + def send_email_data(email_er) + + @user = User.find(email_er.create_user_id) + + email_group_data + + @group_mail = Array.new + + email_er.email_group.each do |egroup| + + if @email_group_data.include?(egroup) and (egroup == 'e_0' or egroup == 'e_1' or egroup == 'e_2' or egroup == 'e_3') + + @group_mail << @email_group_data[egroup]["email"] + + elsif @email_group_data.include?(egroup) and egroup == 'e_4' + + @group_mail << email_er.other_mailaddress + + end + + end + + if !@group_mail.join.blank? + + @mail_content = { + "text" => email_er.mail_content + } + + @mail_cron = { + :mail_from_app => 'er_email', + :mail_from => @user.email, + :mail_reply_to => @user.email, + :mail_subject => email_er.mail_subject, + :mail_to => @group_mail.join(','), + :mail_content => @mail_content , + # :mail_sentdate => email_er.mail_sentdate, + :mail_sentdate => DateTime.now, + :create_user_id => email_er.create_user_id, + :update_user_id => email_er.create_user_id + } + + @mail_cron = MailCron.new(@mail_cron) + + email_er.email_er_files.each do | mrfile | + + @mcfile = @mail_cron.mail_cron_files.build + + tmp_file = File.new(mrfile.file_identifier, 'w+') + + tmp_file.write(Mongo::GridFileSystem.new(Mongoid.database).open(mrfile.file.url.gsub("/gridfs/", ""), 'r').read.force_encoding("UTF-8")) + + @mcfile.file = tmp_file + + @mcfile.title = mrfile.title + + # delete file + FileUtils.rm_f(tmp_file) + + end + + @mail_cron.save + + MailCron.send_mail_now(@mail_cron.id) + + end + + end + + def email_group_data + + @email_group_data = EmailEr.email_group_data + + end + +end diff --git a/app/controllers/panel/er_email/back_end/email_er_categorys_controller.rb b/app/controllers/panel/er_email/back_end/email_er_categorys_controller.rb new file mode 100644 index 0000000..0d30b78 --- /dev/null +++ b/app/controllers/panel/er_email/back_end/email_er_categorys_controller.rb @@ -0,0 +1,126 @@ +class Panel::ErEmail::BackEnd::EmailErCategorysController < OrbitBackendController + include OrbitControllerLib::DivisionForDisable + + open_for_manager :except => [:index,:get_categorys_json] + open_for_sub_manager :except => [:index,:get_categorys_json] + + + def index + @email_er_categorys = get_categories_for_index("EmailErCategory") + @email_er_category = EmailErCategory.new(:display => 'List') + + @url = panel_er_email_back_end_email_er_categorys_path + + respond_to do |format| + format.html # index.html.erb + format.js + end + end + + def get_categorys_json + categorys = EmailErCategory.all + data = Array.new + + categorys.each do |c| + data << { + category: c.title, + link: "#{url_for( :action => "index", + :controller => "panel/er_email/back_end/email_ers", + :format => :rss, + :only_path => false, + :inner=>true, + :category_id => c )}" + } + end + render :json => JSON.pretty_generate(data) + end + + # GET /email_ers/1 + # GET /email_ers/1.xml + def show + @email_er_category = EmailErCategory.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.js + end + end + + # GET /email_ers/new + # GET /email_ers/new.xml + def new + @email_er_category = EmailErCategory.new(:display => 'List') + + respond_to do |format| + format.html # new.html.erb + format.js + end + end + + # GET /email_ers/1/edit + def edit + @email_er_category = EmailErCategory.find(params[:id]) + + @url = panel_er_email_back_end_email_er_category_path(@email_er_category) + + respond_to do |format| + format.html + format.js + end + end + + # POST /email_ers + # POST /email_ers.xml + def create + @email_er_category = EmailErCategory.new(params[:email_er_category]) + + respond_to do |format| + if @email_er_category.save + format.html { redirect_to(panel_er_email_back_end_email_er_categorys_url, :notice => t('email_er_category.create_email_er_category_success')) } + format.js + else + format.html { render :action => "new" } + format.js { render action: "new" } + end + end + end + + # PUT /email_ers/1 + # PUT /email_ers/1.xml + def update + @email_er_category = EmailErCategory.find(params[:id]) + + @url = panel_er_email_back_end_email_er_category_path(@email_er_category) + + respond_to do |format| + if @email_er_category.update_attributes(params[:email_er_category]) + format.html { redirect_to(panel_er_email_back_end_email_er_categorys_url, :notice => t('email_er_category.update_email_er_category_success')) } + # format.xml { head :ok } + format.js + else + format.html { render :action => "edit" } + format.js { render :action => "edit" } + end + end + end + + # DELETE /email_ers/1 + # DELETE /email_ers/1.xml + def destroy + @email_er_category = EmailErCategory.find(params[:id]) + @email_er_category.disable = @email_er_category.disable ? false : true + + if @email_er_category.save! + respond_to do |format| + flash[:notice] = t("update.success_") + # flash[:error] += @email_er_category.disable ? t(:enable) : t(disable) + format.html { redirect_to(panel_er_email_back_end_email_er_categorys_url) } + # format.xml { head :ok } + format.js + end + else + flash[:error] = t("update.fail") + format.html { render :action => "index" } + end + end +end diff --git a/app/controllers/panel/er_email/back_end/email_ers_controller.rb b/app/controllers/panel/er_email/back_end/email_ers_controller.rb new file mode 100644 index 0000000..056459d --- /dev/null +++ b/app/controllers/panel/er_email/back_end/email_ers_controller.rb @@ -0,0 +1,314 @@ +class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController + # before_filter :for_app_manager,:except => [:index,:show] + # include OrbitControllerLib::DivisionForDisable + + open_for_approver + open_for_sub_manager + + before_filter :only => [ :new, :create, :edit, :update ] do |controller| + @categories = get_categories_for_form + end + + def preview + email_er = EmailEr.new params + @preview_obj = email_er.to_preview + @preview_obj.save + render '/shared/preview/preview.html.erb',:layout=>false + end + + def index + email_group_data + + @categories = get_categories_for_index + @statuses = get_statuses + category_ids = @categories.collect{|t| t.id} + + if params[:sort].blank? + params[:direction] = 'desc' + params[:sort] = 'status' + params[:sort_options] = ['is_pending', 'is_checked', 'is_rejected'] + end + + @email_ers = get_sorted_and_filtered("email_er", :category_id.in => category_ids) + respond_to do |format| + format.html # index.html.erb + format.js { } + format.xml { render :xml => @email_ers } + end + end + + # GET /email_ers/1 + # GET /email_ers/1.xml + + def show + + email_group_data + + @item = Page.find(params[:page_id]) rescue nil + if params[:preview] == "true" + preview_content + else + @email_er = EmailEr.all.can_display.where(_id: params[:id]).first + if @email_er and !@email_er.disable? and !@email_er.is_rejected + if @email_er.enabled_for_lang(I18n.locale.to_s) + delayed_impressionist(@email_er) + # get_categorys + else + render :text => "
#{t('sys.can_not_display_due_to_no_context')}
".html_safe + end + else + render :nothing => true, :status => 403 + end + end + + end + + def preview_content + @email_er = EmailEr.find params[:id] rescue nil + @email_er = Preview.find(params[:id]).get_virtual_object if @email_er.nil? + # get_categorys + end + + # GET /email_ers/new + # GET /email_ers/new.xml + def new + + email_group_data + + @email_er = EmailEr.new(:mail_sentdate => DateTime.now) + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @email_er } + end + end + + # GET /email_ers/1/edit + def edit + + email_group_data + + @email_er = EmailEr.find(params[:id]) + + is_authorized_sub_manager = @email_er.category.auth_sub_manager.authorized_user_ids rescue nil + + if !(is_manager? || is_admin? || is_authorized_sub_manager.include?(current_user.id)) + redirect_to :action => :index + else + # @summary_variable = @bulletin.summary_variable + + @link_url = panel_er_email_back_end_email_ers_path(@email_er) + + @tags = get_tags + end + + end + + # POST /email_ers + # POST /email_ers.xml + def create + + email_group_data + + @email_er = EmailEr.new(params[:email_er]) + @email_er.create_user_id = current_user.id + @email_er.update_user_id = current_user.id + + if(is_manager? || is_admin?) + @email_er.is_checked = true + @email_er.is_rejected = false + @email_er.de_pending + end + + respond_to do |format| + if @email_er.save + + if @email_er.is_checked == true and !@email_er.is_rejected + send_email_data(@email_er) + end + + format.html { redirect_to(panel_er_email_back_end_email_ers_url) } + format.xml { render :xml => @email_er, :status => :created, :location => @email_er } + # format.js + format.js { + @info = {"success"=>"true","redirect_url"=>panel_er_email_back_end_email_ers_url} + flash[:notice] = t('er_email.create_er_email_success') + render "/shared/preview/after_create.js.erb" + } + else + format.html { render :action => "new" } + format.xml { render :xml => @email_er.errors, :status => :unprocessable_entity } + format.js { + @info = {"success"=>"false","redirect_url"=>new_panel_er_email_back_end_email_er_url(:email_er => @email_er)} + session[:in_validate_object] = @email_er + render "/shared/preview/after_create.js.erb" + } + end + end + end + + # PUT /email_ers/1 + # PUT /email_ers/1.xml + def update + + email_group_data + + @email_er = EmailEr.find(params[:id]) + + @email_er.update_user_id = current_user.id + + respond_to do |format| + if @email_er.update_attributes(params[:email_er]) + + if(is_manager? || is_admin?) + @email_er.is_checked = true + @email_er.is_rejected = false + @email_er.de_pending! + end + + if @email_er.is_checked == true and !@email_er.is_rejected + send_email_data(@email_er) + end + + format.html { redirect_to(panel_er_email_back_end_email_ers_url(:page => params[:page])) } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @email_er.errors, :status => :unprocessable_entity } + end + end + end + + # DELETE /email_ers/1 + # DELETE /email_ers/1.xml + def destroy + @email_er = EmailEr.find(params[:id]) + @email_er.destroy + + respond_to do |format| + format.html { redirect_to(panel_er_email_back_end_email_ers_url) } + # format.xml { head :ok } + format.js + end + end + + def delete + if params[:ids] + # email_ers = EmailEr.any_in(:_id => params[:ids]).destroy_all + end + redirect_to panel_er_email_back_end_email_ers_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + + def email_resend + if params[:id] + @email_er = EmailEr.find(params[:id]) + + @email_er.is_checked = false + @email_er.is_pending = true + + @email_er.save + + end + redirect_to panel_er_email_back_end_email_ers_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + + def test_send_email + if params[:id] + @email_er = EmailEr.find(params[:id]) + + if (@email_er.create_user_id == current_or_guest_user.id) || is_manager? + if current_or_guest_user.admin? || (!@email_er.is_rejected? && !@email_er.is_checked?) + if @email_er.is_pending + send_email_data( @email_er , true ) + end + end + end + end + redirect_to panel_er_email_back_end_email_ers_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + + protected + + def send_email_data(email_er , test_send = false) + + @user = User.find(email_er.create_user_id) + + if !test_send + + email_group_data + + @group_mail = Array.new + + email_er.email_group.each do |egroup| + + if @email_group_data.include?(egroup) and (egroup == 'e_0' or egroup == 'e_1' or egroup == 'e_2' or egroup == 'e_3') + + @group_mail << @email_group_data[egroup]["email"] + + elsif @email_group_data.include?(egroup) and egroup == 'e_4' + + @group_mail << email_er.other_mailaddress + + end + + end + + else + + @group_mail = [@user.email] + + end + + if !@group_mail.join.blank? + + @mail_content = { + "text" => email_er.mail_content + } + + @mail_cron = { + :mail_from_app => 'er_email', + :mail_from => @user.email, + :mail_reply_to => @user.email, + :mail_subject => email_er.mail_subject, + :mail_to => @group_mail.join(','), + :mail_content => @mail_content , + # :mail_sentdate => email_er.mail_sentdate, + :mail_sentdate => DateTime.now, + :create_user_id => email_er.create_user_id, + :update_user_id => email_er.create_user_id + } + + @mail_cron = MailCron.new(@mail_cron) + + email_er.email_er_files.each do | mrfile | + + @mcfile = @mail_cron.mail_cron_files.build + + tmp_file = File.new(mrfile.file_identifier, 'w+') + + tmp_file.write(Mongo::GridFileSystem.new(Mongoid.database).open(mrfile.file.url.gsub("/gridfs/", ""), 'r').read.force_encoding("UTF-8")) + + @mcfile.file = tmp_file + + @mcfile.title = mrfile.title + + # delete file + FileUtils.rm_f(tmp_file) + + end + + @mail_cron.save + + MailCron.send_mail_now(@mail_cron.id) + + end + + end + + def email_group_data + + @email_group_data = EmailEr.email_group_data + + end + +end diff --git a/app/models/email_er.rb b/app/models/email_er.rb new file mode 100644 index 0000000..99811b0 --- /dev/null +++ b/app/models/email_er.rb @@ -0,0 +1,126 @@ +# encoding: utf-8 +class EmailEr + include Mongoid::Document + include Mongoid::Timestamps + include Mongoid::MultiParameterAttributes + + include OrbitCategory::Categorizable + include OrbitCoreLib::Preview + + include OrbitModel::LanguageRestrict + include OrbitModel::Status + include OrbitModel::TimeFrame + + include Tire::Model::Search + include Tire::Model::Callbacks + + field :mail_subject + field :mail_sentdate , :type => DateTime + field :mail_content + + field :create_user_id + field :update_user_id + + field :is_checked, :type => Boolean, :default => false + field :is_pending, :type => Boolean, :default => true + field :is_rejected, :type => Boolean, :default => false + + field :not_checked_reason + + field :email_group, :type => Array, default: [] + field :other_mailaddress + + scope :can_display,where(is_hidden: false) + + has_many :email_er_files, :autosave => true, :dependent => :destroy + + accepts_nested_attributes_for :email_er_files, :allow_destroy => true + + validates :mail_subject,presence:{message:'blank is not allowed'} + validates :other_mailaddress, + :length => {:maximum => 1000, :message => I18n.t("er_email.other_mailaddress_note_limit")} + + def proc_check(check,not_pass_info = "") + self.is_checked = true + if check =="true" + self.is_rejected = false + elsif check == "false" + self.is_rejected = true + self.not_checked_reason = not_pass_info + end + end + + def de_pending + self.is_pending = false + end + + def de_pending! + de_pending + self.save! + end + + def is_checked? + !self.is_pending && self.is_checked && (self.is_rejected == false) + end + + def is_pending? + self.is_pending + end + + def is_rejected? + !self.is_pending && self.is_rejected && (self.is_rejected == true) + end + + def get_email_group_data(email_group_data) + + group_mail = Array.new + + self.email_group.each do |egroup| + + if email_group_data.include?(egroup) and (egroup == 'e_0' or egroup == 'e_1' or egroup == 'e_2' or egroup == 'e_3') + + #group_mail << "#{email_group_data[egroup]["email"]}(#{email_group_data[egroup]["name"]})" + group_mail << "#{email_group_data[egroup]["name"]}" + + elsif email_group_data.include?(egroup) and egroup == 'e_4' + + self.other_mailaddress.split(",").each do |otmail| + + group_mail << "#{otmail}(#{email_group_data[egroup]["name"]})" + + end + + end + + end + + group_mail.join("
").html_safe + + end + + def to_preview + preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_er_email_back_end_email_er_path",:object_class_type=>"EmailEr") + + self.email_er["email_er_files_attributes"].each_with_index do |atr,idx| + preview_object.preview_files.build(:file=>self.email_er["email_er_files_attributes"][idx.to_s],:field_name_for_rebuild=>'email_er_files',:file_in_array=>true) + end unless self.email_er["email_er_files_attributes"].nil? + + preview_object.object = self.email_er.except("email_er_files_attributes") + preview_object + end + + protected + + def self.email_group_data + + @email_group_data = { + 'e_0'=> {"name"=>I18n.t('er_email.email_group_data_0'), "email"=>"alluser@tea.ntue.edu.tw"}, + 'e_1'=> {"name"=>I18n.t('er_email.email_group_data_1'), "email"=>"allstu@tea.ntue.edu.tw"}, + 'e_2'=> {"name"=>I18n.t('er_email.email_group_data_2'), "email"=>"allgrad@tea.ntue.edu.tw"}, + 'e_3'=> {"name"=>I18n.t('er_email.email_group_data_3'), "email"=>"allad@tea.ntue.edu.tw"}, + 'e_4'=> {"name"=>I18n.t('er_email.email_group_data_4')} + } + + end + +end \ No newline at end of file diff --git a/app/models/email_er_category.rb b/app/models/email_er_category.rb new file mode 100644 index 0000000..0820e8f --- /dev/null +++ b/app/models/email_er_category.rb @@ -0,0 +1,47 @@ +# encoding: utf-8 + +class EmailErCategory + include Mongoid::Document + include Mongoid::Timestamps + include OrbitCoreLib::ObjectAuthable + include OrbitCoreLib::ObjectDisable + # include Sunspot::Mongo + # include Mongoid::MultiParameterAttributes + APP_NAME = 'ErEmail' + ObjectAuthTitlesOptions = %W{submit_new fact_check} + AfterObjectAuthUrl = '/panel/er_email/back_end/email_er_categorys' + + field :disable, type: Boolean, :default => false + field :display + field :key + field :title, localize: true + + has_many :email_ers + + validates :title, :at_least_one => true + + # searchable do + # text :titles do + # title_translations.to_a.collect{|t| t[1]} + # end + + # boolean :frontend_search do + # !disable + # end + + # text :files do + # email_ers.can_display.collect{|t| t.title_translations.to_a.collect{|t| t[1]}} + # end + + # end + + + def pp_object + title + end + + def self.from_id(id) + EmailErCategory.find(id) rescue nil + end + +end \ No newline at end of file diff --git a/app/models/email_er_file.rb b/app/models/email_er_file.rb new file mode 100644 index 0000000..fb1db3b --- /dev/null +++ b/app/models/email_er_file.rb @@ -0,0 +1,23 @@ +class EmailErFile + + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :file, AssetUploader + + field :should_destroy, :type => Boolean + field :title + + belongs_to :email_er + + validate :file_size + + private + + def file_size + if file.file.size > 10.megabytes + errors.add( :file, I18n.t("er_email.email_file_limit")) + end + end + +end diff --git a/app/views/panel/er_email/back_end/approvals/_modal_approve.html.erb b/app/views/panel/er_email/back_end/approvals/_modal_approve.html.erb new file mode 100644 index 0000000..9729986 --- /dev/null +++ b/app/views/panel/er_email/back_end/approvals/_modal_approve.html.erb @@ -0,0 +1,99 @@ + <% if email_er -%> + + + +<% end -%> \ No newline at end of file diff --git a/app/views/panel/er_email/back_end/approvals/_modal_list.html.erb b/app/views/panel/er_email/back_end/approvals/_modal_list.html.erb new file mode 100644 index 0000000..fb84dde --- /dev/null +++ b/app/views/panel/er_email/back_end/approvals/_modal_list.html.erb @@ -0,0 +1,44 @@ +<% if email_er_category -%> + +