Merge remote-tracking branch 'remotes/origin/szzh' into develop

Conflicts:
	app/views/welcome/contest.html.erb
This commit is contained in:
nwb 2014-07-22 09:52:16 +08:00
commit 68be9c25b8
20 changed files with 192 additions and 105 deletions

View File

@ -1,4 +1,4 @@
source 'https://ruby.taobao.org'
source 'http://ruby.taobao.org'
unless RUBY_PLATFORM =~ /w32/
# unix-like only

View File

@ -19,7 +19,7 @@ PATH
rails
GEM
remote: https://ruby.taobao.org/
remote: http://ruby.taobao.org/
remote: https://rubygems.org/
specs:
actionmailer (3.2.13)
@ -53,13 +53,12 @@ GEM
rails (>= 3, < 5)
arel (3.0.3)
builder (3.0.0)
capybara (2.0.3)
capybara (2.4.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 1.0.0)
xpath (~> 2.0)
celluloid (0.15.2)
timers (~> 1.1.0)
childprocess (0.5.3)
@ -90,7 +89,7 @@ GEM
lumberjack (~> 1.0)
pry (>= 0.9.12)
thor (>= 0.18.1)
guard-rails (0.5.2)
guard-rails (0.5.3)
guard (~> 2.0)
guard-spork (1.5.1)
childprocess (>= 0.2.3)
@ -122,14 +121,17 @@ GEM
metaclass (0.0.4)
method_source (0.8.2)
mime-types (1.25.1)
mocha (0.13.3)
mini_portile (0.6.0)
mocha (1.1.0)
metaclass (~> 0.0.1)
multi_json (1.10.1)
mysql2 (0.3.11)
mysql2 (0.3.11-x86-mingw32)
net-ldap (0.3.1)
nokogiri (1.5.11)
nokogiri (1.5.11-x86-mingw32)
nokogiri (1.6.3)
mini_portile (= 0.6.0)
nokogiri (1.6.3-x86-mingw32)
mini_portile (= 0.6.0)
paperclip (3.5.4)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
@ -233,7 +235,7 @@ GEM
json (>= 1.8.0)
websocket (1.0.7)
win32console (1.3.2-x86-mingw32)
xpath (1.0.0)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS
@ -246,22 +248,22 @@ DEPENDENCIES
acts-as-taggable-on (= 2.4.1)
better_errors!
builder (= 3.0.0)
capybara (~> 2.0.0)
capybara (~> 2.4.1)
coderay (~> 1.0.6)
coffee-rails (~> 3.2.1)
factory_girl
factory_girl (~> 4.4.0)
fastercsv (~> 1.5.0)
guard-rails
guard-spork
guard-rails (~> 0.5.3)
guard-spork (~> 1.5.1)
guard-test (~> 1.0.0)
htmlentities
i18n (~> 0.6.0)
jquery-rails (~> 2.0.2)
kaminari
mocha (~> 0.13.3)
mocha (~> 1.1.0)
mysql2 (= 0.3.11)
net-ldap (~> 0.3.1)
nokogiri (< 1.6.0)
nokogiri (~> 1.6.3)
paperclip (~> 3.5.4)
pry
pry-nav
@ -273,7 +275,8 @@ DEPENDENCIES
ruby-openid (~> 2.1.4)
sass-rails (~> 3.2.3)
seems_rateable!
shoulda (> 3.3.2)
spork-testunit
selenium-webdriver (~> 2.42.0)
shoulda (~> 3.5.0)
spork-testunit (~> 0.0.8)
therubyracer
uglifier (>= 1.0.3)

View File

@ -68,5 +68,7 @@ bundle exec rake db:migrate:up VERSION=20140410021724
4 点击“查询”(就是确定的功能)
===============================================================================
0719若遇到首页定制报错问题请尝试如下操作
如果运行迁移文件有报错与sort_type相关 先运行 bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202
在按如下步骤执行,未报与之相关的则直接按如下步骤执行
1.运行 bundle exec rake db:migrate:down version=20140719080032
2.运行 bundle exec rake db:migrate:up version=20140719080032

View File

@ -70,7 +70,7 @@ class BoardsController < ApplicationController
@message = Message.new(:board => @board)
#modify by nwb
if @project
render :action => 'show', :layout => !request.xhr?
render :action => 'show', :layout => 'base_projects'
elsif @course
render :action => 'show', :layout => 'base_courses'
end

View File

@ -1,6 +1,7 @@
# fq
# class BidsController < ApplicationController
class ContestsController < ApplicationController
layout "contest_base"
menu_item :respond
menu_item :project, :only => :show_project
menu_item :application, :only => :show_softapplication

View File

@ -29,7 +29,13 @@ class DocumentsController < ApplicationController
def index
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
documents = @project.documents.includes(:attachments, :category).all
temp = @project.documents.includes(:attachments, :category).all
documents = []
temp.each do |doc|
if doc.has_right?(@project)
documents << doc
end
end
case @sort_by
when 'date'
@grouped = documents.group_by {|d| d.updated_on.to_date }
@ -105,7 +111,7 @@ class DocumentsController < ApplicationController
# 权限判断
# add by nwb
def authorize_document
if !(User.current.admin? || User.current.member_of?(@project) || @document.is_public==1)
if !(User.current.admin? || User.current.member_of?(@project) || @document == nil || (@document != nil && @document.is_public==1))
render_403 :message => :notice_not_authorized
end
end

View File

@ -1,4 +1,5 @@
class SoftapplicationsController < ApplicationController
layout "contest_base"
before_filter :find_softapplication, only: [:edit, :update, :destroy]
before_filter :editable, only: [:edit, :update]
before_filter :destroyable, only: :destroy

View File

@ -33,7 +33,7 @@ class UsersController < ApplicationController
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info,
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score]
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities]
#edit has been deleted by huang, 2013-9-23
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,

View File

@ -148,7 +148,7 @@ class WelcomeController < ApplicationController
end
private
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
def entry_select
url = request.original_url
if url.include?("course.trustie.net")
@ -166,28 +166,6 @@ class WelcomeController < ApplicationController
end
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
def entry_select_course
if request.original_url.match(/.*course\.trustie\.net/)
(course() and render :course and return 0)
end
end
def entry_select_contest
if request.original_url.match(/.*contest\.trustie\.net/)
contest
render :contest
return 0
end
end
def entry_select_user
if request.original_url.match(/.*user\.trustie\.net$/)
redirect_to(:controller => "users", :action => "index")
return 0
end
end
# def render(*args)
# _fake if @fake_filter
# super

View File

