diff --git a/Gemfile b/Gemfile index d15019e..2fd067c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -# Declare your gem's dependencies in bulletin.gemspec. +# Declare your gem's dependencies in email_er.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..bc8e092 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,106 @@ +PATH + remote: . + specs: + er_email (0.0.1) + mongoid (= 4.0.0.beta1) + rails (~> 4.1.0.rc2) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.1.0.rc2) + actionpack (= 4.1.0.rc2) + actionview (= 4.1.0.rc2) + mail (~> 2.5.4) + actionpack (4.1.0.rc2) + actionview (= 4.1.0.rc2) + activesupport (= 4.1.0.rc2) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + actionview (4.1.0.rc2) + activesupport (= 4.1.0.rc2) + builder (~> 3.1) + erubis (~> 2.7.0) + activemodel (4.1.0.rc2) + activesupport (= 4.1.0.rc2) + builder (~> 3.1) + activerecord (4.1.0.rc2) + activemodel (= 4.1.0.rc2) + activesupport (= 4.1.0.rc2) + arel (~> 5.0.0) + activesupport (4.1.0.rc2) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) + arel (5.0.0) + atomic (1.1.16) + bson (2.2.1) + builder (3.2.2) + connection_pool (2.0.0) + erubis (2.7.0) + hike (1.2.3) + i18n (0.6.9) + json (1.8.1) + mail (2.5.4) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.25.1) + minitest (5.3.1) + mongoid (4.0.0.beta1) + activemodel (>= 4.0.0) + moped (~> 2.0.beta6) + origin (~> 2.1) + tzinfo (>= 0.3.37) + moped (2.0.0.rc1) + bson (~> 2.2) + connection_pool (~> 2.0) + optionable (~> 0.2.0) + multi_json (1.9.2) + optionable (0.2.0) + origin (2.1.1) + polyglot (0.3.4) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rails (4.1.0.rc2) + actionmailer (= 4.1.0.rc2) + actionpack (= 4.1.0.rc2) + actionview (= 4.1.0.rc2) + activemodel (= 4.1.0.rc2) + activerecord (= 4.1.0.rc2) + activesupport (= 4.1.0.rc2) + bundler (>= 1.3.0, < 2.0) + railties (= 4.1.0.rc2) + sprockets-rails (~> 2.0.0) + railties (4.1.0.rc2) + actionpack (= 4.1.0.rc2) + activesupport (= 4.1.0.rc2) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.2.2) + sprockets (2.12.0) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.0.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + thor (0.19.1) + thread_safe (0.3.1) + atomic (>= 1.1.7, < 2) + tilt (1.4.1) + treetop (1.4.15) + polyglot + polyglot (>= 0.3.1) + tzinfo (1.1.0) + thread_safe (~> 0.1) + +PLATFORMS + ruby + +DEPENDENCIES + er_email! diff --git a/README.rdoc b/README.rdoc index b237aa4..46ab52c 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,3 +1,3 @@ -= Bulletin += EmailEr This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/Rakefile b/Rakefile index ccd84f8..48f104b 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,7 @@ require 'rdoc/task' RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'Announcement' + rdoc.title = 'ErEmail' rdoc.options << '--line-numbers' rdoc.rdoc_files.include('README.rdoc') rdoc.rdoc_files.include('lib/**/*.rb') diff --git a/app/assets/images/bulletin/.keep b/app/assets/images/email_er/.keep similarity index 100% rename from app/assets/images/bulletin/.keep rename to app/assets/images/email_er/.keep diff --git a/app/assets/javascripts/admin/er_emails.js b/app/assets/javascripts/admin/er_emails.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/admin/er_emails.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/bulletin/.keep b/app/assets/javascripts/email_er/.keep similarity index 100% rename from app/assets/javascripts/bulletin/.keep rename to app/assets/javascripts/email_er/.keep diff --git a/app/assets/stylesheets/admin/er_emails.css b/app/assets/stylesheets/admin/er_emails.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/admin/er_emails.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/assets/stylesheets/bulletin/.keep b/app/assets/stylesheets/email_er/.keep similarity index 100% rename from app/assets/stylesheets/bulletin/.keep rename to app/assets/stylesheets/email_er/.keep diff --git a/app/controllers/admin/er_emails_controller.rb b/app/controllers/admin/er_emails_controller.rb new file mode 100644 index 0000000..add8bf5 --- /dev/null +++ b/app/controllers/admin/er_emails_controller.rb @@ -0,0 +1,223 @@ +# encoding: utf-8 +class Admin::ErEmailsController < OrbitAdminController + include Admin::ErEmailsHelper + before_action ->(module_app = @app_title) { set_variables module_app } + before_action :set_email_er, only: [:edit, :show, :send_email, :test_send_email, :destroy] + + def initialize + super + @app_title = "er_email" + end + + def index + @categories = @module_app.categories.enabled + @table_fields = [:status, :category, 'er_email.mail_subject', 'er_email.created_user'] + + @email_ers = EmailEr.where(:is_preview.in=>[false,nil]).order_by(sort).with_categories(filters("category")).page(params[:page]).per(10) + + if request.xhr? + render :partial => "index" + end + end + + def show + end + + def new + @categories = @module_app.categories.enabled + @email_er = EmailEr.new + @email_er.mail_sentdate = Time.now + end + + def create + @email_er = EmailEr.new(email_er_params) + @email_er.create_user_id = current_user.id + @email_er.update_user_id = current_user.id + # @email_er.save + # build_email(@email_er) + + respond_to do |format| + if @email_er.save + # build_email(@email_er) + + format.html { redirect_to "/admin/er_emails" } + else + format.html { render :action => "new" } + end + end + + end + + def edit + @categories = @module_app.categories.enabled + # @email_er.mail_sentdate = Time.now + end + + def update + uid = params[:id].split('-').last + @email_er = EmailEr.find_by(:uid=>uid) + @email_er.email_confirm = false + @email_er.update_user_id = current_user.id + email_er_params[:email_member_ids] = email_er_params[:email_member_ids].blank? ? [] : email_er_params[:email_member_ids] + # email_er.update_attributes(email_er_params) + # email_er.save + # build_email(email_er) + + respond_to do |format| + if @email_er.update_attributes(email_er_params) + @email_er.save + # build_email(@email_er) + + format.html { redirect_to "/admin/er_emails" } + else + format.html { render :action => "edit" } + end + end + + end + + def destroy + @email_er.destroy + redirect_to "/admin/er_emails" + end + + def delete + if params[:ids] + EmailEr.any_in(:uid => params[:ids]).destroy_all + end + redirect_to "/admin/er_emails" + end + + def preview + if params['preview_type'].eql?('edit') + email_er_data = email_er_params + org_email_er = EmailEr.find(params['email_er_id']) + email_er = org_email_er.clone + email_er.generate_uid + email_er.email_er_files = [] + + if !email_er_data['email_er_files_attributes'].blank? + email_er_data['email_er_files_attributes'].each do |key, email_er_file| + next if !email_er_file['_destroy'].blank? + file = nil + if email_er_file['id'].blank? + file = EmailErFile.new(email_er_file) + file.email_er_id = email_er.id + file.save + else + org_file = EmailErFile.find(email_er_file['id']) + file = org_file.clone + file.email_er_id = email_er.id + file.file = org_file.file + email_er_file.delete('id') + email_er_file.delete('_destroy') + file.update_attributes(email_er_file) + end + + file.save + email_er.email_er_files << file + end + end + + email_er_data.delete('email_er_files_attributes') + email_er.update_attributes(email_er_data) + else + email_er = EmailEr.new(email_er_params) + end + + email_er.is_preview = true + email_er.save + render :text=>page_for_email_er(email_er) + end + + def destroy_preview + email_er = EmailEr.find(params[:id]) + if email_er.is_preview + email_er.destroy + end + render :json=>{'destroy'=>email_er.id.to_s} + end + + def build_email(email_er , test_send = false) + + email = Email.new + email.save + email_er.email_id = email.id + email_er.email_confirm = true if !test_send + email_er.save + + + if !test_send + + @group_mail = email_er.email_addresses + + @mail_sentdate = email_er.mail_sentdate + + else + + @user = MemberProfile.find(User.find(email_er.create_user_id).member_profile_id) + + @group_mail = [@user.email] + + @mail_sentdate = DateTime.now + + end + + email_er.email.update_attributes( + :create_user=>current_user, + :mail_sentdate=>@mail_sentdate, + :module_app=>@module_app, + :mail_to=>@group_mail, + :mail_content => email_er.mail_content , + :mail_subject=>email_er.mail_subject + ) + + if !email_er.email_er_files.blank? + + email.email_files.destroy_all + + email_er.email_er_files.each do | mrfile | + + @mcfile = email.email_files.build + + @mcfile.file = mrfile.file + + @mcfile.title = mrfile.title + + end + + email.save + + end + + OrbitMailer.set_mail(email_er.email).deliver if test_send + + end + + def send_email + if params[:id] + build_email(@email_er) + end + + redirect_to "/admin/er_emails" + end + + def test_send_email + if params[:id] + build_email(@email_er, true) + end + + redirect_to "/admin/er_emails" + end + + private + + def set_email_er + @email_er = EmailEr.find(params[:id]) + end + + def email_er_params + # params[:email_er][:email_sent] = params[:email_er][:email_sent].nil? ? 0 : params[:email_er][:email_sent] + params.require(:email_er).permit! + end +end diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb deleted file mode 100644 index dacd367..0000000 --- a/app/controllers/announcements_controller.rb +++ /dev/null @@ -1,38 +0,0 @@ -class AnnouncementsController < ApplicationController - - def index - announcements = Bulletin.all - announcements.collect do |a| - { - "title" => a.title, - "body" => a.body, - "link_to_show" => OrbitHelper.url_to_show(a.uid,a.title.parameterize), - "more" => "More" - } - end - - end - - def widget - announcements = Bulletin.all - announcements.collect do |a| - { - "title" => a.title, - "subtitle" => a.body, - "link_to_show" => OrbitHelper.url_to_show(a.uid,a.title.parameterize), - "more" => "More", - "link_to_index" => "index" - } - end - end - - - def show - params = OrbitHelper.get_params - announcement = Bulletin.find_by_param(params[:uid]) - { - "title" => announcement.title, - "body" => announcement.body - } - end -end diff --git a/app/helpers/admin/er_emails_helper.rb b/app/helpers/admin/er_emails_helper.rb new file mode 100644 index 0000000..9a021ed --- /dev/null +++ b/app/helpers/admin/er_emails_helper.rb @@ -0,0 +1,27 @@ +module Admin::ErEmailsHelper + def page_for_email_er(email_er) + ann_page = nil + pages = Page.where(:module=>'er_email') + + pages.each do |page| + if page.categories.count ==1 + if page.categories.include?(email_er.category.id.to_s) + ann_page = page + end + end + break if !ann_page.nil? + end + + if ann_page.nil? + pages.each do |page| + if page.categories.include?(email_er.category.id.to_s) + ann_page = page + end + break if !ann_page.nil? + end + end + + ann_page = pages.first if ann_page.nil? + request.protocol+(request.host_with_port+'/admin/er_emails/'+email_er.id).gsub('//','/') rescue "/" + end +end diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb deleted file mode 100644 index bd6658c..0000000 --- a/app/models/bulletin.rb +++ /dev/null @@ -1,24 +0,0 @@ -class Bulletin - include Mongoid::Document - include Mongoid::Timestamps - - field :title, type: String, localize: true - field :body, type: String, localize: true - field :uid, type: String - - # include Slug - - def to_param - I18n.locale - title.parameterize - end - - def self.find_by_param(input) - self.find_by(uid: input) - end - - def generate_uid - self.uid = rand(36**8).to_s(36) - self.save - end -end diff --git a/app/models/email_er.rb b/app/models/email_er.rb new file mode 100644 index 0000000..8b528f1 --- /dev/null +++ b/app/models/email_er.rb @@ -0,0 +1,65 @@ +class EmailEr + include Mongoid::Document + include Mongoid::Timestamps + + include OrbitModel::Status + include OrbitModel::Impression + # encoding: utf-8 + include OrbitTag::Taggable + include OrbitCategory::Categorizable + include Slug + + field :mail_subject + field :mail_sentdate , :type => DateTime + field :mail_content + + field :email_member_ids + field :other_mailaddress + + field :create_user_id + field :update_user_id + + field :email_id + field :email_confirm, :type => Boolean, :default => false + + field :is_preview, :type => Boolean, :default => false + + has_many :email_er_files, :autosave => true, :dependent => :destroy + accepts_nested_attributes_for :email_er_files, :allow_destroy => true + + before_destroy :destroy_email + + scope :can_display,->{where(is_hidden: false)} + + 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 update_user + User.find(update_user_id) rescue nil + end + + def update_user=(user) + self.update_user_id = user.id + end + + def email_members + MemberProfile.find(self.email_member_ids) rescue [] + end + + def email_addresses + addresses = self.email_members.collect{|member| member.email} rescue [] + addresses = addresses +[self.other_mailaddress] if !self.other_mailaddress.blank? + addresses.flatten + end + + def email + mail = Email.find(self.email_id) rescue nil + end + + def destroy_email + mail = Email.find(self.email_id) rescue nil + mail.destroy if !mail.nil? + end + +end diff --git a/app/models/email_er_file.rb b/app/models/email_er_file.rb new file mode 100644 index 0000000..079d9e7 --- /dev/null +++ b/app/models/email_er_file.rb @@ -0,0 +1,23 @@ +# encoding: utf-8 +class EmailErFile + + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :file, AssetUploader + + field :title, localize: true + + 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/admin/er_emails/_form.html.erb b/app/views/admin/er_emails/_form.html.erb new file mode 100644 index 0000000..e973fef --- /dev/null +++ b/app/views/admin/er_emails/_form.html.erb @@ -0,0 +1,211 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/file-type" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + + <%= f.error_messages %> + + +
+ + + + + + +
+ + +
+ + +
+ +
+ <%= select_category(f, @module_app) %> +
+
+ +
+ +
+ <%= f.datetime_picker :mail_sentdate, :no_label => true %> +
+
+ + +
+ +
+ <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'email_er[email_member_ids][]', email_members: @email_er.email_members} %> +
+
+
+ +
+ <%= "#{t("er_email.other_mailaddress")}(#{t("er_email.other_mailaddress_note")})"%> + <%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %> + <%= "#{t("er_email.mail_to_note")}"%> +
+
+
+ +
+ + +
+ + +
+ + +
+ +
+ <%= f.text_field :mail_subject, class: "input-block-level", placeholder: t("er_email.mail_subject") %> +
+
+ + +
+ +
+ <%#= f.text_area :mail_content, :style=>"width:100%", :class => 'ckeditor input-block-level' %> + <%= f.cktext_area :mail_content, rows: 5, class: "input-block-level" %> +
+
+ +
+ + +
+ +
+ + + <% if @email_er && !@email_er.email_er_files.blank? %> +
+ <% @email_er.email_er_files.each_with_index do |email_er_file, i| %> + <%= f.fields_for :email_er_files, email_er_file do |f| %> + <%= render :partial => 'form_file', :object => email_er_file, :locals => {:f => f, :i => i} %> + <% end %> + <% end %> +
+
+ <% end %> + + +
+
+

