This commit is contained in:
z9hang 2014-07-08 09:12:28 +08:00
commit b4bf320c2e
20 changed files with 229 additions and 123 deletions

View File

@ -28,6 +28,9 @@ class ContestsController < ApplicationController
@offset, @limit = api_offset_and_limit({:limit => 10})
@contests = Contest.visible
@contests = @contests.like(params[:name]) if params[:name].present?
if params[:contests_search]
(redirect_to contests_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
end
@contest_count = @contests.count
@contest_pages = Paginator.new @contest_count, @limit, params['page']

View File

@ -20,25 +20,27 @@ class StoresController < ApplicationController
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%").
reorder("created_on DESC")
result = resultSet.to_a.dup
# result = resultSet.to_a.dup
resultSet.to_a.map { |res|
if(res.container.nil? ||
(res.container.class.to_s=="Project" && res.container.is_public == false) ||
(res.container.has_attribute?(:project) && res.container.project.is_public == false) ||
(res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
false
)
result.delete(res)
end
}
result
# resultSet.to_a.map { |res|
# if(res.container.nil? ||
# (res.container.class.to_s=="Project" && res.container.is_public == false) ||
# (res.container.has_attribute?(:project) && res.container.project.is_public == false) ||
# (res.container.class.to_s=="HomeworkAttach" && res.container.bid.reward_type == 3) ||
# false
# )
# result.delete(res)
# end
# }
# result
end
LIMIT = 12 unless const_defined?(:LIMIT)
def index
@projects_attach = project_classification(0).take(LIMIT)
@courses_attach = project_classification(1).take(LIMIT)
@courses_attach = Attachment.includes(:course).where("courses.is_public = ?", 1).
where(container_type: 'Course').
limit(LIMIT)
# @projects_attach = Attachment.includes(:project).where("projects.project_type=? AND projects.is_public = ?", 0, 1).
# reorder("#{Attachment.table_name}.downloads DESC").
# limit(LIMIT)

View File

@ -110,7 +110,7 @@ module AttachmentsHelper
# 搜索到的资源
searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
searched_attach = private_filter searched_attach
#searched_attach = private_filter searched_attach
searched_attach = paginateHelper(searched_attach, 10)
s = content_tag('div', attachments_check_box_tags('attachment[attach][]', searched_attach), :id => 'attachments')
@ -149,7 +149,7 @@ module AttachmentsHelper
# 搜索到的资源
searched_attach = domain.where("filename LIKE :like ", like:"%#{filename_condition}%").limit(limit).order('created_on desc')
searched_attach = private_filter searched_attach
#searched_attach = private_filter searched_attach
searched_attach = paginateHelper(searched_attach, 10)
#testattach = Attachment.public_attachments

View File

@ -256,8 +256,8 @@ module CoursesHelper
people
end
# 截至到2014-03-17 这个是最终的判断课程是否过期的方法
def course_endTime_timeout? project
end_time_str = Course.find_by_extra(project.try(:extra)).try(:endup_time)
def course_endTime_timeout? course
end_time_str = course.try(:endup_time)
begin
cTime = Time.parse(end_time_str.to_s)
rescue TypeError,ArgumentError

View File

@ -37,15 +37,24 @@ module StoresHelper
WORD_LIMIT = 100
def come_from_local attachment
container = attachment.container
case container.class.to_s
when 'Message'
# binding.pry
# '项目 > zzz > 论坛 > 帖子xxx'
# topic_str = container.project.project_type == 0 ? l(:label_board) : l(:label_new_course)
topic_list = link_to l(:label_board), project_boards_path(container.project)
topic_item = link_to container.subject.truncate(WORD_LIMIT, omission: '...'), board_message_path(container.board, container), title: container.subject
project_link(container.project).push(topic_list, topic_item)
course = container.course
project = container.project
if course.nil? # container is belongs to Project
topic_list = link_to l(:label_board), project_boards_path(container.project)
topic_item = link_to container.subject.truncate(WORD_LIMIT, omission: '...'), board_message_path(container.board, container), title: container.subject
project_link(container.project).push(topic_list, topic_item)
else # container is belongs to Course
topic_list = link_to l(:label_course_news), course_boards_path(course)
topic_item = link_to container.try(:subject).to_s.truncate(WORD_LIMIT, omission: '...'), board_message_path(container.board, container), title: container.subject
project_link(course).push(topic_list, topic_item)
end
when 'Issue'
# '项目 > zzz > 缺陷 > 问题xxx'
issue_list = link_to l(:label_project_issues), project_issues_path(container.project)
@ -58,15 +67,26 @@ module StoresHelper
project_link(container.project).push(doc_list, doc_item)
when 'News'
# '课程 > zzz > 新闻 > 新闻xxx'
news_str = container.project.project_type == 0 ? l(:label_news) : l(:label_course_news)
news_list = link_to news_str, project_news_index_path(container.project)
news_item = link_to container.title.truncate(WORD_LIMIT, omission: '...'), news_path(container), title: container.title
project_link(container.project).push(news_list, news_item)
course = container.course
project = container.project
if course.nil? # container is belongs to Project
news_list = link_to l(:label_news), project_news_index_path(container.project)
news_item = link_to container.title.truncate(WORD_LIMIT, omission: '...'), news_path(container), title: container.title
project_link(container.project).push(news_list, news_item)
else # container is belongs to Course
news_list = link_to l(:label_course_news), course_news_index_path(course)
news_item = link_to container.title.truncate(WORD_LIMIT, omission: '...'), news_path(container), title: container.title
project_link(course).push(news_list, news_item)
end
when 'Project'
# '项目 > zzz '
file_str = container.project.project_type == 0 ? l(:project_module_files) : l(:label_course_file)
files_list = link_to file_str, project_files_path(container.project)
project_link(container).push(files_list)
when 'Course'
files_list = link_to l(:label_course_file), course_files_path(container)
project_link(container).push(files_list)
when 'Version'
# '项目 > zzz > 里程碑 > xxx'
ver_list = link_to l(:label_roadmap), project_roadmap_path(container.project)
@ -91,7 +111,8 @@ module StoresHelper
# '竞赛 > xxx '
bid_link(container)
else
Rails.logger.error "ERROR: attachment type unkown"
Rails.logger.error "ERROR: attachment type unkown. file:#{__FILE__}, line:#{__LINE__}"
Rails.logger.error "#{container.class.to_s}"
[link_to('unkown', '')]
end
rescue ActionController::RoutingError => e
@ -99,20 +120,6 @@ module StoresHelper
[link_to('unkown', '')]
end
def project_link project
if project.nil?
Rails.logger.error "ERROR: attachment type unkown #project_link project.nil?"
return [link_to('unkown', '')]
end
project_list = nil
if project.project_type == 0
project_list = link_to l(:label_project_plural), projects_path
else
project_list = link_to l(:label_new_course), course_path
end
project_item = link_to project.to_s, project_path(project)
[project_list, project_item]
end
def bid_link bid
bid_list = nil
@ -129,7 +136,7 @@ module StoresHelper
Rails.logger.error "ERROR: attachment type unkown #bid_link/when 3"
return [link_to('unkown', '#')]
end
bid_list = link_to l(:label_homework), project_homework_path(bid.courses.first)
bid_list = link_to l(:label_homework), homework_course_path(bid.courses.first)
bid_item = link_to bid.name, respond_path(bid)
return project_link(bid.courses.first).push(bid_list, bid_item)
else
@ -137,4 +144,28 @@ module StoresHelper
end
[bid_list, bid_item]
end
def project_link project
if project.nil?
Rails.logger.error "ERROR: attachment type unkown #project_link project.nil? file: #{__FILE__}, line: #{__LINE__}"
return [link_to('unkown', '')]
end
project_list = nil
klass = project.class.to_s
case klass
when "Project"
project_list = link_to l(:label_project_plural), projects_path
project_item = link_to project.to_s, project_path(project)
[project_list, project_item]
when "Course"
course_list = link_to l(:label_new_course), courses_path
course_item = link_to project.name, course_path(project)
[course_list, course_item]
else
Rails.logger.error "[StoresHelper]: #{klass} ======================================="
[]
end
end
end

View File

@ -24,8 +24,9 @@ class Contest < ActiveRecord::Base
validates_length_of :name, :maximum => NAME_LENGTH_LIMIT
validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT
validates_presence_of :author_id, :name, :deadline
validates_format_of :deadline, :with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/
validates_presence_of :author_id, :name, :budget
#validates_format_of :deadline, :with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/
validates_format_of :deadline, :with =>/^[1-9][0-9]{3}\-0?[1-9]|1[12]\-0?[1-9]|[12]\d|3[01]$/
# validates_format_of :budget, :with => /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/
validate :validate_user
after_create :act_as_activity

View File

@ -1163,8 +1163,11 @@ class Issue < ActiveRecord::Base
else
issue_index = 1
self.project.issues.each do |issue|
if self.id > issue.id
++issue_index
if self.id == nil
issue_index = self.project.issues.count +1
break
elsif self.id > issue.id
issue_index = issue_index+1
end
end
issue_index.to_s

View File

@ -29,7 +29,7 @@ class Journal < ActiveRecord::Base
# end
attr_accessor :indice
acts_as_event :title =>Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.inProjectIndex}#{status}: #{o.issue.subject}" },
acts_as_event :title =>Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.project_index}#{status}: #{o.issue.subject}" },
:description =>:notes,
:author => :user,
:group => :issue,

