Merge branch 'develop' of 10.0.47.245:/home/trustie2 into develop

This commit is contained in:
alan 2014-04-17 14:48:35 +08:00
commit f6a1e90ad1
48 changed files with 1146 additions and 766 deletions

View File

@ -1,5 +1,11 @@
source 'https://rubygems.org'
unless RUBY_PLATFORM =~ /w32/
# unix-like only
gem 'iconv'
gem 'rubyzip'
gem 'zip-zip'
end
gem "rails", "3.2.13"
gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0"

View File

@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

View File

@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

View File

@ -150,6 +150,7 @@ class AttachmentsController < ApplicationController
ori = Attachment.find_by_id(attach_id)
next if ori.blank?
attach_copied_obj = ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
attach_copied_obj.container = obj
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id

View File

@ -11,6 +11,42 @@ class ForumsController < ApplicationController
include SortHelper
PageLimit = 20
def create_memo
@memo = Memo.new(params[:memo])
@memo.forum_id = @forum.id
@memo.author_id = User.current.id
@memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads]))
respond_to do |format|
if @memo.save
format.html { redirect_to (forum_memo_path(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))), notice: "#{l :label_memo_create_succ}" }
format.json { render json: @memo, status: :created, location: @memo }
else
sort_init 'updated_at', 'desc'
sort_update 'created_at' => "#{Memo.table_name}.created_at",
'replies' => "#{Memo.table_name}.replies_count",
'updated_at' => "COALESCE (last_replies_memos.created_at, #{Memo.table_name}.created_at)"
@topic_count = @forum.topics.count
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
@memos = @forum.topics.
reorder("#{Memo.table_name}.sticky DESC").
includes(:last_reply).
limit(@topic_pages.per_page).
offset(@topic_pages.offset).
order(sort_clause).
preload(:author, {:last_reply => :author}).
all
flash.now[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}"
# back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id)
format.html { render action: :show, layout: 'base_forums' }#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
format.json { render json: @memo.errors, status: :unprocessable_entity }
end
end
end
def index
@offset, @limit = api_offset_and_limit({:limit => 10})

View File

@ -47,7 +47,30 @@ class MemosController < ApplicationController
else
flash[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}"
# back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id)
format.html { redirect_to back_memo_or_forum_url}#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
pre_count = REPLIES_PER_PAGE
@memo_new = @memo.dup
@memo = @memo.root # 取出楼主防止输入帖子id让回复作为主贴显示
@memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1))
page = params[:page]
if params[:r] && page.nil?
offset = @memo.children.where("#{Memo.table_name}.id < ?", params[:r].to_i).count
page = 1 + offset / pre_count
else
end
@reply_count = @memo.children.count
@reply_pages = Paginator.new @reply_count, pre_count, page
@replies = @memo.children.
includes(:author, :attachments).
reorder("#{Memo.table_name}.created_at ASC").
limit(@reply_pages.per_page).
offset(@reply_pages.offset).
all
format.html { render action: :show }#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
# format.html { redirect_to back_memo_or_forum_url}#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
format.json { render json: @memo.errors, status: :unprocessable_entity }
end
end
@ -76,7 +99,7 @@ class MemosController < ApplicationController
offset(@reply_pages.offset).
all
@mome_new = Memo.new
@memo_new = Memo.new
# @memo = Memo.find_by_id(params[:id])

View File

@ -390,7 +390,7 @@ class ProjectsController < ApplicationController
# added by bai
@course.term = params[:term]
@course.time = params[:time]
@course.school_id = params[:school]
@course.school_name = params[:occupation]
@course.setup_time = params[:setup_time]
@course.endup_time = params[:endup_time]
@course.class_period = params[:class_period]

View File

@ -1,2 +1,15 @@
class SchoolController < ApplicationController
def get_options
@school = School.where("province = ?", params[:province])
p = params[:province]
##@school = School.all
options = ""
@school.each do |s|
options << "<option value=#{s.name}>#{s.name}</option>"
end
render :text => options
end
end

View File

