From f6d09e055495bd08854d627840ded36356fd6f7d Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Sun, 24 Apr 2016 14:23:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AA=20=E9=9A=90=E8=97=8F=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E4=BF=A1=E6=81=AF=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/settings_controller.rb | 22 ++++++ app/views/layouts/new_base_user.html.erb | 81 ++++++++++++----------- app/views/settings/edit.html.erb | 1 + app/views/settings/hidden_courses.js.erb | 5 ++ app/views/users/_user_activities.html.erb | 6 +- app/views/users/show.html.erb | 32 +++++---- config/locales/zh.yml | 6 +- config/routes.rb | 1 + config/settings.yml | 2 + 9 files changed, 100 insertions(+), 56 deletions(-) create mode 100644 app/views/settings/hidden_courses.js.erb diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 93e0e9c4b..c22f9e4ab 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -32,6 +32,10 @@ class SettingsController < ApplicationController hidden_non_project = Setting.find_by_name("hidden_non_project") @text = (hidden_non_project && hidden_non_project.value == "0") ? l(:label_show_non_project) : l(:label_hidden_non_project) + #1隐藏了课程信息 0显示了课程信息 + hidden_courses = Setting.find_by_name("hidden_courses") + @text_1 = (hidden_courses && hidden_courses.value == "1") ? l(:label_show_courses) : l(:label_hidden_courses) + @notifiables = Redmine::Notifiable.all if request.post? && params[:settings] && params[:settings].is_a?(Hash) settings = (params[:settings] || {}).dup.symbolize_keys @@ -89,4 +93,22 @@ class SettingsController < ApplicationController redirect_to settings_url end + + #隐藏/显示课程信息 + def hidden_courses + @notifiable = Setting.find_by_name("hidden_courses") + if @notifiable + @notifiable.value == "1" ? @notifiable.value = 0 : @notifiable.value = 1 + @notifiable.save + else + @notifiable = Setting.new() + @notifiable.name = "hidden_courses" + @notifiable.value = 1 + @notifiable.save + end + + redirect_to settings_url + end end + + diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 4e1064b7f..0d40bb946 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -185,48 +185,53 @@