Merge branch 'szzh' into guange_dev

This commit is contained in:
sw 2015-04-09 16:05:49 +08:00
commit 5ad1028c49
28 changed files with 150 additions and 55 deletions

View File

@ -80,6 +80,10 @@ module Mobile
class_period: params[:class_period]
}
course = ::Course.find(params[:course_id])
# 如果没有传密码过来,那就把原来的密码给上,不然会不更新
if params[:password].nil? || params[:password].blank?
cs_params[:course][:password] = course[:password]
end
cs.edit_course_authorize(current_user,course)
course = cs.edit_course(cs_params, course,current_user)
present :data, course, with: Mobile::Entities::Course

View File

@ -681,9 +681,10 @@ class CoursesController < ApplicationController
"show_course_files" => true,
"show_course_news" => true,
"show_course_messages" => true,
"show_course_journals_for_messages" => true,
#"show_course_journals_for_messages" => true,
"show_bids" => true,
"show_homeworks" => true
"show_homeworks" => true,
#"show_polls" => true
}
@date_to ||= Date.today + 1
@date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date

View File

@ -29,6 +29,9 @@ class SettingsController < ApplicationController
end
def edit
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)
@notifiables = Redmine::Notifiable.all
if request.post? && params[:settings] && params[:settings].is_a?(Hash)
settings = (params[:settings] || {}).dup.symbolize_keys
@ -70,4 +73,20 @@ class SettingsController < ApplicationController
rescue Redmine::PluginNotFound
render_404
end
#隐藏/显示非项目信息
def hidden_non_project
@notifiable = Setting.find_by_name("hidden_non_project")
if @notifiable
@notifiable.value == "1" ? @notifiable.value = 0 : @notifiable.value = 1
@notifiable.save
else
@notifiable = Setting.new()
@notifiable.name = "hidden_non_project"
@notifiable.value = 0
@notifiable.save
end
redirect_to settings_url
end
end

View File

@ -132,9 +132,10 @@ module ApplicationHelper
def link_to_user_header user,canShowRealName=false,options={}
if user.is_a?(User)
if canShowRealName
name = h(user.realname(options[:format]))
name = user.show_name
name = user.login if name == ""
else
name = h(user.name(options[:format]))
name = user.login
end
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => options[:class]
else
@ -1947,6 +1948,8 @@ module ApplicationHelper
end
def bootstrap_render_dynamic_nav
hidden_non_project = Setting.find_by_name("hidden_non_project")
visiable = !(hidden_non_project && hidden_non_project.value == "0")
main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.course_domain}
main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain}
@ -1964,21 +1967,21 @@ module ApplicationHelper
#@nav_dispaly_project_label
nav_list = Array.new
nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label && @show_course == 1
nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label && @show_course == 1 && visiable
# nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label && @show_course == 1
nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label && @show_course == 1
nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label && @show_course == 1 && visiable
nav_list.push(main_project_link) if @nav_dispaly_main_project_label
nav_list.push(main_course_link) if @nav_dispaly_main_course_label && @show_course == 1
nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label && @show_contest == 1
nav_list.push(main_course_link) if @nav_dispaly_main_course_label && @show_course == 1 && visiable
nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label && @show_contest == 1 && visiable
nav_list.push(courses_link) if @nav_dispaly_course_label && @show_course == 1
nav_list.push(courses_link) if @nav_dispaly_course_label && @show_course == 1 && visiable
# nav_list.push(projects_link) if @nav_dispaly_project_label
#nav_list.push(users_link) if @nav_dispaly_user_label
# nav_list.push(contest_link) if @nav_dispaly_contest_label && @show_contest == 1
nav_list.push(bids_link) if @nav_dispaly_bid_label
nav_list.push(forum_link) if @nav_dispaly_forum_label
nav_list.push(stores_link) if @nav_dispaly_store_all_label
nav_list.push(bids_link) if @nav_dispaly_bid_label && visiable
nav_list.push(forum_link) if @nav_dispaly_forum_label && visiable
nav_list.push(stores_link) if @nav_dispaly_store_all_label && visiable
content_li = ''
nav_list.collect do |nav_item|

View File