@ -1,160 +1,56 @@
class TestController < ApplicationController
before_filter :find_user, :only => [:new, :create, :destroy]
def index
# @users = User.where('status = ?', 1)
# for user in @users
# if user.user_extensions.nil?
# UserExtensions.create(:user_id => user.id)
# end
# end
# @message = Message.all
# @message.each do |m|
# Activity.create(:act_id => m.id, :act_type => 'Message', :user_id => m.author_id)
# end
# activity = Message.all
# activity += News.all
# activity += Journal.all
# activity += Issue.all
# activity += Bid.all
# @activity = activity.sort {|x,y| x.created_on <=> y.created_on}
# @activity.each do |act|
# if act.instance_of?(Bid)
# act.acts << Activity.new(:user_id => act.author_id)
# elsif act.instance_of?(News)
# act.acts << Activity.new(:user_id => act.author_id)
# elsif act.instance_of?(Message)
# act.acts << Activity.new(:user_id => act.author_id)
# elsif act.instance_of?(Journal)
# act.acts << Activity.new(:user_id => act.user_id)
# elsif act.instance_of?(Issue)
# act.acts << Activity.new(:user_id => act.author_id)
# elsif act.instance_of?(Changeset)
# act.acts << Activity.new(:user_id => act.user_id)
# end
# end
#@watchers_of_projects = WatchersOfProjects.new
#@watchers_of_projects.user_id = 1
#@watchers_of_projects.project_id = 1
#@watchers_of_projects.save
#测试user表与watch_project表之间的关联是否成功
#@user = User.find(params[:id])
#@watch_table = @user.watch_projects.to_a.first
#@watch = WatchProject.find(1)
#@watcher = @watch.user
#测试通过watch_project表使user表可以访问project表
#@watch_project = @user.projects
#watch_project_path(@watch)
#@project = Project.find(11)
#project_path(@project)
#@member = @project.users
#@watched = @project.watch_projects
#@issue = Issue.find(6)
#user_path(@user)
#issue_path(@issue)
#@watcher2=WatchProject.where("#{WatchProject.table_name}.project_id = ?" , temp)
#测试where语句
#temp = 1
#@watcher2=WatchProject.where(:project_id => temp).to_a
#测试新建记录
#@watch_new = WatchProject.new
#@watch_new.user_id = 4
#@watch_new.project_id = 1
#@watch_new.save
#@id = params[:id]
#测试添加关注项目功能
#WatchersOfProjects.watch(3,10)
#Project.find(50)
#测试统计关注该项目的用户数
#@count = WatchersOfProjects.watcher_count(@watch_project.to_a.first)
#测试取消关注功能
#WatchersOfProjects.watch_cancle(10,35)
#测试关注用户功能
#测试关注功能
#WatchersOfUser.watch_user(7,7)
#测试取消关注功能
#WatchersOfUser.cancel_watching_user(1,2)
#测试查找关注的人功能
#@user = WatchersOfUser.find_users(1)
#测试查找被关注的人功能
#@user = WatchersOfUser.find_watchers(10)
#测试用户留言功能
#测试留言功能
# MessagesForUser.leave_message(User.current.id, 6, 'test')
#测试查找留言功能
#@message_table = MessagesForUser.find_message(3)
#测试查找留言用户功能
#@messager=@message_table.first.find_messager
#测试需求
#测试新建需求
#bids = Bid.creat_bids(10000, '2013.7.25', 'test', 'sfsadgfag')
#测试修改需求
#bids.update_bids(10, '2014.7.222', 'asdf')
#测试删除需求
# bids = Bid.where('id = ?', 5)
# bids.each do |bid|
# bid.delete_bids
# end
def zip
homeworks_attach_path = []
homework_id = params[:homework_id]
bid = Bid.find_by_id(homework_id)
bid.homeworks.each do |homeattach|
homeattach.attachments.each do |attach|
length = attach.storage_path.length
homeworks_attach_path << attach.diskfile.to_s.slice((length+1)..-1)
end
end
@paths = homeworks_attach_path
zipfile = ziping homeworks_attach_path
send_file zipfile, :filename => bid.name,
:type => detect_content_type(zipfile)
rescue Errno::ENOENT => e
logger.error "[Errno::ENOENT] ===> #{e}"
end
def courselist
@courses = Project.course_entities
end
def ziping files_path
ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE')
folder = "#{Rails.root}/files"
input_filename = files_path
zipfile_name = "#{Rails.root}/tmp/archiveZip/archive_#{Time.now.to_i}.zip"
# ##########留言功能 message by fq
# def new
# end
#
# def create
#
# if params[:user_search].size>0
# unless params[:user_id].nil?
# message = params[:user_search]
# MessagesForUser.leave_message(User.current.id, params[:user_id], message)
# @message = MessagesForUser.find_message(@user.id)
# end
# end
#
# respond_to do |format|
# # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
# format.js
# #format.api { render_api_ok }
# end
# end
#
# def destroy
# MessagesForUser.delete_message(params[:object_id])
# @message = MessagesForUser.find_message(@user.id)
# respond_to do |format|
# format.html { redirect_to :back }
# format.js
# #format.api { render_api_ok }
# end
# end
Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name))
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
input_filename.each do |filename|
zipfile.add(ic.iconv(filename_to_real(File.basename(filename))), folder + '/' + filename)
end
zipfile.get_output_stream("ReadMe"){ |os|
os.write "Homeworks"
}
end
zipfile_name
end
def detect_content_type(name)
content_type = Redmine::MimeType.of(name)
content_type.to_s
end
# private
#
# def find_user
# if params[:user_id]
# @user = User.find(params[:user_id])
# end
# rescue
# render_404
# end
#######end of message
def filename_to_real name
attach = Attachment.find_by_disk_filename(name)
attach.filename
end
end

