From a810260e14ca62c7d4a5a0f298712664d2097e39 Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Sun, 24 Sep 2023 15:19:52 +0800 Subject: [PATCH] Fix bug. --- app/helpers/admin/news_helper.rb | 3 ++- app/views/admin/news/_form.html.erb | 8 ++++---- app/views/admin/news/_index.html.erb | 2 +- config/locales/en.yml | 23 ++++++++++++++++++++++- config/locales/zh_tw.yml | 5 ++--- lib/news/engine.rb | 10 +++++----- 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/app/helpers/admin/news_helper.rb b/app/helpers/admin/news_helper.rb index 8bc0b41..1460b5c 100644 --- a/app/helpers/admin/news_helper.rb +++ b/app/helpers/admin/news_helper.rb @@ -25,7 +25,8 @@ module Admin::NewsHelper request.protocol+(request.host_with_port+ann_page.url+'/'+news_bulletin.to_param).gsub('//','/') rescue "/" end - def send_rejection_email(news) + + def send_rejection_email(news) user = User.find(news.create_user_id) rescue nil if !user.nil? email = user.member_profile.email diff --git a/app/views/admin/news/_form.html.erb b/app/views/admin/news/_form.html.erb index 8f78747..a1dedba 100644 --- a/app/views/admin/news/_form.html.erb +++ b/app/views/admin/news/_form.html.erb @@ -161,8 +161,8 @@
- - + +
<% @site_in_use_locales.each do |locale| %> @@ -482,7 +482,7 @@ var validate_image = function(){ var validate = true, file_size = 0; - if($("#user_default_image").prop("checked")){ + if($("#use_default_image").prop("checked")){ return validate; }else{ fileupload_alert = $("#news_bulletin_image").parent().parent().parent().find('.fileupload-alert'); @@ -496,7 +496,7 @@ } } if(!validate){ - alert("您還沒有上傳封面圖片"); + alert("<%=t('news.cover_image_not_yet_upload')%>"); fileupload_alert.text("<%= t("news.file_size")%>: "+file_size.toFixed(1)+"MB , <%= t("news.file_size_limit") %>: "+fileupload_size_limit_mb+"MB"); fileupload_alert.show(); $("#basic").removeClass("active"); diff --git a/app/views/admin/news/_index.html.erb b/app/views/admin/news/_index.html.erb index 4ccb6ed..ca27305 100644 --- a/app/views/admin/news/_index.html.erb +++ b/app/views/admin/news/_index.html.erb @@ -103,7 +103,7 @@ <% Unit.where({:id => b.unit_id}).each do |u| %> <%= u.name %> <% end %> - <% Department.where({:id => b.department}).each do |d| %> + <% Department.where({:id => b.department_id}).each do |d| %> -<%= d.name %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 38b174a..116034b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,6 +1,27 @@ en: - + module_name: + news: News + news_bulletin: + use_default_image: Use Default Image + all_category: All Category + campus_news: Campus News + category: Category + create_news_bulletin_category_success: News Category create successfully + create_news_bulletin_success: News create successfully + department: Department + editing_news: Edit News + editing_news_category: Edit Category + error: + no_avilb_cate_for_posting: News must have a category to send, please contact the administrator + hot: Headlines + news_bulletins: News + new_news_category: Create News Category + search: Search News + update_news_bulletin_category_success: News Category update successfully + update_news_bulletin_success: News update successfully + ut_prompt: Please choose department news: + cover_image_not_yet_upload: The cover image has not been uploaded yet. admins: Unit Setting unit: Department category: Category diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index c63d715..d8f82b2 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -1,10 +1,8 @@ zh_tw: - module_name: news: 新聞 - news_bulletin: - user_default_image: 或使用預設圖片 + use_default_image: 或使用預設圖片 all_category: 全部類別 campus_news: 校園新聞 category: 分類 @@ -23,6 +21,7 @@ zh_tw: update_news_bulletin_success: 新聞已成功更新 ut_prompt: 請選擇單位 news: + cover_image_not_yet_upload: 您還沒有上傳封面圖片 unit: 單位 category: 分類 department: 系所 diff --git a/lib/news/engine.rb b/lib/news/engine.rb index b8c0cdc..6acb28f 100644 --- a/lib/news/engine.rb +++ b/lib/news/engine.rb @@ -30,11 +30,6 @@ module News :priority=>2, :active_for_action=>{'admin/news'=>'news'}, :available_for => 'sub_managers' - context_link 'news.admins', - :link_path=>"admin_news_admins_path" , - :priority=>4, - :active_for_action=>{'admin/news'=>'admins'}, - :available_for => 'managers' context_link 'categories', :link_path=>"admin_module_app_categories_path" , :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'news').id}", @@ -49,6 +44,11 @@ module News :active_for_action=>{'admin/news'=>'tags'}, :active_for_tag => 'News', :available_for => 'managers' + context_link 'news.admins', + :link_path=>"admin_news_admins_path" , + :priority=>6, + :active_for_action=>{'admin/news'=>'admins'}, + :available_for => 'managers' end end