This commit is contained in:
linhk 2014-08-16 17:02:58 +08:00
commit ecae8d1f35
20 changed files with 160 additions and 58 deletions

View File

@ -81,3 +81,10 @@ kw:
默认支持如下格式:"bmp,jpeg,jpg,png,gif"
可在configuration.yml中修改格式pic_types: "bmp,jpeg,jpg,png,gif"(注意pic_types若前面有#号需去掉)
配置完成后重启服务
=================================[2014-08-16]====================================
kw:数据迁移project_scores表已存在
bundle exec rake db:migrate:down VERSION=20140811022947
bundle exec rake db:migrate:up VERSION=20140811022947
bundle exec rake db:migrate
bundle exec rake project_score:calculate

View File

@ -279,7 +279,7 @@ class ApplicationController < ActionController::Base
# Find project of id params[:id]
def find_project
@project = Project.find(params[:id])
@project = Project.find_by_id(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
@ -725,6 +725,12 @@ class ApplicationController < ActionController::Base
#查找首页相关信息
def find_first_page
@first_page = FirstPage.where("page_type = 'project'").first
if @first_page.nil?
@first_page = FirstPage.new
@first_page.page_type = 'project'
@first_page.description = ""
@first_page.save()
end
@show_course = @first_page.show_course
@show_contest = @first_page.show_contest
end

View File

@ -17,7 +17,7 @@
class TrackersController < ApplicationController
layout 'admin'
helper "project_score"
before_filter :require_admin, :except => :index
before_filter :require_admin_or_api_request, :only => :index
accept_api_auth :index
@ -38,6 +38,7 @@ class TrackersController < ApplicationController
@tracker ||= Tracker.new(params[:tracker])
@trackers = Tracker.sorted.all
@projects = Project.all
@courses = Course.all
end
def create

View File

@ -295,8 +295,8 @@ class UsersController < ApplicationController
# 活跃度排序, 就是所谓的得分情况
@s_type = 1
@users = scope.
joins("LEFT JOIN user_scores ON users.id = user_scores.user_id").
reorder('user_scores.active DESC')
joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1").
reorder('option_numbers.total_score DESC')
when '2'
# 粉丝数排序
@s_type = 2
@ -308,8 +308,8 @@ class UsersController < ApplicationController
# 默认活跃度排序
@s_type = 1
@users = scope.
joins("LEFT JOIN user_scores ON users.id = user_scores.user_id").
reorder('user_scores.active DESC')
joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1").
reorder('option_numbers.total_score DESC')
end
# limit and offset

View File

@ -20,11 +20,12 @@ class WelcomeController < ApplicationController
include WelcomeHelper
helper :project_score
caches_action :robots
before_filter :find_first_page, :only => [:index]
# before_filter :fake, :only => [:index, :course]
before_filter :entry_select, :only => [:index]
def index
@first_page = FirstPage.where("page_type = 'project'").first
#@first_page = FirstPage.where("page_type = 'project'").first
#@show_course = @first_page.show_course
if @first_page.nil? || @first_page.sort_type.nil?
@projects = find_miracle_project(10, 3,"score desc")
@ -76,7 +77,7 @@ class WelcomeController < ApplicationController
logo = get_avatar?(@course_page)
id = params[:school_id]
logo_link = ""
if id.nil? && User.current.user_extensions.school.nil?
if id.nil? && (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?)
if logo
logo_link = url_to_avatar(@course_page)
else
@ -148,8 +149,8 @@ class WelcomeController < ApplicationController
private
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
def entry_select
@first_page = FirstPage.where("page_type = 'project'").first
url = request.original_url
#@first_page = FirstPage.where("page_type = 'project'").first
url = request.original_url.gsub('/','')
if url.include?(Setting.host_course)
if @first_page.show_course == 1
course

View File

@ -54,7 +54,7 @@ class ZipdownController < ApplicationController
end
rescue => e
render file: 'public/file_not_found.html'
render file: 'public/file_not_found.html' , :layout => 'course_base'
end
private

View File

@ -16,7 +16,7 @@ module ProjectScoreHelper
end
#文档数量
def document_num project
def documents_num project
project.documents.count
end
@ -48,8 +48,8 @@ module ProjectScoreHelper
end
#文档得分
def document_score project
d_num = document_num project
def documents_score project
d_num = documents_num(project)
d_num * 4
end
@ -67,7 +67,7 @@ module ProjectScoreHelper
#计算项目得分
def project_scores project
result = (issue_score project) + (news_score project) + (document_score project) + (changesets_score project) + (board_message_score project)
result = (issue_score project) + (news_score project) + (documents_score project) + (changesets_score project) + (board_message_score project)
pss = ProjectScore.where("project_id = '#{project.id}'")
if pss.nil? || pss.count == 0
ps = ProjectScore.new

View File

@ -384,6 +384,9 @@ module UserScoreHelper
#更新分数
def update_score(option_number)
option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + active(option_number)
if option_number.total_score < 0
option_number.total_score = 0
end
option_number.save
option_number.total_score
end

View File

@ -13,16 +13,17 @@
<% end %>
</span>
<script type='text/javascript'>
function CompatibleSend()
{
var obj=document.getElementById("_file");
var file= $(obj).clone();
file.click();
}
// function CompatibleSend()
// {
// var obj=document.getElementById("_file");
// var file= $(obj).clone();
// file.click();
// }
</script>
<span class="add_attachment">
<%= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
<!--%= link_to image_tag(),"javascript:void(0)", :onclick => "_file.click()"%-->
<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()" %>
<%= file_field_tag 'attachments[dummy][file]',
:id => '_file',
:class => 'file_selector',

View File

@ -1,12 +1,98 @@
<%#= error_messages_for 'softapplication' %>
<script type="text/javascript">
//验证作品名称
function regexName()
{
var name = $("#softapplication_name").val();
if(name.length ==0)
{
$("#spane_name_notice").text("作品名称不能为空");
$("#spane_name_notice").css('color','#ff0000');
$("#spane_name_notice").focus();
return false;
}
else if(name.length < 25)
{
$("#spane_name_notice").text("填写正确");
$("#spane_name_notice").css('color','#008000');
return true;
}
else
{
$("#spane_name_notice").text("作品名称超过25个汉字");
$("#spane_name_notice").css('color','#ff0000');
$("#spane_name_notice").focus();
return false;
}
}
//验证运行平台
function regexWorkdescription()
{
var workDescription = $("#softapplication_android_min_version_available").val();
if(workDescription.length ==0)
{
$("#spane_workdescription_notice").text("运行平台不能为空");
$("#spane_workdescription_notice").css('color','#ff0000');
return false;
}
if(workDescription.length < 125)
{
$("#spane_workdescription_notice").text("填写正确");
$("#spane_workdescription_notice").css('color','#008000');
return true;
}
else
{
$("#spane_workdescription_notice").text("运行平台超过125个汉字");
$("#spane_workdescription_notice").css('color','#ff0000');
return false;
}
}
//验证开发人员
function regexDevelopers()
{
var workDescription = $("#softapplication_application_developers").val();
if(workDescription.length ==0)
{
$("#span_softapplication_application_developers").text("开发人员不能为空");
$("#span_softapplication_application_developers").css('color','#ff0000');
return false;
}
if(workDescription.length < 125)
{
$("#span_softapplication_application_developers").text("填写正确");
$("#span_softapplication_application_developers").css('color','#008000');
return true;
}
else
{
$("#span_softapplication_application_developers").text("开发人员超过125个汉字");
$("#span_softapplication_application_developers").css('color','#ff0000');
return false;
}
}
//提交验证
function submit_new_softapplication()
{
if(regexName() && regexWorkdescription() && regexDevelopers())
{
alert("123123123123");
$("#new_softapplication").submit();
}
}
</script>
<%= form_for Softapplication.new, :url => softapplications_path do |f| %>
<fieldset class="contes-new-box" style="padding-left: 36px; line-height: 8px; margin-left: 1px" >
<%= hidden_field_tag 'contest_id', @contest.id %>
<tr style="width:700px; margin-left: -10px;">
<span><%= l(:label_work_name) %></span>
<span class="contest-star"> * </span>:
<td><%= f.text_field :name, :required => true, :size => 60, :style => "width:350px;" %></td>
<span style="font-size: 10px">(<%= l(:label_workname_lengthlimit) %>)</span>
<td><%= f.text_field :name, :required => true, :size => 60, :style => "width:320px;", :onblur => "regexName();" %></td>
<span style="font-size: 10px;" id="spane_name_notice">(<%= l(:label_workname_lengthlimit) %>)</span>
</tr>
<br/>
<br/>
@ -16,9 +102,9 @@
<span><%= l(:label_running_platform) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px">
<%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:350px;" %>
<%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:320px;", :onblur=>"regexWorkdescription();"%>
</td>
<span style="font-size: 10px">(<%= l(:label_workdescription_lengthlimit) %>)</span>
<span style="font-size: 10px" id="spane_workdescription_notice">(<%= l(:label_workdescription_lengthlimit) %>)</span>
</tr>
<br/>
<br/>
@ -31,12 +117,12 @@
<span>
<%#= select_tag 'app_type_name', work_type_opttion, {:name => 'app_type_name',:style => "width:358px;"} %>
</span>
<%= f.select :app_type_name,work_type_opttion, {},{:style => "width:358px;",:onchange => "selectChange(this)"} %>
<%= f.select :app_type_name,work_type_opttion, {},{:style => "width:328px;",:onchange => "selectChange(this)"} %>
<%#= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %>
</td>
<span style="font-size: 10px;display: none" id="other_span">
<%#= f.text_field :other_input, :required => true, :size => 60, :style => "width:100px;" %>
<input type="text" style="width: 100px;" id="other_input" name = "other_input"/>
<input type="text" style="width: 120px;" id="other_input" name = "other_input"/>
</span>
</tr>
<br/>
@ -46,7 +132,7 @@
<tr style="width:800px;">
<span><%= l(:label_work_description) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:350px;" %></td>
<td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:320px;" %></td>
<!--span style="font-size: 10px">(<%#= l(:label_workdescription_lengthlimit) %>)</span-->
</tr>
<br/>
@ -56,8 +142,8 @@
<tr style="width:800px;">
<span><%= l(:label_softapplication_developers) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px"><%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:350px;" %></td>
<span style="font-size: 10px">(<%= l(:label_workdescription_lengthlimit) %>)</span>
<td style="width: 100px"><%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:320px;", :onblur => 'regexDevelopers();' %></td>
<span style="font-size: 10px" id="span_softapplication_application_developers">(<%= l(:label_workdescription_lengthlimit) %>)</span>
</tr>
<br/>
<br/>
@ -65,7 +151,7 @@
<tr style="width:800px;">
<span><%= l(:label_work_deposit_project) %></span>
<span style="padding-left: 4px"><%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:358px;" %></span>
<span style="padding-left: 4px"><%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:328px;" %></span>
<span><%= link_to l(:label_create_new_projects),{:controller => 'projects',:action => 'new',course: 0, project_type: 0,host: Setting.project_domain}, :target => '_blank' %></span><!-- new_project_path(course: 0, project_type: 0) -->
</tr>
<br/>
@ -90,7 +176,8 @@
</fieldset>
</fieldset></br>
<div class="align-center" style="padding-top: -3px; padding-bottom: 8px">
<%= submit_tag l(:button_create) %>
<input type="button" class="enterprise" value="<%=l(:button_create) %>" onclick="submit_new_softapplication();" >
<%#= submit_tag l(:button_create) %>
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();",
:type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'",
:onmouseover => "this.style.backgroundPosition = 'left -30px'" %>

View File

@ -44,11 +44,11 @@
<% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
<% hasCourse=true%>
<li id="course_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %>
<li id="course_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id} %>
<ul class="course_sub_menu">
<% User.current.courses.each do |course| %>
<% if !course_endTime_timeout?(course) %>
<li><%= link_to course.name.truncate(10, omission: '...'), {:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %></li>
<li><%= link_to course.name.truncate(10, omission: '...'), {:controller => 'courses',:action => 'show',id:course.id} %></li>
<% end %>
<% end %>
</ul>

View File

@ -66,7 +66,7 @@
<% if @project.project_type == 0 %>
<%= l(:label_project_grade)%> :
<%= link_to(format("%.2f" , project_scores(@project) ).to_i, {:controller => 'projects',
<%= link_to(format("%.2f" ,project_scores(@project) ).to_i, {:controller => 'projects',
:action => 'show_projects_score',
:remote => true,
:id => @project.id

View File

@ -4,22 +4,22 @@
<div class="tools ">
<ul><h3>项目交流</h3>
<li><%= link_to l(:label_project_tool_response) ,project_feedback_path(@project) %></li>
<li><%= link_to l(:project_module_files) ,project_files_path(@project) %></li>
<li style="background: url('http://<%= Setting.host_name %>/images/sidebar/tool_tag_alpha.png') no-repeat scroll 10px 30% transparent;"><%= link_to l(:label_project_tool_response) ,project_feedback_path(@project)%></li>
<li style="background: url('http://<%= Setting.host_name %>/images/sidebar/tool_tag_alpha.png') no-repeat scroll 10px 30% transparent;"><%= link_to l(:project_module_files) ,project_files_path(@project) %></li>
<% if @project.enabled_modules.where("name = 'wiki'").count > 0 %>
<li><%= link_to l(:project_module_wiki), project_wiki_path(@project) %></li>
<% end %>
</ul>
<ul><h3>进度跟踪</h3>
<li><%= link_to l(:project_module_calendar),project_calendar_path(@project) %></li>
<li><%= link_to l(:label_roadmap) ,project_roadmap_path(@project) %></li>
<li><%= link_to l(:project_module_gantt) ,project_gantt_path(@project) %></li>
<li style="background: url('http://<%= Setting.host_name %>/images/sidebar/tool_tag_alpha.png') no-repeat scroll 10px 30% transparent;"><%= link_to l(:project_module_calendar),project_calendar_path(@project) %></li>
<li style="background: url('http://<%= Setting.host_name %>/images/sidebar/tool_tag_alpha.png') no-repeat scroll 10px 30% transparent;"><%= link_to l(:label_roadmap) ,project_roadmap_path(@project) %></li>
<li style="background: url('http://<%= Setting.host_name %>/images/sidebar/tool_tag_alpha.png') no-repeat scroll 10px 30% transparent;"><%= link_to l(:project_module_gantt) ,project_gantt_path(@project) %></li>
</ul>
<ul><h3>其他工具</h3>
<% if @project.enabled_modules.where(" name = 'dts'").count > 0 %>
<li><%= link_to l(:label_module_share) ,share_show_path(@project) %></li>
<% end %>
<li><%= link_to l(:project_module_documents), project_documents_path(@project) %></li>
<li style="background: url('http://<%= Setting.host_name %>/images/sidebar/tool_tag_alpha.png') no-repeat scroll 10px 30% transparent;"><%= link_to l(:project_module_documents), project_documents_path(@project) %></li>
<li></li>
</ul>

View File

@ -25,13 +25,9 @@
</span>
<%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %>
<div class="activity_description info-break" style="font-size: 13px;">
<div class="issue-list-description">
<div class="wiki">
<%#= textilizable e.event_url,:description %>
</div>
</div>
<%= h(truncate(strip_tags(e.event_description).gsub(/&nbsp;/, ' '), length: 30, omission: '...')) %>
<div class="activity_description info-break" style="font-size: 13px;width: 100%;word-break: break-all;">
<%= textAreailizable e,:event_description %>
<%#= h(truncate(strip_tags(e.event_description).gsub(/&nbsp;/, ' '), length: 30, omission: '...')) %>
</div>
<div class="activity_status" style="position:relative; padding-top: 3px;">
<span class="font_lighter"> <%= l :label_activity_time %>

View File

@ -153,7 +153,7 @@
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" >
<h3 style="margin-left: 5px; color: #e8770d;"><strong><%=l(:label_current_hot_contest)%></strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to l(:label_more_information), {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %></span>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to l(:label_more_information), {:controller => 'contests', :action => 'index'}, :target => "_blank" %></span>
<div class="d-p-projectlist-box">
<div class="d-p-projectlist">
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
@ -294,7 +294,7 @@
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: left;">
<h3 style="margin-left: 5px; color: #e8770d;"><strong><%=l(:label_current_attendingcontest_work)%></strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to l(:label_more_information), {:controller => 'softapplications', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %></span>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to l(:label_more_information), {:controller => 'softapplications', :action => 'index'}, :target => "_blank" %></span>
<div class="d-p-projectlist-box">
<% if Softapplication.count > 0%>
<div class="d-p-projectlist">

View File

@ -42,7 +42,7 @@
</div>
<div class="course welcome_left" id="welcome_left">
<span class="font_welcome_school"> <% if @school_id.nil? and User.current.user_extensions.school.nil? %>
<span class="font_welcome_school"> <% if @school_id.nil? and (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) %>
<% else %>
<% if @school_id == "0" %>
<% else %>
@ -58,7 +58,7 @@
<% unless @course_page.nil? %>
<span class="font_welcome_trustie"><%= @course_page.title %> </span>
<% if @school_id.nil? and User.current.user_extensions.school.nil? %>
<% if @school_id.nil? and (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) %>
<span class="font_welcome_tdescription">, <%= @course_page.description %></span>
<% else %>
<% if @school_id == "0" %>

View File

@ -79,7 +79,7 @@
<span class='font_lighter' title ='<%=project.short_description%>'><%=project.description.truncate(100, omission: '...')%></span>
</div>
<div >
<%= content_tag "span", l(:label_project_score)+ ":" + project_scores(project).to_s,
<%= content_tag "span", l(:label_project_score)+ ":" + red_project_scores(project).to_i.to_s,
:style => "cursor: pointer; display: inline-block; float: right; color: #ec6300;",
:title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度",
:class => "tooltip",

View File

@ -441,10 +441,10 @@ ActiveRecord::Schema.define(:version => 20140814062455) do
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "sort_type"
t.integer "show_course", :default => 1
t.integer "show_contest", :default => 1
t.integer "image_width", :default => 107
t.integer "image_height", :default => 63
t.integer "show_course", :default => 1
t.integer "show_contest", :default => 1
end
create_table "forums", :force => true do |t|

View File

@ -408,7 +408,7 @@ Redmine::MenuManager.map :course_menu do |menu|
end
Redmine::MenuManager.map :user_menu do |menu|
menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain }
menu.push :user_course, {:controller => 'users', :action => 'user_courses', :host => Setting.course_domain}
menu.push :user_course, {:controller => 'users', :action => 'user_courses'}
#menu.push :user_homework, {:controller => 'users', :action => 'user_homeworks'} by huang
menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain}
# menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} by huang

View File

@ -656,7 +656,7 @@ input[class='nyan-clean-gray']:active, .nyan-clean-gray:active {
}
.tools li {
background: url("/images/sidebar/tool_tag_alpha.png") 10px 30% no-repeat transparent;
/*background: url("/images/sidebar/tool_tag_alpha.png") 10px 30% no-repeat transparent;*/
color: #3e3e3e;
font-weight: 400;
line-height: 1.5em;