View File

@ -0,0 +1,68 @@
class ZipdownController < ApplicationController
def assort
obj_class = params[:obj_class]
obj_id = params[:obj_id]
obj = obj_class.constantize.find(obj_id)
case obj.class.to_s.to_sym
when :Bid
zip obj
else
logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!"
end
rescue NameError, ActiveRecord::RecordNotFound => e
logger.error "[ZipDown] ===> #{e}"
@error = e
end
private
def zip bid
# Todo: User Access Controll
homeworks_attach_path = []
bid.homeworks.each do |homeattach|
homeattach.attachments.each do |attach|
length = attach.storage_path.length
homeworks_attach_path << attach.diskfile.to_s.slice((length+1)..-1)
end
end
@paths = homeworks_attach_path
zipfile = ziping homeworks_attach_path
send_file zipfile, :filename => bid.name,
:type => detect_content_type(zipfile)
rescue Errno::ENOENT => e
logger.error "[Errno::ENOENT] ===> #{e}"
@error = e
end
def ziping files_path
ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE')
folder = "#{Rails.root}/files"
input_filename = files_path
zipfile_name = "#{Rails.root}/tmp/archiveZip/archive_#{Time.now.to_i}.zip"
Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name))
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
input_filename.each do |filename|
zipfile.add(ic.iconv(filename_to_real(File.basename(filename))), folder + '/' + filename)
end
zipfile.get_output_stream("ReadMe"){ |os|
os.write "Homeworks"
}
end
zipfile_name
rescue Errno=> e
logger.error "[zipdown#zipping] ===> #{e}"
@error = e
end
def detect_content_type(name)
content_type = Redmine::MimeType.of(name)
content_type.to_s
end
def filename_to_real name
attach = Attachment.find_by_disk_filename(name)
attach.filename
end
end

View File

@ -0,0 +1,2 @@
module ZipdownHelper
end

View File

@ -4,9 +4,10 @@ class Memo < ActiveRecord::Base
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
validates_presence_of :author_id, :forum_id, :subject
#validates :content, presence: true
# 若是主题帖,则内容可以是空
validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? }
validates_length_of :subject, maximum: 50
#validates_length_of :content, maximum: 3072
validates_length_of :content, maximum: 3072
validate :cannot_reply_to_locked_topic, :on => :create
acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC"

View File

@ -12,11 +12,14 @@
<% end %>
</span>
<span class="add_attachment">
<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()" %>
<!--%= link_to image_tag(),"javascript:void(0)", :onclick => "_file.click()"%-->
<%= file_field_tag 'attachments[dummy][file]',
:id => nil,
:id => '_file',
:class => 'file_selector',
:multiple => true,
:onchange => 'addInputFiles(this);',
:style => 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
@ -24,6 +27,7 @@
:upload_path => uploads_path(:format => 'js'),
:description_placeholder => l(:label_optional_description)
} %>
<span id="upload_file_count"><%= l(:label_no_file_uploaded)%></span>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</span>

View File

@ -1 +1,8 @@
$('#attachments_<%= j params[:attachment_id] %>').remove();
var count=$('#attachments_fields>span').length;
if(count<=0){
$("#upload_file_count").text("未上传文件");
$(".remove_all").remove();
}else{
$("#upload_file_count").html("已上传"+"<span id=\"count\">"+count+"</span>"+"个文件");
}

View File

@ -8,7 +8,7 @@ fileSpan.find('a.remove-upload')
.attr({
"data-remote": true,
"data-method": 'delete',
href: '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>'
"href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>'
})
.off('click');
<% end %>

View File

@ -60,7 +60,10 @@
<% end %> <!-- <td style="color: rgb(255, 0, 0);"><strong><%= l(:label_price) %><%= l(:label_RMB_sign) %><%= bid.budget%></strong></td> --></td>
</tr>
<tr>
<td colspan="2" width="580px" ><span class="font_description"><%= bid.description %></span></td>
<td colspan="2" width="580px" ><span class="font_description">
<%#= bid.description %>
<%= textilizable bid, :description %>
</span></td>
</tr>
<tr>
<td align="left"><span class="font_lighter"><span> <%= l(:label_create_time) %> :&nbsp; <%=format_time bid.created_on %></span><span style="float: right"> <%= l(:field_deadline) %> :&nbsp; <%=bid.deadline %></span></td>

View File

@ -14,6 +14,10 @@
</div>
<% end %>
<% display_id = im_watching_student_id? @bid%>
<%= 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;display: inline-block;" if(
User.current.admin? ||
!(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) ||
(Rails.env.development?) %>
<% @homework_list.each do |homework|%>
<% if homework.attachments.any?%>
<table width="660px" border="0" align="center">
@ -22,7 +26,12 @@
<td>
<table width="580px" border="0">
<tr>
<td colspan="2" valign="top"><strong> <%= link_to homework.user, user_path(homework.user)%></strong> <span class="font_lighter">已提交</span></td>
<td colspan="1" valign="top"><strong> <%= link_to homework.user, user_path(homework.user)%></strong> <span class="font_lighter">已提交</span></td>
<td valign="top" align="right">
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.attachments[0].created_on.to_s) %>
<span class="required">迟交</span>
<% end %>
</td>
</tr>
<tr>
<td colspan="2" valign="top">&nbsp;

View File

@ -147,6 +147,13 @@
<%= format_time b_project.created_at%>
</span></td>
</tr>
<tr>
<td>
<% if Time.parse(@bid.deadline.to_s) < Time.parse(b_project.created_at.to_s) %>
<span class="required">迟交</span>
<% end %>
</td>
</tr>
</table>
</td>
<td width="30%">

View File

@ -1,6 +1,6 @@
<!-- fq -->
<% if @bid.homework_type == 1%>
<% if @bid.homework_type == Bid::HomeworkFile %>
<%= render :partial => 'homework' %>
<% else %>

View File

@ -2,7 +2,7 @@
<div id="add-memo" class='lz' style="display: none; padding: 20px;">
<h3><%=l(:label_memo_new)%></h3>
<% if User.current.logged? %>
<%= labelled_form_for(@memo, :url => forum_memos_path(@forum), :html => {:multipart => true} ) do |f| %>
<%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %>
<% if @memo.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2>

View File

@ -1,20 +1,31 @@
<!--add by huang-->
<div class="clearfix"></div>
<div id="footer" style="margin-left:-5px;padding-top: 50px;clear: both;">
<div id="footer" style="margin-left:-5px;padding-top: 50px;clear: both;font-size: 12px;">
<div style="border-top:solid 1px #C6E9F1;width:940px;margin-left:auto;margin-right:auto;margin-bottom: 5px;margin-top: -10px;"></div>
<div class="base_footer"><div align="center">
<span> Trustie 研发团队 2007~2014 </span>
</div></div>
<div class="base_footer">
<div align="center">
<!--gcm-->
<p>
主办单位
</p>
<p style="">
<%= link_to image_tag('/images/footer_logo/pdl.jpg',:size=>'150x40',:alt=>"国防科学技术大学并行与分布处理国家重点实验室"), "http://www.nudt.edu.cn/ArticleShow.asp?ID=47", :target=>"_blank"%>
<%= link_to "Trustie 开发团队 ","http://forge.trustie.net/projects/2/member",:target=>"_blank",:style=>"position:relative; top:-15px; left:5px; font-weight: bold"%>
</p>
<p>
核心技术团队
</p>
<div id="logo_link">
<%= link_to image_tag('/images/footer_logo/nudt.jpg',:size=>'150x40',:alt=>"国防科学技术大学计算机学院"),"http://www.nudt.edu.cn/special.asp?classid=12"%>
<%= link_to image_tag('/images/footer_logo/peking_eecs.jpg',:size=>'150x40',:alt=>"北京大学信息科学技术学院软件研究所"), "http://eecs.pku.edu.cn"%>
<%= link_to image_tag('/images/footer_logo/buaa_scse.jpg',:size=>'150x40',:alt=>"北京航空航天大学计算机学院"), "http://scse.buaa.edu.cn/iniAction.action"%>
<%= link_to image_tag('/images/footer_logo/iscas.jpg',:size=>'150x40',:alt=>"中国科学院软件研究所"), "http://www.iscas.ac.cn"%>
<%= link_to image_tag('/images/footer_logo/inforbus.jpg',:size=>'150x40',:alt=>"山东中创软件商用中间件股份有限公司"), "http://www.inforbus.com"%>
</div>
<p style="font-size: 1em">
国防科学技术大学并行与分布处理国家重点实验室 版权@2007~2014 湘ICP备09019772
</p>
<!--gcm-->
</div>
</div>
</div>
<%= debug(params) if Rails.env.development? %>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-46523987-1', 'trustie.net');
ga('send', 'pageview');
</script>

View File

@ -240,14 +240,15 @@
<%= yield %>
<%= call_hook :view_layouts_base_content %>
<div style="clear:both;"></div>
<!--gcm-->
</div>
<!--gcm move it mistakenly-->
<%= render :partial => 'layouts/base_footer'%>
</div>
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>
</div>
<div id="ajax-modal" style="display:none;"></div>
</div>
</div>

View File

@ -1,4 +1,4 @@
<%= form_for(@mome_new, url: forum_memos_path, :html => {:multipart => true}) do |f| %>
<%= form_for(@memo_new, url: forum_memos_path, :html => {:multipart => true}) do |f| %>
<%= f.hidden_field :subject, :required => true, value: @memo.subject %>
<%= f.hidden_field :forum_id, :required => true, value: @memo.forum_id %>
<%= f.hidden_field :parent_id, :required => true, value: @memo.id %>

View File

@ -1,7 +1,7 @@
<div class="lz">
<div class="lz-left">
<div class=""><%= link_to image_tag(url_to_avatar(@memo.author), :class => "avatar"), user_path(@memo.author) %></div>
<p class=""><%=link_to @memo.author.name, user_path(@memo.author) %></p>
<div><%= link_to image_tag(url_to_avatar(@memo.author), :class => "avatar"), user_path(@memo.author) %></div>
<p class="clearfix"><%=link_to @memo.author.name, user_path(@memo.author) %></p>
</div>
<div class="memo-section">
<div class="contextual-borad">

View File

@ -1,3 +1,20 @@
<script type="text/javascript">
function get_options(value){
$.ajax({
type :"POST",
url :'/school/get_options/'+encodeURIComponent(value),
data :'text',
success: function(data){
$("#occupation").html(data);
}
}
)
}
</script>
<div class="contextual" style="padding-right: 10px;">
<%= link_to(l(:button_change_password), {:action => 'password'}, :class => 'icon icon-passwd') if @user.change_password_allowed? %>
<%= call_hook(:view_my_account_contextual, :user => @user)%>
@ -61,13 +78,23 @@
<% end %>
<!-- added by bai 单位-->
<% unless @user.user_extensions.nil?%>
<p style="width:400px;padding-left: 26px;"><%= l(:field_occupation)%>&nbsp;<%= text_field_tag "occupation", @user.user_extensions.occupation, :class => 'occupation'%>
<!--<% unless @user.user_extensions.nil?%>
<p style="width:400px;padding-left: 26px;"><%= l(:field_occupation)%>&nbsp;<span class="required">*</span><%= text_field_tag "occupation", @user.user_extensions.occupation, :class => 'occupation' %>
</p>
<%else%>
<p style="width:400px;padding-left: 26px;"><%= l(:field_occupation)%><%= text_field_tag "occupation", nil, :class => 'occupation'%>
<p style="width:400px;padding-left: 26px;"><%= l(:field_occupation)%><span class="required">*</span><%= text_field_tag "occupation", nil, :class => 'occupation' %>
</p>
<%end%>
-->
<!-- added by Wen -->
<p style="width:357px;padding-left: 26px;">
<%= l(:field_occupation) %>&nbsp;<span class="required">*</span><%= select_tag "province", options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province), :onchange => "get_options(this.value)" %>
<%= select_tag "occupation", options_for_select([['安徽大学','安徽大学'],['合肥工业大学','合肥工业大学'],['中国科技大学','中国科技大学']]) %>
</p>
<!-- added by bai 增加了地区 -->

