bug修复
This commit is contained in:
parent
e86bd6728e
commit
e22e1caaed
|
@ -695,7 +695,7 @@ class AttachmentsController < ApplicationController
|
|||
@attachment.container.board.course)
|
||||
@course = @attachment.container.board.course
|
||||
else
|
||||
unless @attachment.container_type == 'Syllabus' || @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork'
|
||||
unless @attachment.container_type == 'Syllabus' || @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' || @attachment.container_type == 'Work'|| @attachment.container_type == 'ContestantWork'|| @attachment.container_type == 'Contest'
|
||||
@project = @attachment.project
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,8 @@ class ContestsController < ApplicationController
|
|||
|
||||
before_filter :find_contest, :only => [:show, :settings, :update, :contest_activities, :search_member, :private_or_public, :switch_role]
|
||||
before_filter :is_logged, :only => [:index, :new, :create]
|
||||
before_filter :is_admin?, :only => [:settings]
|
||||
before_filter :is_member?, :only => [:show, :contest_activities]
|
||||
layout "base_contests"
|
||||
|
||||
def show
|
||||
|
@ -240,4 +242,19 @@ class ContestsController < ApplicationController
|
|||
redirect_to signin_path unless User.current.logged?
|
||||
end
|
||||
|
||||
def is_admin?
|
||||
unless User.current.admin_of_contest?(@contest) || User.current.admin?
|
||||
render_403
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
def is_member?
|
||||
if User.current.member_of_contest?(@contest) || User.current.admin? || @contest.is_public
|
||||
|
||||
else
|
||||
render_403
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -243,6 +243,8 @@ class UsersController < ApplicationController
|
|||
if @type == 'JournalsForMessage'
|
||||
if reply.jour_type == "HomeworkCommon"
|
||||
@type = "HomeworkCommon"
|
||||
elsif reply.jour_type == "Work"
|
||||
@type = "Work"
|
||||
elsif reply.jour_type == "Syllabus"
|
||||
@type = "Syllabus"
|
||||
end
|
||||
|
@ -255,6 +257,12 @@ class UsersController < ApplicationController
|
|||
comment = HomeworkCommon.add_homework_jour(User.current, params[:reply_message], reply.jour_id, reply.root_id, options)
|
||||
@root.update_column('updated_at', Time.now)
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher, @root.course) || User.current.admin?
|
||||
when 'Work'
|
||||
@root = Work.find reply.jour_id
|
||||
options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => User.current.id,:m_parent_id => params[:reply_id].to_i,:m_reply_id => params[:reply_id].to_i, :root_id => reply.root_id}
|
||||
comment = Work.add_work_jour(User.current, params[:reply_message], reply.jour_id, reply.root_id, options)
|
||||
@root.update_column('updated_at', Time.now)
|
||||
@is_teacher = User.current.admin_of_contest?(@root.contest) || User.current.admin?
|
||||
when 'JournalsForMessage'
|
||||
options = {:user_id => User.current.id,
|
||||
:status => true,
|
||||
|
@ -4193,6 +4201,12 @@ class UsersController < ApplicationController
|
|||
@journals = obj.journals_for_messages.reorder("created_on desc")
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,obj.course)
|
||||
@user_activity_id = params[:user_activity_id].to_i if params[:user_activity_id]
|
||||
when 'Work'
|
||||
obj = Work.where('id = ?', params[:id].to_i).first
|
||||
@type = 'Work'
|
||||
@journals = obj.journals_for_messages.reorder("created_on desc")
|
||||
@is_teacher = User.current.admin_of_contest?(obj.contest)
|
||||
@user_activity_id = params[:user_activity_id].to_i if params[:user_activity_id]
|
||||
end
|
||||
end
|
||||
@journals = get_no_children_comments_all @journals
|
||||
|
|
|
@ -118,6 +118,15 @@ class WordsController < ApplicationController
|
|||
end
|
||||
@hw_status = params[:hw_status].to_i if
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher, @homework.course) || User.current.admin?
|
||||
elsif @journal_destroyed.jour_type == 'Work'
|
||||
@work = Work.find @journal_destroyed.jour_id
|
||||
if params[:user_activity_id]
|
||||
@user_activity_id = params[:user_activity_id].to_i
|
||||
else
|
||||
@user_activity_id = -1
|
||||
end
|
||||
@hw_status = params[:hw_status].to_i if
|
||||
@is_teacher = User.current.admin_of_contest?(@work.contest) || User.current.admin?
|
||||
elsif @journal_destroyed.jour_type == 'Syllabus'
|
||||
@syllabus = Syllabus.find @journal_destroyed.jour_id
|
||||
@count = @syllabus.journals_for_messages.count
|
||||
|
|
|
@ -3590,7 +3590,7 @@ end
|
|||
def get_reply_by_type type, reply_id
|
||||
reply = nil
|
||||
case type
|
||||
when 'HomeworkCommon'
|
||||
when 'HomeworkCommon', 'Work'
|
||||
reply = JournalsForMessage.find reply_id
|
||||
when 'JournalsForMessage'
|
||||
reply = JournalsForMessage.find reply_id
|
||||
|
|
|
@ -4,7 +4,7 @@ module ContestsHelper
|
|||
def get_acts_list_type type
|
||||
case type
|
||||
when "work"
|
||||
l(:label_homework_acts)
|
||||
l(:label_work_acts)
|
||||
when "news"
|
||||
l(:label_news_acts)
|
||||
when "attachment"
|
||||
|
@ -16,7 +16,7 @@ module ContestsHelper
|
|||
when "poll"
|
||||
l(:label_poll_acts)
|
||||
else
|
||||
l(:label_all_cats)
|
||||
l(:label_contest_cats)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
<%=get_cw_status(homework).html_safe %>
|
||||
<div class="cl"></div>
|
||||
<% if homework.work_type == 3 && homework.work_detail_group.base_on_project %>
|
||||
<span class="c_red">系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!</span>
|
||||
<span class="c_red">系统提示:该题目要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!</span>
|
||||
<% elsif homework.work_type == 3 && !homework.work_detail_group.base_on_project%>
|
||||
<span class="c_red">系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合!</span>
|
||||
<span class="c_red">系统提示:该题目要求各组长提交作品,提交作品时请添加组成员。谢谢配合!</span>
|
||||
<% end %>
|
||||
|
||||
<% is_base_group = homework.work_type == 3 && (homework.work_detail_group.base_on_project || !(cur_user_works_for_work(homework).nil?)) && !is_teacher %>
|
||||
|
|
|
@ -98,14 +98,14 @@
|
|||
<% end %>
|
||||
<% hcommons.each_with_index do |homework_common,index |%>
|
||||
<% if homework_common.id == @contestwork.id %>
|
||||
<%="作业 #{hcommons.count - index}" %>
|
||||
<%="题目 #{hcommons.count - index}" %>
|
||||
<% end %>
|
||||
<% end%>
|
||||
</a>
|
||||
<ul>
|
||||
<% hcommons.each_with_index do |homework_common,index |%>
|
||||
<li class="pr10">
|
||||
<%= link_to "作业#{hcommons.count - index}:#{homework_common.name}",student_work_index_path(:homework => homework_common.id)%>
|
||||
<%= link_to "题目#{hcommons.count - index}:#{homework_common.name}",student_work_index_path(:homework => homework_common.id)%>
|
||||
<%#= link_to "第#{@homework_commons.count - index}次作业",student_work_index_path(:homework => homework_common.id)%>
|
||||
</li>
|
||||
<% end%>
|
||||
|
|
|
@ -12,9 +12,7 @@
|
|||
<div class="sy_class_info fl">
|
||||
<div class="sy_class_titbox">
|
||||
<h3 class="fl sy_class_title"><%= @contest.name %></h3>
|
||||
<% if @contest.is_public %>
|
||||
<span class="hw_icon_open fl ml5 mt3"></span>
|
||||
<% end %>
|
||||
<span class="<%= @contest.is_public ? 'hw_icon_open' : 'hw_icon_private' %> fl ml5 mt3"></span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<p class="sy_cgrey ">
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
</li>
|
||||
<li class="clear">
|
||||
<label class="fl ">公开 :</label>
|
||||
<input class="fl ml5" id="contest_is_public" name="contest[is_public]" type="checkbox" <%= @contest.is_public ? "checked" : ""%>>
|
||||
<input class="fl ml5 h28" id="contest_is_public" name="contest[is_public]" type="checkbox" <%= @contest.is_public ? "checked" : ""%>>
|
||||
<span class="fl c_grey ">(选中后对所有用户可见,否则仅对成员可见。)</span>
|
||||
</li>
|
||||
<li class="clear">
|
||||
|
|
|
@ -10,15 +10,15 @@
|
|||
<div class="cl"></div>
|
||||
|
||||
<div>
|
||||
<% if @contest.description.nil? && User.current.admin_of_contest?(@contest) %>
|
||||
<% if (@contest.description.nil? || @contest.description == "") && User.current.admin_of_contest?(@contest) %>
|
||||
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
|
||||
<p class="sy_tab_con_p">请尽快补充竞赛说明,赢得更多参赛</p>
|
||||
<% elsif @contest.description.nil? %>
|
||||
<% elsif (@contest.description.nil? || @contest.description == "") %>
|
||||
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
|
||||
<p class="sy_tab_con_p">尚未发布竞赛说明,敬请期待~</p>
|
||||
<% else %>
|
||||
<div class="description_div">
|
||||
<div class="syllabuscon upload_img ke-block" id="syllabus_description_<%= @contest.id %>">
|
||||
<div class="syllabuscon upload_img ke-block break_word" id="syllabus_description_<%= @contest.id %>">
|
||||
<%= @contest.description.html_safe %>
|
||||
</div>
|
||||
<div class="mt10" style="font-weight:normal; font-size: 12px;">
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
</li>
|
||||
<% else %>
|
||||
<li>
|
||||
<%= link_to "作业",works_path(:contest => contest.id), :class => 'user_navmore_li', :target => '_blank' %>
|
||||
<%= link_to "作品",works_path(:contest => contest.id), :class => 'user_navmore_li', :target => '_blank' %>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -31,10 +31,10 @@
|
|||
<div class="cl"></div>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="clear">
|
||||
<%= link_to "论坛",contest_boards_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>
|
||||
<%= link_to "+",contest_boards_path(contest, :flag => true, :is_new => 1), :class => 'user_navmore_add fl', :title => '发布帖子',:target => '_blank' %>
|
||||
</li>
|
||||
<!--<li class="clear">-->
|
||||
<!--<%#= link_to "论坛",contest_boards_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>-->
|
||||
<!--<%#= link_to "+",contest_boards_path(contest, :flag => true, :is_new => 1), :class => 'user_navmore_add fl', :title => '发布帖子',:target => '_blank' %>-->
|
||||
<!--</li>-->
|
||||
<% if User.current == user %>
|
||||
<li>
|
||||
<%= link_to "取消收藏", cancel_or_collect_user_path(user, :contest => contest.id), :class => 'user_navmore_li',:target => '_blank', :remote => true %>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
竞赛通知
|
||||
</div>
|
||||
</div>
|
||||
<% if contest && User.current.allowed_to?(:manage_news, @contest) %>
|
||||
<% if contest && User.current.admin_of_contest?(@contest) %>
|
||||
<%= labelled_form_for @news, :url => new_contest_news_path(:contest_id => @contest),
|
||||
:html => {:id => 'news-form', :nhname => 'form', :multipart => true, :method => "get"} do |f| %>
|
||||
<%= render :partial => 'contest_news_new', :locals => {:f => f, :news => @news, :edit_mode => false, :contest => @contest} %>
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
<div class="homepagePostReplyBannerTime"><%#= format_date(activity.updated_on) %></div>
|
||||
<%if expand_more %>
|
||||
<div class="homepagePostReplyBannerMore">
|
||||
<% if activity.class.to_s == 'HomeworkCommon' %>
|
||||
<a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply_homework('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>',<%= activity.id %>,'HomeworkCommon',<%=activity.id %>,<%=user_activity_id %>)" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
|
||||
<% if activity.class.to_s == 'HomeworkCommon' || activity.class.to_s == 'Work' %>
|
||||
<a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply_homework('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>',<%= activity.id %>,'<%=activity.class %>',<%=activity.id %>,<%=user_activity_id %>)" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
|
||||
展开更多
|
||||
</a>
|
||||
<% elsif activity.class.to_s == 'Message' %>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% if params[:type] == 'HomeworkCommon' %>
|
||||
<% if params[:type] == 'HomeworkCommon' || params[:type] == 'Work' %>
|
||||
$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/news_replies', :locals => {:comments => @journals, :type => @type, :is_teacher => @is_teacher, :user_activity_id => @user_activity_id, :activity_id => params[:id].to_i}) %>');
|
||||
<% elsif params[:type] == 'JournalsForMessage' %>
|
||||
$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id =>params[:id].to_i}) %>');
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
window.location.href = "<%=board_message_path(@root.board_id, @root) %>";
|
||||
<% end %>
|
||||
<% elsif @type == 'HomeworkCommon' %>
|
||||
$("#homework_post_reply_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/homework_post_reply', :locals => {:activity => @root, :user_activity_id => @user_activity_id, :is_teacher => @is_teacher}) %>");
|
||||
$("#homework_post_reply_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/homework_post_reply', :locals => {:activity => @root, :user_activity_id => @user_activity_id, :is_teacher => @is_teacher}) %>");
|
||||
<% elsif @type == 'Work' %>
|
||||
$("#homework_post_reply_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/contest_work_post_reply', :locals => {:activity => @root, :user_activity_id => @user_activity_id, :is_teacher => @is_teacher}) %>");
|
||||
<% elsif @type == 'BlogComment' %>
|
||||
<% if @user_activity_id.to_i != @root.id %>
|
||||
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/user_blog_post_reply', :locals => {:activity => @root,:user_activity_id =>@user_activity_id}) %>");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% if @journal_destroyed.nil? %>
|
||||
alert('<%=l(:notice_failed_delete)%>');
|
||||
<% elsif (['Principal','Project','Course', 'Bid', 'Contest', 'Softapplication','HomeworkCommon','Syllabus'].include? @journal_destroyed.jour_type)%>
|
||||
<% elsif (['Principal','Project','Course', 'Bid', 'Contest', 'Softapplication','HomeworkCommon','Syllabus', 'Work'].include? @journal_destroyed.jour_type)%>
|
||||
<% if @is_user%>
|
||||
<% if @activity %>
|
||||
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/user_journal_post_reply', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>");
|
||||
|
@ -37,7 +37,14 @@
|
|||
<% else %>
|
||||
sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>");
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% elsif @work%>
|
||||
$("#homework_post_reply_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/contest_work_post_reply', :locals => {:activity => @work, :user_activity_id => @user_activity_id, :is_teacher => @is_teacher}) %>");
|
||||
<% if @user_activity_id != @work.id %>
|
||||
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
|
||||
<% else %>
|
||||
sd_create_editor_from_data(<%= @work.id%>,"","100%", "<%=@work.class.to_s%>");
|
||||
<% end %>
|
||||
<% end %>
|
||||
var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>')
|
||||
destroyedItem.fadeOut(600,function(){
|
||||
destroyedItem.remove();
|
||||
|
|
|
@ -39,6 +39,8 @@ zh:
|
|||
label_poll_acts: 问卷动态
|
||||
label_all_cats: 班级动态
|
||||
|
||||
label_work_acts: 作品动态
|
||||
label_contest_cats: 竞赛动态
|
||||
#
|
||||
# 课程托管平台主页
|
||||
#
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
#coding=utf-8
|
||||
|
||||
namespace :contest_work_publishtime do
|
||||
desc "start publish contest_work and end contest_work"
|
||||
task :publish => :environment do
|
||||
puts "--------------------------------contest_work_publish start"
|
||||
Rails.logger.info("log--------------------------------contest_work_publish start")
|
||||
homework_commons = Work.where("publish_time = '#{Date.today}'")
|
||||
homework_commons.each do |homework|
|
||||
if homework.work_status == 0
|
||||
homework.update_column('work_status', 1)
|
||||
|
||||
contest = homework.contest
|
||||
contest.contest_members.each do |m|
|
||||
homework.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => contest.id, :viewed => false, :status => nil)
|
||||
end
|
||||
if homework.contest_acts.size == 0
|
||||
homework.contest_acts << ContestActivity.new(:user_id => homework.user_id,:contest_id => homework.contest_id)
|
||||
end
|
||||
# 邮件通知
|
||||
# Mailer.run.homework_added(homework)
|
||||
end
|
||||
end
|
||||
Rails.logger.info("log--------------------------------contest_work_publish end")
|
||||
puts "--------------------------------contest_work_publish end"
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue