配置中增加一个 隐藏课程信息的功能

This commit is contained in:
yuanke 2016-04-24 14:23:08 +08:00
parent f6a5ffc6a5
commit f6d09e0554
9 changed files with 100 additions and 56 deletions

View File

@ -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

View File

@ -185,6 +185,9 @@
<div class="homepageLeftMenuBlock">
<%= link_to "动态",user_activities_path(@user.id),:class => "homepageMenuText"%>
</div>
<% hidden_courses = Setting.find_by_name("hidden_courses") %>
<% unvisiable = hidden_courses && hidden_courses.value == "1"%>
<% if !unvisiable %>
<div class="homepageLeftMenuBlock">
<a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuCourses').slideToggle();">课程</a>
<% if is_current_user%>
@ -227,6 +230,8 @@
<%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => @user, :page => 0} %>
</ul>
</div>
<% end %>
<div class="homepageLeftMenuBlock">
<a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuForge').slideToggle();">项目</a>

View File

@ -1,5 +1,6 @@
<h3 style="float: left;"><%=l(:label_settings)%></h3>
<%= link_to @text,settings_hidden_non_project_path,:id => "hidden_non_project",:style => "float: right;margin-right: 60px;margin-top: 9px;"%>
<%= link_to @text_1,settings_hidden_courses_path,:id => "hidden_courses",:style => "float: right;margin-right: 60px;margin-top: 9px;"%>
<div class="clear"></div>
<%= render_tabs administration_settings_tabs %>

View File

@ -0,0 +1,5 @@
<% if @notifiable.value == "0"%>
$("#hidden_courses").replaceWith("<%= escape_javascript(link_to '隐藏课程信息',settings_hidden_courses_path,:id => 'hidden_courses',:style => 'float: right;margin-right: 60px;margin-top: 9px;', :remote => true)%>");
<% else%>
$("#hidden_courses").replaceWith("<%= escape_javascript(link_to '显示课程信息',settings_hidden_courses_path,:id => 'hidden_courses',:style => 'float: right;margin-right: 60px;margin-top: 9px;', :remote => true)%>");
<% end%>

View File

@ -65,7 +65,11 @@
<% case user_activity.act_type.to_s %>
<% when 'HomeworkCommon' %>
<%# cache (act) do %>
<% hidden_courses = Setting.find_by_name("hidden_courses") %>
<% unvisiable = hidden_courses && hidden_courses.value == "1"%>
<% if !unvisiable %>
<%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity_id =>user_activity.id,:course_activity => 0} %>
<% end %>
<%# end %>
<% when 'News' %>
<%# cache [act, act.comments.count] do %>

View File

@ -7,6 +7,9 @@
<ul class="homepagePostType">
<li>
<ul class="homepagePostTypeHomework fl">
<% hidden_courses = Setting.find_by_name("hidden_courses") %>
<% unvisiable = hidden_courses && hidden_courses.value == "1"%>
<% if !unvisiable %>
<li class="f14">课程动态</li>
<li><%= link_to "作业动态", {:controller => "users", :action => "show", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%>
<!--<a href="javascript:void(0);" class="homepagePostTypeAssignment postTypeGrey">作业动态</a>--></li>
@ -17,6 +20,7 @@
<li><%= link_to "课程留言", {:controller => "users", :action => "show", :type => "course_journals"}, :class =>"homepagePostTypeMessage postTypeGrey"%>
<!--<li><a href="javascript:void(0);" class="homepagePostTypeForum postTypeGrey">论坛动态</a></li>-->
<!--<li><a href="javascript:void(0);" class="homepagePostTypeQuiz postTypeGrey">问卷动态</a></li>-->
<% end %>
</ul>
</li>
<li>

View File

@ -371,8 +371,8 @@ zh:
permission_contest_attachments_download: 竞赛附件下载
permission_upload_attachments: 资源上传
label_show_courses: 显示课程信息
label_hidden_courses: 隐藏课程信息
label_user: 用户
label_user_plural: 用户列表

View File

@ -1085,6 +1085,7 @@ RedmineApp::Application.routes.draw do
match 'settings/edit', :via => [:get, :post]
match 'settings/plugin/:id', :to => 'settings#plugin', :via => [:get, :post], :as => 'plugin_settings'
match 'settings/hidden_non_project', :via => [:get, :post]
match 'settings/hidden_courses', :via => [:get, :post]
match 'sys/projects', :via => :get
match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post

View File

@ -267,6 +267,8 @@ please_chose:
default: 请选择
hidden_non_project:
default: 1
hidden_courses:
default: 0
plugin_redmine_ckeditor:
serialized: true
default: --- !ruby/hash:ActiveSupport::HashWithIndifferentAccess