View File

@ -1,4 +1,19 @@
<script type="text/javascript">
function get_options(value){
$.ajax({
type :"POST",
url :'/school/get_options/'+encodeURIComponent(value),
data :'text',
success: function(data){
$("#occupation").html(data);
}
}
)
}
</script>
<% object = [] %>
@ -269,10 +284,12 @@
<!--added by Wen -->
<p style="margin-left:-76px;">
<strong><%=l(:label_new_course_school)%></strong><span class="required">*</span>&nbsp;&nbsp;&nbsp;
<%= select_tag "province", options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province), :onclick => "get_options(this.value)" %>
<p>
<select name='province' "><%= options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province) %></select>
<%= select_tag 'school', options_from_collection_for_select(School.all, :id, :name)%>
<%= select_tag "occupation", options_for_select([['安徽大学','安徽大学'],['合肥工业大学','合肥工业大学'],['中国科技大学','中国科技大学']]) %>
</p>
<!-- end -->

View File

@ -22,6 +22,7 @@
:class => 'repository' + (repo == @repository ? ' selected' : '')
}.join('&nbsp|&nbsp').html_safe %>)</p>
<% else %>
<h3>项目代码请设置好正确的编码方式utf-8否则中文会出现乱码</h3>
<h3>建立版本库文件夹,打开命令行执行如下:</h3>
<div class="repos_explain">
<p>git init</p>
@ -30,11 +31,22 @@
<p>git remote add origin <%= @repos_url%></p>
<p>git push -u origin master:master</p>
</div>
<h3>已经有本地库,打开命令行执行如下:</h3>
<h3>已经有本地库,还没有配置远程地址,打开命令行执行如下:</h3>
<div class="repos_explain">
<p>git remote add origin <%= @repos_url%></p>
<p>git add .</p>
<p>git commit -m "first commit"</p>
<p>git push -u origin master:matser</p>
</div>
</h3>
<h3>从网上获取别人的开源版本库转交到trustie网站上打开命令行执行如下</h3>
<div class="repos_explain">
<p>git remote add trustie <%= @repos_url%></p>
<p>git add .</p>
<p>git commit -m "first commit"</p>
<p>git push -u trustie master:matser</p>
<p><%= link_to "李海提供", user_path(646)%></p>
</div>
<% end %>
</h3>
<% if !@entries.nil? && authorize_for('repositories', 'browse') %>

View File

@ -0,0 +1,42 @@
<style type="text/css">
.courses_list{
font-size: 18px;
font-weight: 800;
margin: 40px 10px;
}
.homeworks{
font-size: 16px;
font-weight: 500;
margin: 5px 40px 20px;
}
.attach_item{
font-size: 14px;
font-weight: 400;
margin: auto 60px;
}
</style>
<% @courses.each do |course| %>
<div class="courses_list">
<%= course.name %>
<% course.homeworks.each do |homework| %>
<% homeworks_attach_path = [] %>
<div class="homeworks">
<%= link_to homework.name, respond_path(homework) %>(<%=homework.homeworks.count %>)<%#Bid%>
<div class="attach_item">
<%= link_to "package", test_zip_path(:homework_id => homework.id)%><br/>
<% homework.homeworks.each do |homeattach|%><%#homework.class == Bid %>
<% homeattach.attachments.each do |attach|%>
<%= link_to_attachment attach, author: true, :download => true %> (<%=attach.author%>)
<br/>
<% homeworks_attach_path << attach.storage_path %>
<% end %>
<% end %>
</div>
<%# 所有作业的文件列表%>
<!-- (<%=homeworks_attach_path.count%>):<%= homeworks_attach_path.to_json %> -->
</div>
<% end %>
</div>
<hr/>
<% end %>

View File

@ -0,0 +1 @@
<%= debug @paths.to_yaml %>

View File