View File

@ -119,8 +119,9 @@ class Mailer < ActionMailer::Base
# Mailer.issue_edit(journal).deliver => sends an email to issue recipients
def issue_edit(journal)
issue = journal.journalized.reload
issue_id = issue.project_index
redmine_headers 'Project' => issue.project.identifier,
'Issue-Id' => (issue.project.issues.index(issue).to_i + 1).to_s,
'Issue-Id' => issue_id.to_s,
'Issue-Author' => issue.author.login
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
message_id journal
@ -129,7 +130,7 @@ class Mailer < ActionMailer::Base
recipients = journal.recipients
# Watchers in cc
cc = journal.watcher_recipients - recipients
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] "
s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
s << issue.subject
@issue = issue

View File

@ -209,10 +209,6 @@ class User < Principal
# ======================================================================
# 集中处理 User 扩展表为空的问题
# 合并 user_score 属性
validate :valid_user_extensions
after_save :save_user_extensions
def extensions
self.user_extensions ||= UserExtensions.new
@ -222,49 +218,6 @@ class User < Principal
self.user_score ||= UserScore.new
end
alias_method :ori_respond_to?, :respond_to?
def respond_to?(m, include_private = false)
flag = false
flag = ori_respond_to? m.to_sym unless flag
flag = UserExtensions.new.respond_to? m.to_sym unless flag
flag = UserScore.new.respond_to? m.to_sym unless flag
flag
end
def method_missing m, *args, &block
if extensions.respond_to? m.to_sym
self.class.send(:define_method, "_meta_#{m}".to_sym) do |*args, &block|
self.extensions.__send__ m.to_sym, *args
end
__send__ "_meta_#{m}".to_sym, *args, &block
elsif user_score_attr.respond_to? m.to_sym
self.class.send(:define_method, "_meta_#{m}".to_sym) do |*args, &block|
self.user_score_attr.__send__ m.to_sym, *args
end
__send__ "_meta_#{m}".to_sym, *args, &block
else
super
end
end
def valid_user_extensions
if !self.extensions.valid?
self.extensions.errors.messages.each do |key, values|
values.each do |value|
self.errors.add key, value
end
end
end
end
def save_user_extensions
self.extensions.save
self.user_score_attr.save
end
# 集中处理 User 扩展表为空的问题 < end
# ======================================================================
#选择项目成员时显示的用户信息文字

