This commit is contained in:
yanxd 2014-07-07 16:53:00 +08:00
commit ab03962e9a
28 changed files with 3828 additions and 51 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

@ -99,7 +99,8 @@ class CoursesController < ApplicationController
# add by nwb
def search
courses_all = Course.all_course
name = params[:name]
(redirect_to courses_path, :notice => l(:label_sumbit_empty);return) if name.blank?
@courses = courses_all.visible
if params[:name].present?
@courses_all = @courses.like(params[:name])

View File

@ -166,6 +166,8 @@ class ForumsController < ApplicationController
def search_forum
# @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'")
name = params[:name]
(redirect_to forums_path, :notice => l(:label_sumbit_empty);return) if name.blank?
@offset, @limit = api_offset_and_limit({:limit => 10})
@forums_all = Forum.where("name LIKE '%#{params[:name]}%'")
@forums_count = @forums_all.count

View File

@ -373,7 +373,7 @@ class UsersController < ApplicationController
def search
sort_init 'login', 'asc'
sort_update %w(login firstname lastname mail admin created_on last_login_on)
(redirect_to users_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
case params[:format]
when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 15})

View File

@ -88,7 +88,8 @@ class WelcomeController < ApplicationController
when :users_student
redirect_to users_search_path(:name => search_condition, :role => :student)
else
redirect_to home_path, :alert => l(:label_sumbit_empty)
#redirect_to home_path, :alert => l(:label_sumbit_empty)
(redirect_to home_path, :notice => l(:label_sumbit_empty);return) #if params[:name].blank?
end
}
end

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

@ -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

@ -9,7 +9,7 @@ class Forum < ActiveRecord::Base
'memo_count',
'last_memo_id',
'creator_id'
validates_presence_of :name, :creator_id
validates_presence_of :name, :creator_id, :description
validates_length_of :name, maximum: 50
validates_length_of :description, maximum: 255
validates :name, :uniqueness => true

View File

@ -990,13 +990,9 @@ class Issue < ActiveRecord::Base
end
def to_s
"#{tracker} ##{id}: #{subject}"
"#{tracker} ##{project_index}: #{subject}"
end
# 缺陷在项目中的序号
def inProjectIndex
(self.project.issues.index(self).to_i + 1).to_s
end
# Returns a string of css classes that apply to the issue
def css_classes
@ -1162,7 +1158,20 @@ class Issue < ActiveRecord::Base
end
def project_index
(self.project.issues.index(self).to_i + 1).to_s
if self.project.issues.include?(self)
(self.project.issues.index(self).to_i + 1).to_s
else
issue_index = 1
self.project.issues.each do |issue|
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
end
end
private

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

@ -96,8 +96,9 @@ class Mailer < ActionMailer::Base
# issue_add(issue) => Mail::Message object
# Mailer.issue_add(issue).deliver => sends an email to issue recipients
def issue_add(issue)
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,
'Issue-Author' => issue.author.login
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
message_id issue
@ -108,7 +109,7 @@ class Mailer < ActionMailer::Base
cc = issue.watcher_recipients - recipients
mail :to => recipients,
:cc => cc,
:subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
:subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}"
end
# Builds a Mail::Message object used to email recipients of the edited issue.
@ -118,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
@ -128,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

@ -41,7 +41,7 @@ class Project < ActiveRecord::Base
has_many :principals, :through => :member_principals, :source => :principal
has_many :enabled_modules, :dependent => :delete_all
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
has_many :issues, :dependent => :destroy, :include => [:status, :tracker]
has_many :issues, :dependent => :destroy, :include => [:status, :tracker] , :order => "id ASC"
has_many :issue_changes, :through => :issues, :source => :journals
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
has_many :time_entries, :dependent => :delete_all

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

@ -84,7 +84,7 @@
<strong> !</strong></td>
</tr>
<tr>
<td class="font_lighter" style="float: right"><%= l :label_update_time %>
<td class="font_lighter" style="float: right"><%= l :label_create_time %>
: <%= format_time(@course.created_at) %>
</table>
</td>

View File

@ -3,17 +3,17 @@
<h3><%=l(:label_memo_new)%></h3>
<% if User.current.logged? %>
<%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %>
<% if @memo.errors.any? %>
<!--<#% if @memo.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2>
<h2><#%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2>
<ul>
<% @memo.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
<#% @memo.errors.full_messages.each do |msg| %>
<li><#%= msg %></li>
<#% end %>
</ul>
</div>
<% end %>
<#% end %> -->
<div class="actions" style="max-width:680px">
<p><%= f.text_field :subject, :required => true%></p>
<p style="max-width:680px"><%= f.text_area :content, :required => true, :id => 'editor02' %></p>

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 @@
<h1><%= link_to(h("#{issue.tracker.name} ##{issue.id}: #{issue.subject}"), issue_url) %></h1>
<h1><%= link_to(h("#{issue.tracker.name} ##{issue.project_index}: #{issue.subject}"), issue_url) %></h1>
<ul>
<li><%=l(:field_author)%>: <%=h issue.author %></li>

View File

@ -1,4 +1,4 @@
<%= "#{issue.tracker.name} ##{issue.id}: #{issue.subject}" %>
<%= "#{issue.tracker.name} ##{issue.project_index}: #{issue.subject}" %>
<%= issue_url %>
* <%=l(:field_author)%>: <%= issue.author %>

View File

@ -1,3 +1,3 @@
<%= l(:text_issue_added, :id => "##{@issue.id}", :author => h(@issue.author)) %>
<%= l(:text_issue_added, :id => "##{@issue.project_index}", :author => h(@issue.author)) %>
<hr />
<%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %>

View File

@ -1,4 +1,4 @@
<%= l(:text_issue_added, :id => "##{@issue.id}", :author => @issue.author) %>
<%= l(:text_issue_added, :id => "##{@issue.project_index}", :author => @issue.author) %>
----------------------------------------
<%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %>

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: 内容:对你的需求进行描述

File diff suppressed because one or more lines are too long

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*/