@ -245,7 +245,7 @@
<div style="width:100%;">
<div style="width:600px;margin:0px auto;margin-top:80px;">
<table style="width:600px;font-size:15px; color: #e8770d;">
<table style="width:600px;font-size:15px; color: gray;">
<tr>
<td><strong>当前网站状态</strong></td>
<td>活跃项目:<%=@projectCount%>个</td>

View File

@ -0,0 +1,2 @@
<h1>Download Status:</h1>
<%= @error.class %>

View File

@ -741,6 +741,7 @@ zh:
label_latest_revision_plural: 最近的修订版本
label_view_revisions: 查看修订
label_view_all_revisions: 查看所有修订
label_no_file_uploaded: 未上传文件
label_max_size: 最大文件大小
label_sort_highest: 置顶
label_sort_higher: 上移
@ -1746,6 +1747,7 @@ zh:
label_exit_course: 退出课程
label_new_join: 加入
label_new_course_password: 课程密码
label_new_course_school: 开课学校
label_new_course_description: 课程描述
label_new_join_order: 请输入课程密码
label_task_submit_form_accessory: 作业最终以附件形式提交

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
class RemoveSchoolidFromCourses < ActiveRecord::Migration
def up
remove_column :courses, :school_id
end
def down
add_column :courses, :school_id, :integer
end
end

View File

@ -0,0 +1,6 @@
class AddSchoolNameToCourses < ActiveRecord::Migration
def change
add_column :courses, :school_name, :string
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140320022724) do
ActiveRecord::Schema.define(:version => 20140415090829) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -157,6 +157,38 @@ ActiveRecord::Schema.define(:version => 20140320022724) do
add_index "comments", ["author_id"], :name => "index_comments_on_author_id"
add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type"
create_table "contesting_projects", :force => true do |t|
t.integer "project_id"
t.string "contest_id"
t.integer "user_id"
t.string "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "reward"
end
create_table "contesting_softapplications", :force => true do |t|
t.integer "softapplication_id"
t.integer "contest_id"
t.integer "user_id"
t.string "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "reward"
end
create_table "contests", :force => true do |t|
t.string "name"
t.integer "budget"
t.integer "author_id"
t.date "deadline"
t.string "description"
t.integer "commit"
t.string "password"
t.datetime "created_on", :null => false
t.datetime "updated_on", :null => false
end
create_table "courses", :force => true do |t|
t.integer "tea_id"
t.string "name"
@ -173,7 +205,7 @@ ActiveRecord::Schema.define(:version => 20140320022724) do
t.string "setup_time"
t.string "endup_time"
t.string "class_period"
t.integer "school_id"
t.string "school_name"
end
create_table "custom_fields", :force => true do |t|
@ -354,6 +386,13 @@ ActiveRecord::Schema.define(:version => 20140320022724) do
add_index "issues", ["status_id"], :name => "index_issues_on_status_id"
add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id"
create_table "join_in_competitions", :force => true do |t|
t.integer "user_id"
t.integer "competition_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "join_in_contests", :force => true do |t|
t.integer "user_id"
t.integer "bid_id"
@ -645,6 +684,21 @@ ActiveRecord::Schema.define(:version => 20140320022724) do
t.string "description"
end
create_table "softapplications", :force => true do |t|
t.string "name"
t.string "description"
t.integer "app_type_id"
t.string "app_type_name"
t.string "android_min_version_available"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "contest_id"
t.integer "softapplication_id"
t.integer "is_public"
t.string "application_developers"
end
create_table "students_for_courses", :force => true do |t|
t.integer "student_id"
t.integer "course_id"
@ -758,6 +812,16 @@ ActiveRecord::Schema.define(:version => 20140320022724) do
add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id"
create_table "user_scores", :force => true do |t|
t.integer "user_id", :null => false
t.integer "collaboration"
t.integer "influence"
t.integer "skill"
t.integer "active"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "user_statuses", :force => true do |t|
t.integer "changesets_count"
t.integer "watchers_count"

38
lib/tasks/rubyzip.rake Normal file
View File