@ -52,7 +52,7 @@ module CoursesHelper
end
def course_poll_count
Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}").count
Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status in (2,3)").count
end
def course_feedback_count
@ -632,48 +632,73 @@ module CoursesHelper
#获取课程动态
def get_course_activity courses, activities
@course_ids=activities.keys()
@bid_ids = []
days = Setting.activity_days_default.to_i
date_to ||= Date.today + 1
date_from = date_to - days-1.years
#原来课程动态计算当期时间前(一年+一月)的动态
# date_to ||= Date.today + 1
# #date_from = date_to - days-1.years
date_from = @course.created_at.to_date-days
#file_count
Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment|
if attachment.is_public? || User.current.member_of_course?(@course) || User.current.admin?
activities[attachment.container_id]+=1
else
activities[attachment.container_id]
end
end
#message_count
#Board.where(course_id: @course_ids).each do |board|
# activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count
#end
#message_count
Board.where(course_id: @course_ids).each do |board|
# activities[board.course_id]+=1
activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count
countmessage = 0
# 课程人员退出课程后,之前在讨论区回帖不计入课程动态统计
board.messages.where("updated_on>?", date_from).each do |message|
if message.author.member_of_course?(@course)
countmessage+=1
end
end
activities[board.course_id]+=countmessage
end
#news
News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news|
if news.author.member_of_course?(@course)
activities[news.course_id]+=1
end
end
#feedbackc_count
JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess|
activities[jourformess.jour_id]+=1
end
#feedback_count 留言目前有问题留待下一步处理
#JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess|
# activities[jourformess.jour_id]+=1
#end
#homework_count
#HomeworkForCourse.where(course_id: @course_ids).each do |homework|
# @bid_ids<<homework.bid_id
# activities[homework.bid_id]+=Bid.where(id: @bid_ids).where("created_on>?",date_from).count
#end
HomeworkForCourse.where(course_id: @course_ids).each do |homework|
countbid=0
# @bid_ids<<homework.bid_id
Bid.where(id: homework.bid_id).where("created_on>?",date_from).each do |bid|
countbid+=1
end
activities[homework.course_id]+=countbid
end
#@bid_ids.each do |bid_id|
# activities[] +=Bid.where(id: bid_id ).where("created_on>?",date_from).count
#end
#poll_count
#Poll.where(polls_group_id: @course_ids, polls_type: Course, polls_status: 2||3).where("published_at>?",date_from).each do |poll|
# activities[poll.polls_group_id]+=1
#end
#end
# 动态数 + 1 ( 某某创建了该课程 )
# activities.each_pair { |key, value| activities[key] = value + 1 }
activities.each_pair { |key, value| activities[key] = value + 1 }
return activities
end
@ -759,7 +784,7 @@ module CoursesHelper
def visable_attachemnts_incourse course
result = []
course.attachments.each do |attachment|
if attachment.is_public? || User.current.member_of_course?(course)
if attachment.is_public? || User.current.member_of_course?(course) || User.current.admin?
result << attachment
end
end

View File

@ -44,7 +44,11 @@ module MembersHelper
# add by nwb
# 课程可添加的成员列表
def render_principals_for_new_course_members(course)
scope = Principal.active.sorted.not_member_of_course(course).like(params[:q])
if params[:q] && params[:q] != ""
scope = Principal.active.sorted.not_member_of_course(course).like(params[:q])
else
scope = []
end
principals = paginateHelper scope,10
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals')

View File

@ -49,6 +49,7 @@ class JournalsForMessage < ActiveRecord::Base
acts_as_activity_provider :type => 'course_journals_for_messages',
:author_key => :user_id,
:permission => :view_course_journals_for_messages,
:timestamp => "#{self.table_name}.updated_on",
:find_options => {:include => :course }

View File

@ -6,4 +6,23 @@ class Poll < ActiveRecord::Base
has_many :poll_questions, :dependent => :destroy,:order => "#{PollQuestion.table_name}.question_number"
has_many :poll_users, :dependent => :destroy
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
# 添加课程的poll动态
# has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# after_create :act_as_activity
# acts_as_event :title => Proc.new {|o| "#{l(:label_my_message)} ##{o.id}: #{o.name}" },
# :description => :description,
# :author => :author,
# :url => Proc.new {|o| {:controller => 'poll', :action => 'show', :id => o.id}}
# acts_as_activity_provider :type => 'polls',
# :permission => :view_course_polls,
#:find_options => {:include => [:course, :author]},
#:timestamp => "#{self.table_name}.published_at",
# :author_key => :author_id
# def act_as_activity
# self.acts << Activity.new(:user_id => self.user_id)
# end
end