View File

@ -15,7 +15,7 @@
<div class="project-search" style="float: right">
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %>
</div>
</td>
</tr>

View File

@ -6,7 +6,7 @@
<%= form_tag(:controller => 'courses', :action => 'search', :method => :get) do %>
<table width="940px">
<tr>
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_practice) %></td>
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_all) %></td>
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
<td rowspan="2">
<% if User.current.logged?%>
@ -24,8 +24,8 @@
</td>
</tr>
<tr>
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index', :course_type => 1 %> </a></td>
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index', :course_type => 1 %></td>
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index' %> </a></td>
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_all), :controller => 'courses', :action => 'index' %></td>
</tr>
</table>
<% end %>

View File

@ -29,21 +29,23 @@
</div>
</div>
</div>
<div class="debug hidden">
<div class="debug">
<%= debug(params) if Rails.env.development? %>
<div class="hidden">
<script src="http://s4.cnzz.com/z_stat.php?id=1000482288&web_id=1000482288" language="JavaScript"></script>
<script>
<script src="http://s4.cnzz.com/z_stat.php?id=1000482288&web_id=1000482288" language="JavaScript"></script>
<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');
(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');
ga('create', 'UA-46523987-1', 'trustie.net');
ga('send', 'pageview');
</script>
</script>
</div>
</div>
<% end %>

View File

@ -41,10 +41,25 @@
<%=link_to_user(User.current)%>
<ul class="sub_menu">
<% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
<li><%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %></li>
<li id="course_loggedas_li"><%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %>
<ul class="course_sub_menu">
<% User.current.courses.each do |course| %>
<% if !course_endTime_timeout?(course) %>
<li><%= link_to course.name, course_path(course) %></li>
<% end %>
<% end %>
</ul>
</li>
<% end -%>
<li><%=link_to l(:label_my_projects),{:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %></li>
<li><%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%></li>
<li id="project_loggedas_li"><%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %>
<ul class="project_sub_menu">
<% User.current.projects.each do |project| %>
<li><%= link_to project.name, project_path(project) %></li>
<% end %>
</ul>
</li>
<li><%=link_to l(:label_user_edit), {:controller => 'my', :action=> 'account', host: Setting.user_domain}%>
</li>
</ul>
</li>
<li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;">
@ -77,11 +92,40 @@
});
}
function addProjectSlipMenu () {
var loggedas = $('#project_loggedas_li')
var project_sub_menu = $('.project_sub_menu')
var course_sub_menu = $('.course_sub_menu')
loggedas.mouseenter(function(event) {
course_sub_menu.hide();
project_sub_menu.show();
});
project_sub_menu.mouseleave(function(event) {
project_sub_menu.hide();
});
}
function addCourseSlipMenu () {
var loggedas = $('#course_loggedas_li')
var project_sub_menu = $('.project_sub_menu')
var course_sub_menu = $('.course_sub_menu')
loggedas.mouseenter(function(event) {
project_sub_menu.hide();
course_sub_menu.show();
});
course_sub_menu.mouseleave(function(event) {
course_sub_menu.hide();
});
}
$(document).ready(function () {
addSlipMenu();
addProjectSlipMenu ();
addCourseSlipMenu();
});
jQuery(document).ready(function($) {
$('.sub_menu').find("a").attr('target', '_blank');
$('.project_sub_menu').find("a").attr('target', '_blank');
$('.course_sub_menu').find("a").attr('target', '_blank');
});
</script>