@ -37,9 +37,17 @@ class ZipdownController < ApplicationController
#下载某一学生的作业的所有文件
def download_user_homework
homework = HomeworkAttach.find params[:homework]
if homework != nil && (User.current.admin? || User.current.member_of_course?(homework.bid.courses.first))
zipfile = zip_homework_by_user homework
send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile
if User.current.admin? || User.current.member_of_course?(homework.bid.courses.first)
if homework != nil
if homework.attachments.count > 0
zipfile = zip_homework_by_user homework
send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile
else
render_403 :message => :no_file_dowmload
end
else
render_403 :message =>:notice_file_not_found
end
else
render_403 :message => :notice_not_authorized
end
@ -81,15 +89,17 @@ class ZipdownController < ApplicationController
end
def zip_homework_by_user(homeattach)
homeworks_attach_path = []
# 需要将所有homework.attachments遍历加入zip
# 并且返回zip路径
user_attaches_paths = homeattach.attachments.each do |attach|
#length = attach.storage_path.length
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
end
zipping "#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true
#user_attaches_paths
#if homeattach.attachments.count > 0
homeworks_attach_path = []
# 需要将所有homework.attachments遍历加入zip
# 并且返回zip路径
user_attaches_paths = homeattach.attachments.each do |attach|
#length = attach.storage_path.length
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
end
zipping("#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true)
#user_attaches_paths
#end
end

View File

@ -46,6 +46,10 @@ class Document < ActiveRecord::Base
!user.nil? && user.allowed_to?(:view_documents, project)
end
def has_right?(project,user=User.current)
user.admin? || user.member_of?(project) || self.is_public==1
end
def initialize(attributes=nil, *args)
super
if new_record?

View File

@ -56,13 +56,12 @@ class Project < ActiveRecord::Base
#added by xianbo for delete biding_project
has_many :biding_projects, :dependent => :destroy
has_many :contesting_projects, :dependent => :destroy
has_many :projecting_softapplications, :dependent => :destroy
has_many :softapplications, :through => :projecting_softapplications
#ended by xianbo
# added by fq
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :homework_for_courses, :dependent => :destroy
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
#has_many :homework_for_courses, :dependent => :destroy
#has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
has_many :shares, :dependent => :destroy
# has_many :students_for_courses, :dependent => :destroy
has_many :student, :through => :students_for_courses, :source => :user
@ -1138,13 +1137,13 @@ class Project < ActiveRecord::Base
# 创建项目后在项目下同步创建一个讨论区
def create_board_sync
@board = self.boards.build
self.name=" #{l(:label_borad_course) }"
self.name=" #{l(:label_borad_project) }"
@board.name = self.name
@board.description = self.name.to_s
if @board.save
logger.debug "[Course Model] ===> #{@board.to_json}"
logger.debug "[Project Model] ===> #{@board.to_json}"
else
logger.error "[Course Model] ===> Auto create board when Course saved, because #{@board.full_messages}"
logger.error "[Project Model] ===> Auto create board when Project saved, because #{@board.full_messages}"
end
end

View File

@ -8,10 +8,7 @@
<table width="100%" valign="center">
<tr>
<td ><span style="margin-left:0px"><%= l(:label_task_plural)%>(<%= @homework_list.count%>)</span>
<%#= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(
User.current.admin? ||
!(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) ||
(Rails.env.development?) %>
<%#= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(is_teacher) %>
</td>
<td align="right">
<div class="project-search">

View File

@ -27,8 +27,8 @@
<% if @grouped.empty? %><p class="nodata"><%= l(:label_no_data) %></p><% end %>
<% @grouped.keys.sort.each do |group| %>
<!-- <h3><%= group %></h3> -->
<%= render :partial => 'documents/document', :collection => @grouped[group] %>
<!-- <h3><%= group %></h3> -->
<%= render :partial => 'documents/document', :collection => @grouped[group] %>
<% end %>
<% html_title(l(:label_document_plural)) -%>

View File

@ -39,7 +39,7 @@
<ul class="list-group-item-meta">
<div class="issue-list-description">
<div class="wiki">
<%= textilizable issue, :description, :attachments => issue.attachments %>
<%= textilizable issue, :description %>
</div>
<!-- <#%= l(:field_description)%>:&nbsp;<#%= issue.short_description %> -->
</div>

View File

@ -0,0 +1,49 @@
<%
@nav_dispaly_contest_label = 1
@nav_dispaly_store_all_label = 1
%>
<!DOCTYPE html>
<html lang="<%= current_language %>">
<head>
<meta charset="utf-8" />
<title><%=h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "jquery.leanModal.min" %>
<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
</head>
<body class="<%=h body_css_classes %>">
<div id="wrapper">
<div id="wrapper2">
<div id="wrapper3">
<%=render :partial => 'layouts/base_header'%>
<div id="main" class="nosidebar">
<div id="content_">
<%= render_flash_messages %>
<%= yield %>
<%= call_hook :view_layouts_base_content %>
<div style="clear:both;"></div>
<%=render :partial => 'layouts/base_footer'%>
</div>
</div>
</div>
<div id="ajax-indicator" style="display:none;"><span><%= l(:label_loading) %></span></div>
<div id="ajax-modal" style="display:none;"></div>
</div>
</div>
<%= call_hook :view_layouts_base_body_bottom %>
</body>
</html>

View File

@ -3,6 +3,10 @@
@nav_dispaly_store_all_label = 1
%>
<%= stylesheet_link_tag 'welcome' %>
<style type="text/css">
#up_zzjs{height:100px;overflow:hidden;}
</style>
<script type="text/javascript" language="javascript">
function clearInfo(id, content) {
var text = $('#' + id);
@ -169,7 +173,7 @@
<% end %>
</div>
<div style="overfowhidden;height:200px;float: left;margin:5px; margin-left: 12px; margin-bottom: 2px; width: 380px;">
<div style="float: left;margin:5px; margin-left: 12px; margin-bottom: 2px; width: 380px;">
<span class='font_lighter' title ='<%=contest.description%>'><%=contest.description.truncate(100, omission: '...')%></span>
</div><br />
@ -195,16 +199,57 @@
<fieldset style="padding-left: 36px; margin-left: 13px; height: 150px; width:380px; border-radius:10px;">
<div style="font-size:14px; color: #1166AD; padding-left:52px; "><strong>2014年Android程序设计大赛获奖名单</strong></div>
<div class="underline-contests_four"></div>
<marquee scrollamount=3 direction=up height=100 onmouseover="this.stop()" onmouseout="this.start()" >
<div><span style="color: red">一等奖:</span>&nbsp<span style="color: #1166AD"><%= link_to "消灭那怪兽", softapplication_path(16) %></span></div>
<div><span style="color: red">二等奖:</span>&nbsp<span style="color: #1166AD"><%= link_to "兄弟向前冲", softapplication_path(20) %></span></div>
<div><span style="color: red">二等奖:</span>&nbsp<span style="color: #1166AD"><%= link_to "鸟鸟文件管理器(银河之光版)", softapplication_path(6) %></span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD"><%= link_to "疯狂猜图", softapplication_path(12) %></span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD"><%= link_to "愉快的定向越野", softapplication_path(14) %></span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD"><%= link_to "体能训练助手", softapplication_path(11) %></span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD"><%= link_to "迷你日记本", softapplication_path(19) %></span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD"><%= link_to "永齐飞机大战", softapplication_path(9) %></span></div>
</marquee>
<div id="up_zzjs">
<div id="marqueebox">
<div><span style="color: red">一等奖:</span>&nbsp<span style="color: #1166AD">消灭那怪兽</span></div>
<div><span style="color: red">二等奖:</span>&nbsp<span style="color: #1166AD">兄弟向前冲 </span></div>
<div><span style="color: red">二等奖:</span>&nbsp<span style="color: #1166AD">鸟鸟文件管理器(银河之光版)</span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD">疯狂猜图</span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD">愉快的定向越野 </span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD">体能训练助手 </span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD">迷你日记本 </span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD">永齐飞机大战</span></div>
</div>
</div>
<!-- 火狐 onmouseover、onmouseout无效 <marquee scrollamount=3 direction=up height=100 onmouseover=stop() onmouseout= start() >
<div><span style="color: red">一等奖:</span>&nbsp<span style="color: #1166AD">消灭那怪兽</span></div>
<div><span style="color: red">二等奖:</span>&nbsp<span style="color: #1166AD">兄弟向前冲 </span></div>
<div><span style="color: red">二等奖:</span>&nbsp<span style="color: #1166AD">鸟鸟文件管理器(银河之光版)</span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD">疯狂猜图</span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD">愉快的定向越野 </span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD">体能训练助手 </span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD">迷你日记本 </span></div>
<div><span style="color: red">三等奖:</span>&nbsp<span style="color: #1166AD">永齐飞机大战</span></div>
</marquee> -->
<script language="javascript">
function startmarquee(lh,speed,delay) {
var p=false;
var t;
var o=document.getElementById("marqueebox");
o.innerHTML+=o.innerHTML;
o.style.marginTop=0;
o.onmouseover=function(){p=true;}
o.onmouseout=function(){p=false;}
function start(){
t=setInterval(scrolling,speed);
if(!p) o.style.marginTop=parseInt(o.style.marginTop)-1+"px";
}
function scrolling(){
if(parseInt(o.style.marginTop)%lh!=0){
o.style.marginTop=parseInt(o.style.marginTop)-1+"px";
if(Math.abs(parseInt(o.style.marginTop))>=o.scrollHeight/2) o.style.marginTop=0;
}else{
clearInterval(t);
setTimeout(start,delay);
}
}
setTimeout(start,delay);
}
startmarquee(20,40,0);
</script>
</fieldset>
</div>
</div>

View File

@ -1867,6 +1867,7 @@ zh:
lable_close_mutual_evaluation: 关闭互评
label_has_been: 已经被
label_course_userd_by: 个课程引用
no_file_dowmload: 该作业没有任何的附件可以下载
role_of_course: 课程角色
label_student: 学生

View File

@ -809,18 +809,18 @@ ActiveRecord::Schema.define(:version => 20140721074353) do
create_table "relative_memos", :force => true do |t|
t.integer "osp_id"
t.integer "parent_id"
t.string "subject", :null => false
t.text "content", :limit => 16777215, :null => false
t.string "subject", :null => false
t.text "content", :null => false
t.integer "author_id"
t.integer "replies_count", :default => 0
t.integer "replies_count", :default => 0
t.integer "last_reply_id"
t.boolean "lock", :default => false
t.boolean "sticky", :default => false
t.boolean "is_quote", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "viewed_count_crawl", :default => 0
t.integer "viewed_count_local", :default => 0
t.boolean "lock", :default => false
t.boolean "sticky", :default => false
t.boolean "is_quote", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "viewed_count_crawl", :default => 0
t.integer "viewed_count_local", :default => 0
t.string "url"
t.string "username"
t.string "userhomeurl"
@ -844,19 +844,6 @@ ActiveRecord::Schema.define(:version => 20140721074353) do
add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
create_table "rich_rich_files", :force => true do |t|
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "rich_file_file_name"
t.string "rich_file_content_type"
t.integer "rich_file_file_size"
t.datetime "rich_file_updated_at"
t.string "owner_type"
t.integer "owner_id"
t.text "uri_cache"
t.string "simplified_type", :default => "file"
end
create_table "roles", :force => true do |t|
t.string "name", :limit => 30, :default => "", :null => false
t.integer "position", :default => 1

View File

@ -10,6 +10,7 @@ class CoursesControllerTest < ActionController::TestCase
Setting.default_language = 'en'
end
# Get :index
def test_index_by_anonymous_should_not_show_private_projects
get :index
assert_response :success
@ -19,6 +20,7 @@ class CoursesControllerTest < ActionController::TestCase
assert courses.all?(&:is_public?)
end
# Get :new
# 人员添加课程的权限是不属于任何角色
def test_new_course_anyone_temporary
@request.session[:user_id] = 5
@ -29,6 +31,7 @@ class CoursesControllerTest < ActionController::TestCase
assert_template :new
end
# post :create
def test_create_course_with_access_control
@request.session[:user_id] = 5
Role.find_by_name("Non member").add_permission! :add_course #Non member
@ -54,6 +57,7 @@ class CoursesControllerTest < ActionController::TestCase
# assert_redirected_to "courses/#{course.id}/settings"
end
# post :create 403
def test_create_course_without_access_control
@request.session[:user_id] = 5
#Role.find_by_name("Non member").add_permission! :add_course #Non member