View File

@ -1,9 +1,8 @@
<% if @statue == 1%>
alert('启动成功');
$("#<%= @bid.id %>_start_anonymous_comment").remove();
$("#<%= @bid.id %>_anonymous_comment").append('<%= link_to "关闭匿评", alert_anonymous_comment_bid_path(@bid), remote: true, id:"#{@bid.id}_stop_anonymous_comment" %>');
$("#<%= @bid.id %>_start_anonymous_comment").replaceWith('<%= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_bid_path(@bid), remote: true, id:"#{@bid.id}_stop_anonymous_comment",:class => "fr mr10 work_edit")%>');
<% elsif @statue == 2 %>
alert('启动失败\n作业总数大于等于2份时才能启动匿评');
<% elsif @statue == 3%>
alert("已开启匿评,请务重复开启");
<% end %>
<% end %>

View File

@ -1,2 +1,2 @@
alert('关闭成功');
$("#<%= @bid.id %>_anonymous_comment").html('<a href="javascript:" style="background:#8e8e8e;">匿评结束</a>');
$("#<%= @bid.id %>_stop_anonymous_comment").replaceWith('<a class="fr pr_join_span mr10 span_wping_background" title="匿评结束">匿评结束</a>');

View File

@ -1,6 +1,6 @@
<% @members.each do |member| %>
<li >
<%= link_to_user_header member.principal,false,:class => "w150 c_orange fl" %>
<%= link_to_user_header member.principal,true,:class => "w150 c_orange fl" %>
<span class="w150 fl">
<%= h member.roles.sort.collect(&:to_s).join(', ') %>
<%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),

View File

@ -15,7 +15,7 @@
</div>
<div class="cl"></div>
<div class="for_img_thumbnails">
<% curse_attachments.sort.reverse.each do |file| %>
<% curse_attachments.each do |file| %>
<% if file.is_public? || User.current.member_of_course?(course) %>
<div class="re_con_box">
<div class="">

View File

@ -26,7 +26,10 @@
<tr>
<td align="left" colspan="2" ><span class="font_lighter"><%= authoring topic.created_at, topic.author %>
<span class="font_description2">
最后回复:<%=link_to_user topic.last_reply.try(:author) %>
<% author = topic.last_reply.try(:author)%>
<% if author%>
最后回复:<%=link_to_user author %>
<% end%>
</span>
<br />
</span></td>

View File

@ -11,8 +11,10 @@
<ul style="padding:0 0; margin:0 0;display:inline;">
<li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;" class="loggedas_li">
<%=link_to_user(User.current)%>
<% hidden_non_project = Setting.find_by_name("hidden_non_project")
visiable = hidden_non_project && hidden_non_project.value == "0"%>
<ul class="sub_menu">
<% if @show_course == 1 %>
<% if @show_course == 1 && !visiable %>
<% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
<% hasCourse=false %>
<% User.current.courses.each do |course| %>

View File

@ -53,7 +53,7 @@
<div class="sidebar-forums">
<div class="forums-line">
<div class="forums-title"><%= @forum.name %></div>
<div class="forums-description"><%= @forum.description %></div>
<div class="forums-description"><%= @forum.description.html_safe %></div>
</div>
<!--informations-->
<div class="formus-first-title" >创建人信息</div>

View File

@ -32,8 +32,10 @@
padding-left: 5px !important;
padding-right: 5px !important;
line-height: 1.9;
float: left;
}
.span_wping a:hover{ background-color:#03a1b3;}
.span_wping_background{background: #CCC !important;}
</style>
</head>
<body class="<%= h body_css_classes %>">

View File

@ -84,7 +84,7 @@
<div class="sidebar-forums">
<div class="forums-line">
<div class="forums-title"><%= @forum.name %></div>
<div class="forums-description"><%= @forum.description %></div>
<div class="forums-description"><%= @forum.description.html_safe %></div>
</div>
<!--informations-->
<div class="formus-first-title" >创建人信息</div>

View File

@ -145,6 +145,7 @@
<%= f.text_area 'user_introduction', :rows => 3,
:cols => 65,
:placeholder => "#{l(:label_my_brief_introduction)}",
:maxlength => 200,
:style => "resize: none;",
:class => 'noline'%>
</td>

View File

@ -64,7 +64,7 @@
<%=h @memo.subject %>
</div>
<div class="memo-content" id="memo-content_div">
<%= textAreailizable(@memo,:content) %>
<%= @memo.content.html_safe %>
<p>
<% if @memo.attachments.any?%>
<% options = {:author => true, :deletable => @memo.deleted_attach_able_by?(User.current) } %>

View File

@ -1,4 +1,6 @@
<h3><%= l(:label_settings) %></h3>
<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;"%>
<div class="clear"></div>
<%= render_tabs administration_settings_tabs %>

View File

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

View File

@ -1,6 +1,9 @@
<%hidden_non_project = Setting.find_by_name("hidden_non_project")
visiable = hidden_non_project && hidden_non_project.value == "0"%>
<% unless visiable%>
<div class="linkother" style="margin-left: 30%; float: left">
<a href="http://<%= Setting.host_name%>" class="link_other_item"><%=l(:label_projects_management_platform)%></a>
<a href="http://<%= Setting.host_course%>" class="link_other_item"><%=l(:label_courses_management_platform)%></a>
<a href="http://<%= Setting.host_contest%>" class="link_other_item"><%=l(:label_contests_management_platform)%></a>
</div>
</div>
<% end%>

View File

@ -2014,6 +2014,8 @@ zh:
label_recently_updated_courseware: 最近更新了课件
label_no_courses: 您没有参与任何课程,请搜索课程、加入课程,或者创建课程吧!
label_commit_failed: 提交失败
label_recently: 最近被
label_creat: 创建
#api end
label_end_time: 截止时间
@ -2031,4 +2033,6 @@ zh:
modal_valid_unpassing: 该分班已经存在
mail_footer: 点击修改邮件发送设置
label_show_non_project: 显示非项目信息
label_hidden_non_project: 隐藏非项目信息

View File

@ -736,6 +736,7 @@ RedmineApp::Application.routes.draw do
match 'settings', :controller => 'settings', :action => 'index', :via => :get
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 'sys/projects', :via => :get
match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post

View File

@ -266,6 +266,8 @@ repository_domain:
default: repository.trustie.net
please_chose:
default: 请选择
hidden_non_project:
default: 1
plugin_redmine_ckeditor:
serialized: true
default: --- !ruby/hash:ActiveSupport::HashWithIndifferentAccess

View File

@ -1,9 +0,0 @@
class CreateDiscussDemos < ActiveRecord::Migration
def change
create_table :discuss_demos do |t|
t.string :title
t.text :body
t.timestamps
end
end
end

View File

@ -137,6 +137,9 @@ Redmine::AccessControl.map do |map|
map.permission :paret_in_homework,{},:require => :member ,:belong_to_course => true
end
# map.course_module :polls do |map|
# map.permission :view_course_polls, {:polls => [:index,:show]},:require => :member, :belong_to_course => true
# end
map.course_module :boards do |map|
# map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member
@ -484,6 +487,7 @@ Redmine::Activity.map do |activity|
activity.register :course_messages, :default => false, :class_name => 'Message'
activity.register :homeworks, :class_name => 'Bid'
# activity.register :polls, :class_name => 'Poll'
end
Redmine::Search.map do |search|

View File

@ -243,7 +243,7 @@ a:hover.tijiao{ background:#0f99a9;}
.members_left ul li a{ float:left; text-align:center;}
.members_left ul li span{ float:left; text-align:center; color:#484747;}
.w150{ text-align:center; width:150px;}
.w150{ text-align:center; width:150px;min-height: 10px;}
.f_b{ font-weight: bold;}
.members_right label{ margin-left:15px;}
.N_search{ height:20px; border:1px solid #999;}