View File

@ -1,4 +1,4 @@
<%= l(:text_issue_updated, :id => "##{@issue.id}", :author => h(@journal.user)) %>
<%= l(:text_issue_updated, :id => "##{@issue.project_index}", :author => h(@journal.user)) %>
<ul>
<% details_to_strings(@journal.details, false, :only_path => false).each do |string| %>

View File

@ -1,4 +1,4 @@
<%= l(:text_issue_updated, :id => "##{@issue.id}", :author => @journal.user) %>
<%= l(:text_issue_updated, :id => "##{@issue.project_index}", :author => @journal.user) %>
<% details_to_strings(@journal.details, true).each do |string| -%>
<%= string %>

View File

@ -3,10 +3,16 @@
<div class="box ph10_5">
<!--[form:message]-->
<p><label for="message_subject"><%= l(:field_subject) %><span class="required"> *&nbsp;&nbsp;</span></label><br />
<%= f.text_field :subject,:size => 60, :style => "width: 99%;", :id => "message_subject",:readonly=>true %><!--by young-->
</p>
<p>
<% unless replying %>
<p><label for="message_subject"><%= l(:field_subject) %><span class="required"> *&nbsp;&nbsp;</span></label><br/>
<%= f.text_field :subject, :size => 60, :style => "width: 99%;", :id => "message_subject" %><!--by young-->
</p>
<% else %>
<p><label for="message_subject"><%= l(:field_subject) %><span class="required"> *&nbsp;&nbsp;</span></label><br/>
<%= f.text_field :subject, :size => 60, :style => "width: 99%;", :id => "message_subject", :readonly => true %>
</p>
<% end %>
<p>
<% unless replying %>
<% if @message.safe_attribute? 'sticky' %>
<%= f.check_box :sticky %> <%= label_tag 'message_sticky', l(:label_board_sticky) %>

