From 048f67c6da1b3d7d02fcc8379930bcfca1c7da8f Mon Sep 17 00:00:00 2001 From: Spen Date: Wed, 16 Oct 2013 15:08:33 +0800 Subject: [PATCH] fix ntue new member default non-administrator and announcement image size & file name cannot be null --- app/models/user/user.rb | 2 +- .../back_end/bulletins_controller.rb | 8 ++++ .../announcement/app/models/bulletin_file.rb | 10 +++++ .../back_end/bulletins/_form.html.erb | 37 +++++++++---------- .../bulletins/_form_bulletin_file.html.erb | 2 + .../announcement/config/locales/en.yml | 1 + .../announcement/config/locales/zh_tw.yml | 1 + 7 files changed, 40 insertions(+), 21 deletions(-) diff --git a/app/models/user/user.rb b/app/models/user/user.rb index a2c7e2472..09e2f45a4 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -7,7 +7,7 @@ class User mount_uploader :avatar, AvatarUploader - field :admin, :type => Boolean, :default => true + field :admin, :type => Boolean, :default => false field :active_role field :user_id field :sid diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index ac19b4687..0b93a2b21 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -23,6 +23,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController def index + + email_group_data + # @bulletins = Bulletin.all # @bulletins = Bulletin.desc("postdate desc") get_categorys('BulletinCategory',params[:bulletin_category_id]) @@ -116,6 +119,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # POST /bulletins # POST /bulletins.xml def create + + email_group_data + @tags = get_tags if params[:bulletin_link] @@ -221,6 +227,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController def update + email_group_data + @bulletin = Bulletin.find(params[:id]) # @bulletin.image.clear if params[:bulletin][:image_del] == '1' diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_file.rb b/vendor/built_in_modules/announcement/app/models/bulletin_file.rb index 2912fc976..4540399b4 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin_file.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin_file.rb @@ -11,4 +11,14 @@ class BulletinFile belongs_to :bulletin + validate :check_file_title + + private + + def check_file_title + if self.title.blank? + errors.add( :file, I18n.t("announcement.file_name_not_null")) + end + end + end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index c3694ee31..284bf8276 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -22,7 +22,7 @@ <% end %> - <%= t("ad.widget_info_for_ad_image_size", :best_size=> "290px x 150px") %> + <%= t("ad.widget_info_for_ad_image_size", :best_size=> "290px x 230px") %>
<%= t(:browse) %> <%= f.file_field :image, :id => "input-upload", :class => '', :onchange => "document.getElementById('fu').innerHTML = this.form.fu.value = this.value;" %> @@ -278,32 +278,29 @@

- <%#= f.datetime_picker :email_sentdate, :picker_type => 'separated', :label => t("announcement.email_sentdate") %> - -
+ +
- <%= f.label :email_group ,t("announcement.email_group")%> -
- -
+ <%= f.label :email_group ,t("announcement.email_group")%> +
+ +
- <%= f.label :other_mailaddress ,"#{t("announcement.other_mailaddress")}(#{t("announcement.other_mailaddress_note")})"%> - <%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %> + <%= f.label :other_mailaddress ,"#{t("announcement.other_mailaddress")}(#{t("announcement.other_mailaddress_note")})"%> + <%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %>
- -
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb index 1cd0d6f38..10e8275f0 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb @@ -1,5 +1,7 @@ <% # encoding: utf-8 %> +<%= f.error_messages %> + " class='list_item'>
diff --git a/vendor/built_in_modules/announcement/config/locales/en.yml b/vendor/built_in_modules/announcement/config/locales/en.yml index 4795124d2..c1068fd29 100644 --- a/vendor/built_in_modules/announcement/config/locales/en.yml +++ b/vendor/built_in_modules/announcement/config/locales/en.yml @@ -25,6 +25,7 @@ en: file: Attachment file_description: File Description file_name: File Name + file_name_not_null: Name cannot be null frontend: bulletins: Announcement front-end search_result: Search result diff --git a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml index 133c1aae9..5e736d163 100644 --- a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml @@ -25,6 +25,7 @@ zh_tw: file: 附加檔案 file_description: 檔案描述 file_name: 檔案名稱 + file_name_not_null: 名稱不得為空值 frontend: bulletins: 公告前台 search_result: 搜尋結果頁