+ <%= hidden_field_tag 'email_er_file_field_count', @email_er.email_er_files.count %> + <%= t(:add) %> +

+ +
+
+ +
+ +
+ + +
+ <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn', type: :button %> + <%= link_to t('cancel'), admin_er_emails_path, :class=>"btn" %> +
+ + + + + +<% content_for :page_specific_javascript do %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/er_emails/_form_file.html.erb b/app/views/admin/er_emails/_form_file.html.erb new file mode 100644 index 0000000..67dbade --- /dev/null +++ b/app/views/admin/er_emails/_form_file.html.erb @@ -0,0 +1,40 @@ +<%= f.error_messages %> +<% if form_file.new_record? %> +
+<% else %> +
+ <% if form_file.file.blank? %> + <%= t(:no_file) %> + <% else %> + <%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %> + <% end %> +<% end %> +
+ + + + <%= f.text_field :title %> + + + <% if form_file.new_record? %> + + + + <% else %> + + <%= f.hidden_field :id %> + + <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> + + <% end %> +
+
\ No newline at end of file diff --git a/app/views/admin/er_emails/_index.html.erb b/app/views/admin/er_emails/_index.html.erb new file mode 100644 index 0000000..779be3b --- /dev/null +++ b/app/views/admin/er_emails/_index.html.erb @@ -0,0 +1,53 @@ + + + + <% @table_fields.each do |f| %> + <%= thead(f) %> + <% end %> + + + + <% @email_ers.each do |b| %> + + + + + + + + + + <% end %> + +
<%= (b.email_confirm.blank? ? t("er_email.email_no_confirm") : t("er_email.email_have_confirm") ) %><%= b.category.title %> + <%= b.mail_subject %> + + <%= b.update_user.user_name %>
+
" class="footable-row-detail-inner" style="display: none;"> +
+ <%= t("er_email.mail_to") %> : + <% b.email_members.each do |member| %> + <%= member.name %> + <% end %> + <% unless b.other_mailaddress.nil? %> + <% b.other_mailaddress.split(',').each do |mailaddress| %> + <%= mailaddress %> + <% end %> + <% end %> +
+
+
+ +<%= + content_tag :div, class: "bottomnav clearfix" do + content_tag :div, paginate(@email_ers), class: "pagination pagination-centered" + end +%> \ No newline at end of file diff --git a/app/views/admin/er_emails/edit.html.erb b/app/views/admin/er_emails/edit.html.erb new file mode 100644 index 0000000..78018d5 --- /dev/null +++ b/app/views/admin/er_emails/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @email_er, url: admin_er_email_path(@email_er), html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ <%= render :partial => 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/er_emails/index.html.erb b/app/views/admin/er_emails/index.html.erb new file mode 100644 index 0000000..e5f6fea --- /dev/null +++ b/app/views/admin/er_emails/index.html.erb @@ -0,0 +1,5 @@ + + <%= render 'index'%> + + +<%= render 'layouts/delete_modal', delete_options: @delete_options %> \ No newline at end of file diff --git a/app/views/admin/er_emails/new.html.erb b/app/views/admin/er_emails/new.html.erb new file mode 100644 index 0000000..34f6506 --- /dev/null +++ b/app/views/admin/er_emails/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @email_er, url: admin_er_emails_path, html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ <%= render :partial => 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/er_emails/show.html.erb b/app/views/admin/er_emails/show.html.erb new file mode 100644 index 0000000..99e6d0d --- /dev/null +++ b/app/views/admin/er_emails/show.html.erb @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/app/views/announcements/index.html.erb b/app/views/announcements/index.html.erb deleted file mode 100644 index 648b75c..0000000 --- a/app/views/announcements/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render_view %> \ No newline at end of file diff --git a/app/views/announcements/show.html.erb b/app/views/announcements/show.html.erb deleted file mode 100644 index 648b75c..0000000 --- a/app/views/announcements/show.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render_view %> \ No newline at end of file diff --git a/bin/rails b/bin/rails index 08ba0ad..74569c3 100755 --- a/bin/rails +++ b/bin/rails @@ -2,7 +2,7 @@ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. ENGINE_ROOT = File.expand_path('../..', __FILE__) -ENGINE_PATH = File.expand_path('../../lib/announcement/engine', __FILE__) +ENGINE_PATH = File.expand_path('../../lib/er_email/engine', __FILE__) # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..525077e --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,27 @@ +en: + + er_email: + er_email: Email_ER + Group: Group + Title: Title + Content: Content + Files: Files + approval_setting: Approval Setting + approve_email_er_fail: Approval Fail + approve_email_er_success: Approve Successfully + create_email_er_success: Create Successfully + email_confirm: Sent mail to confirm + email_have_confirm: Have confirmed + email_no_confirm: Unconfirmed + mail_resend: Resend + test_send_email: Test Send Email + mail_subject: Mail Subject + mail_content: Mail Content + mail_sentdate: Email Time + mail_to: Email To + mail_to_note: Remember to fill in or choose the people you want to send, or the system couldn't send off. + other_mailaddress: Other Email + other_mailaddress_note: Divide different email accounts with "," + other_mailaddress_note_limit: maximum 1000 characters + email_file_limit: File upload size is limited to 1MB + created_user: Creator \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml new file mode 100644 index 0000000..c4443af --- /dev/null +++ b/config/locales/zh_tw.yml @@ -0,0 +1,27 @@ +zh_tw: + + er_email: + er_email: 寄信群組 + Group: 群組 + Title: 主旨 + Content: 內文 + Files: 檔案 + approval_setting: 審核設定 + approve_email_er_fail: 審核失敗 + approve_email_er_success: 審核成功 + create_email_er_success: 建立資料成功 + mail_resend: 重新寄送 + test_send_email: 測試寄信 + mail_subject: 主旨 + mail_content: 信件內容 + mail_sentdate: 寄送時間 + mail_to: 寄送對象 + mail_to_note: 請記得填寫或選擇寄送對象,若無填寫將導致系統無法確認寄信 + other_mailaddress: 其他Mail + other_mailaddress_note: 輸入多組mail時,請用","逗號隔開 + other_mailaddress_note_limit: 限制1000字元以內 + email_file_limit: 檔案上傳容量限制為10MB + email_confirm: 確認寄送 + email_have_confirm: 已確認 + email_no_confirm: 未確認 + created_user: 建立者 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index e5c56a9..60e3282 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,10 +1,14 @@ Rails.application.routes.draw do - scope "(:locale)", locale: /en|zh_tw/ do - resources :announcements do - collection do - get ':uid/:title', to: 'announcements#show', as: :display - end + locales = Site.first.in_use_locales rescue I18n.available_locales + + scope "(:locale)", locale: Regexp.new(locales.join("|")) do + namespace :admin do + get 'er_email/send_email/:id', to: 'er_emails#send_email' + get 'er_email/test_send_email/:id', to: 'er_emails#test_send_email' + post 'er_email/preview', to: 'er_emails#preview' + get 'er_email/destroy_preview/:id', to: 'er_emails#destroy_preview' + resources :er_emails end end diff --git a/announcement.gemspec b/er_email.gemspec similarity index 60% rename from announcement.gemspec rename to er_email.gemspec index 0c22b51..30721ab 100644 --- a/announcement.gemspec +++ b/er_email.gemspec @@ -1,22 +1,19 @@ $:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: -require "announcement/version" +require "er_email/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "announcement" - s.version = Announcement::VERSION + s.name = "er_email" + s.version = ErEmail::VERSION s.authors = ["RulingDigital"] s.email = ["orbit@rulingcom.com"] s.homepage = "http://www.rulingcom.com" - s.summary = "Announcements for Orbit" - s.description = "Announcements for Orbit" + s.summary = "ErEmails for Orbit" + s.description = "ErEmails for Orbit" s.license = "MIT" s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] s.test_files = Dir["test/**/*"] - - s.add_dependency "rails", "~> 4.1.0.rc2" - s.add_dependency "mongoid", "4.0.0.beta1" end diff --git a/lib/announcement.rb b/lib/announcement.rb deleted file mode 100644 index 1feec47..0000000 --- a/lib/announcement.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "announcement/engine" - -module Announcement -end diff --git a/lib/announcement/engine.rb b/lib/announcement/engine.rb deleted file mode 100644 index 4c7b94d..0000000 --- a/lib/announcement/engine.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Announcement - class Engine < ::Rails::Engine - initializer "announcement" do - OrbitApp.registration "Announcement", :type => "ModuleApp" do - module_label "announcement.announcement" - base_url File.expand_path File.dirname(__FILE__) - end - end - end -end \ No newline at end of file diff --git a/lib/er_email.rb b/lib/er_email.rb new file mode 100644 index 0000000..0647b8f --- /dev/null +++ b/lib/er_email.rb @@ -0,0 +1,4 @@ +require "er_email/engine" + +module ErEmail +end diff --git a/lib/er_email/engine.rb b/lib/er_email/engine.rb new file mode 100644 index 0000000..02050ef --- /dev/null +++ b/lib/er_email/engine.rb @@ -0,0 +1,39 @@ +module ErEmail + class Engine < ::Rails::Engine + initializer "er_email" do + OrbitApp.registration "ErEmail", :type => "ModuleApp" do + module_label "er_email.er_email" + base_url File.expand_path File.dirname(__FILE__) + taggable "EmailEr" + categorizable + authorizable + + side_bar do + head_label_i18n 'er_email.er_email', icon_class: "icons-paperplane" + available_for [:admin,:manager,:sub_manager] + active_for_controllers (['admin/er_emails']) + head_link_path "admin_er_emails_path" + + context_link 'all', + :link_path=>"admin_er_emails_path" , + :priority=>1, + :active_for_action=>{'admin/er_emails'=>'index'}, + :available_for => [:all] + context_link 'new_', + :link_path=>"new_admin_er_email_path" , + :priority=>2, + :active_for_action=>{'admin/er_emails'=>'new'}, + :available_for => [:sub_manager] + context_link 'categories', + :link_path=>"admin_module_app_categories_path" , + :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'er_email').id}", + :priority=>3, + :active_for_action=>{'admin/er_emails'=>'categories'}, + :active_for_category => 'ErEmail', + :available_for => [:manager] + end + + end + end + end +end \ No newline at end of file diff --git a/lib/announcement/version.rb b/lib/er_email/version.rb similarity index 54% rename from lib/announcement/version.rb rename to lib/er_email/version.rb index 1b52275..9893c44 100644 --- a/lib/announcement/version.rb +++ b/lib/er_email/version.rb @@ -1,3 +1,3 @@ -module Announcement +module ErEmail VERSION = "0.0.1" end diff --git a/lib/tasks/bulletin_tasks.rake b/lib/tasks/email_er_tasks.rake similarity index 76% rename from lib/tasks/bulletin_tasks.rake rename to lib/tasks/email_er_tasks.rake index cfe4f33..46f4c45 100644 --- a/lib/tasks/bulletin_tasks.rake +++ b/lib/tasks/email_er_tasks.rake @@ -1,4 +1,4 @@ # desc "Explaining what the task does" -# task :bulletin do +# task :email_er do # # Task goes here # end diff --git a/test/bulletin_test.rb b/test/bulletin_test.rb deleted file mode 100644 index 10cd840..0000000 --- a/test/bulletin_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class BulletinTest < ActiveSupport::TestCase - test "truth" do - assert_kind_of Module, Bulletin - end -end diff --git a/test/controllers/admin/er_emails_controller_test.rb b/test/controllers/admin/er_emails_controller_test.rb new file mode 100644 index 0000000..e834df0 --- /dev/null +++ b/test/controllers/admin/er_emails_controller_test.rb @@ -0,0 +1,14 @@ +require 'test_helper' + +class Admin::ErEmailsControllerTest < ActionController::TestCase + test "should get new" do + get :new + assert_response :success + end + + test "should get create" do + get :create + assert_response :success + end + +end diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 091c8f5..336a7f8 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -9,7 +9,7 @@ require "sprockets/railtie" require "rails/test_unit/railtie" Bundler.require(*Rails.groups) -require "bulletin" +require "email_er" module Dummy class Application < Rails::Application diff --git a/test/email_er_test.rb b/test/email_er_test.rb new file mode 100644 index 0000000..faefcb6 --- /dev/null +++ b/test/email_er_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class EmailErTest < ActiveSupport::TestCase + test "truth" do + assert_kind_of Module, EmailEr + end +end diff --git a/test/helpers/admin/er_emails_helper_test.rb b/test/helpers/admin/er_emails_helper_test.rb new file mode 100644 index 0000000..a7a6825 --- /dev/null +++ b/test/helpers/admin/er_emails_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class Admin::ErEmailsHelperTest < ActionView::TestCase +end