View File

@ -87,9 +87,11 @@
<ul class="d-p-projectlist">
<h1></h1>
<p id="errorExplanation">
该学校未开设任何课程,您可以查看其他学校课程
</p>
<% if User.current.logged? %>
<p id="errorExplanation">
该学校未开设任何课程,您可以查看其他学校课程
</p>
<% end %>
<h1></h1>
<% find_all_new_hot_course(9, @school_id).map do |course| %>

View File

@ -1448,7 +1448,7 @@ zh:
label_respond_requirement: 对需求进行了反馈
label_contest_requirement: 对竞赛进行了反馈
label_question_requirement: 对作业提出了问题!
label_deadline: 投资时限yyyy-mm-dd
label_deadline: 截止日期yyyy-mm-dd
label_requirement_name: 在此输入需求名称
label_contest_name: 在此输入竞赛名称
label_requirement_description: 内容:对你的需求进行描述

View File

@ -2158,8 +2158,66 @@ ul.messages-for-user-reply li {
#loggedas .sub_menu a{
margin: 0px;
}
.sub_menu li{
width: 90%;
width: 90%;
}
#project_loggedas_li .project_sub_menu {
box-shadow: 2px 2px 6px #b0b0b0 ;
display: none;
background: #13AEBF 0 0 no-repeat;
left: 115px;
padding-bottom: 5px;
position: absolute;
top: 40px;
font-size: 1.1em;
margin: 0px auto;
padding: 0px 0px;
text-align: left;
z-index: 1;
}
#project_loggedas_li .project_sub_menu a{
margin: 0px;
}
#project_loggedas_li li {
border-bottom: 1px solid #129DAD;
color: white;
list-style: none ;
padding: 6px 0px;
margin-left: 5%;
font-size: 0.8em;
width: 90%;
line-height: 15px;
}
#course_loggedas_li .course_sub_menu {
box-shadow: 2px 2px 6px #b0b0b0 ;
display: none;
background: #13AEBF 0 0 no-repeat;
left: 115px;
padding-bottom: 5px;
position: absolute;
top: 0px;
font-size: 1.1em;
margin: 0px auto;
padding: 0px 0px;
text-align: left;
z-index: 1;
}
#course_loggedas_li .course_sub_menu a{
margin: 0px;
}
#course_loggedas_li li {
border-bottom: 1px solid #129DAD;
color: white;
list-style: none ;
padding: 6px 0px;
margin-left: 5%;
font-size: 0.8em;
width: 90%;
line-height: 15px;
}
/*gcm*/