@ -0,0 +1,38 @@
desc "nyan ruby zip operation"
task :zip do
puts "input rake zip:clean_tmp will removed tmp/*.zip ."
end
namespace :zip do
desc "ruby zip sweeper"
task :clean_tmp do
unless File.exist?(Dir.pwd+"/tmp/archiveZip")
puts "tmp/archiveZip folder is not exist. "
next
end
puts "ruby zip sweeping..."
Dir.chdir('tmp/archiveZip') do
Dir['*'].select do |file|
if file =~ /archive_\d+\.zip/
File.delete(file)
puts "#{file} is deleted."
end
end
end
puts "ruby zip sweeping is done."
end
end
desc "create tmp file, to test"
file 'tmp/test.yml' do
require 'yaml'
var = {
:name => "name",
:age => "age",
:agent => "agent"
}
File.open('tmp/test.yml', 'w') do |f|
f.write YAML.dump({'conf' => var })
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -7,14 +7,14 @@ function addFile(inputEl, file, eagerUpload) {
var attachmentId = addFile.nextAttachmentId++;
var fileSpan = $('<span>', { id: 'attachments_' + attachmentId });
var fileSpan = $('<span>', { 'id': 'attachments_' + attachmentId, 'class':'attachment' });
fileSpan.append(
$('<input>', { type: 'text', 'class': 'filename readonly', name: 'attachments[' + attachmentId + '][filename]', readonly: 'readonly'} ).val(file.name),
$('<input>', { type: 'text', 'class': 'description', name: 'attachments[' + attachmentId + '][description]', maxlength: 255, placeholder: $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload),
$('<a>&nbsp</a>').attr({ href: "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload)
$('<input>', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name),
$('<input>', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 255, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload),
$('<a>&nbsp</a>').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload)
).appendTo('#attachments_fields');
if(eagerUpload) {
ajaxUpload(file, attachmentId, fileSpan, inputEl);
}
@ -63,6 +63,22 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
}
form.dequeue('upload');
});
//gcm files count and add delete_all link
var count=$('#attachments_fields>span').length;
$('#upload_file_count').html("已上传"+"<span id=\"count\">"+count+"</span>"+"个文件");
if(count>=1){
var add_attachs=$('.add_attachment');
var delete_all=$('.remove_all');
if(delete_all.length<1){
add_attachs.append($("<a>&nbsp</a>").attr({"href":"javascript:void(0)", 'class': 'remove_all',"onclick": "removeAll()"}));
}
}
//gcm
}
var progressSpan = $('<div>').insertAfter(fileSpan.find('input.filename'));
@ -84,6 +100,16 @@ function removeFile() {
return false;
}
//gcm delete all file
function removeAll(){
if(confirm("您确定要删除所有文件吗?")){
$(".remove-upload").removeAttr("data-confirm");
$(".remove-upload").click();
}
// return false;
}
//gcm
function uploadBlob(blob, uploadUrl, attachmentId, options) {
var actualOptions = $.extend({

View File

@ -1727,7 +1727,7 @@ ul.properties li span {font-style:italic;}
/*end*/
.autoscroll {overflow-x: auto; padding:1px; margin-bottom: 1.2em;}
#user_login, #user_firstname, #user_lastname, #user_mail, #my_account_form select, #user_form select, #user_identity_url { width: 60%; }
/*#user_login, #user_firstname, #user_lastname, #user_mail, #my_account_form select, #user_form select, #user_identity_url { width: 45%; }*/
#workflow_copy_form select { width: 200px; }
table.transitions td.enabled {background: #bfb;}
@ -1821,6 +1821,11 @@ span.required {color: #bb0000;}
a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block; padding-left:16px;}
a.remove-upload:hover {text-decoration:none !important;}
/*gcm upload file count and deleteall*/
#upload_file_count #count {color:red; font-size:1.5em;}
span.add_attachment .remove_all {background:none;background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block;position:absolute;right:21px;text-decoration:none;}
div.fileover { background-color: lavender; }
div.attachments { margin-top: 12px; }

View File

@ -456,6 +456,7 @@ ul.projects li.root
width:auto;
float:center;
min-height:800px;
border: 1px solid #ffffff;
}
/*by huang*/
@ -981,7 +982,8 @@ hr
}
p
{
font-size: 13px
font-size: 13px;
position:relative;/*gcm*/
}
/*end*/
div.issue
@ -1906,6 +1908,10 @@ input[type="submit"], .button_submit {
text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2), 0px 1px 0px rgb(255, 255, 255);
cursor: pointer;
}
.button_submit_font_white{
color: white !important ;
font-weight: 400;
}
input[type="button-submit"] {
padding-bottom: 5px;

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ZipdownControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class ZipdownHelperTest < ActionView::TestCase
end