Merge branch 'develop'

This commit is contained in:
kg 2014-05-01 09:22:24 +08:00
commit 881c91fafd
23 changed files with 742 additions and 408 deletions

View File

@ -138,6 +138,17 @@ class ProjectsController < ApplicationController
@project_count = @projects_all.count
@project_pages = Paginator.new @project_count, per_page_option, params['page']
#gcm activity count
@project_activity_count=Hash.new
@projects_all.each do |project|
@project_activity_count[project.id]=0
end
@project_activity_count=get_project_activity @projects_all,@project_activity_count
#gcm end
case params[:project_sort_type]
when '0'
@ -149,6 +160,14 @@ class ProjectsController < ApplicationController
when '2'
@projects = @projects_all.order("watchers_count desc")
@s_type = 2
#gcm
when '3'
#@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array)
@projects=handle_project @projects_all,@project_activity_count
@s_type = 3
@projects = @projects[@project_pages.offset, @project_pages.per_page]
else
@projects = @projects = @projects_all.order("grade desc")
@s_type = 1
@ -193,122 +212,16 @@ class ProjectsController < ApplicationController
@project_count = @projects_all.count
@project_pages = Paginator.new @project_count, per_page_option, params['page']
#gcm activity count
#gcm activity count
@project_activity_count=Hash.new
#count initialize
@projects_all.each do |project|
@project_activity_count[project.id]=0
end
@project_ids=@project_activity_count.keys()
days = Setting.activity_days_default.to_i
date_to ||= Date.today + 1
date_from = date_to - days-1.years
#approach 1
=begin
@projects_all.each do |project|
#issue_count
issues=Issue.where("project_id=?",project.id)
issue_count=0
issues.each do |issue|
issue_count+=issue.journals.count
end
#repository_count
repositories=Repository.where("project_id=?",project.id)
repository_count=0
repositories.each do |repository|
repository_count+=repository.changesets.count
end
#news_count
news_count=News.where("project_id=?",project.id).count
#document_count
document_count=Document.where("project_id=?",project.id).count
#file_count
file_count=Attachment.where("container_type='Project' AND container_id=?",project.id).count
#message_count
boards=Board.where("project_id=?",project.id)
message_count=0
boards.each do |board|
message_count+=board.messages.count
end
#time_entry_count
time_entry_count=TimeEntry.where("project_id=?",project.id).count
#sum
@project_activity_count[project.id.to_s]=issue_count+repository_count+news_count+document_count+file_count+message_count+time_entry_count
end
=end
#gcm
#gcm approach 2
#issue_count
Issue.where(project_id: @project_ids).where("updated_on>?",date_from).each do |issue|
# @project_activity_count[issue.project_id.to_s]+=1
@project_activity_count[issue.project_id]+=issue.journals.where("created_on>?",date_from).count
end
#repository_count
Repository.where(project_id: @project_ids).each do |repository|
# @project_activity_count[repository.project_id.to_s]+=1
@project_activity_count[repository.project_id]+=repository.changesets.where("committed_on>?",date_from).count
end
#news_count
News.where(project_id: @project_ids).where("created_on>?",date_from).each do |news|
@project_activity_count[news.project_id]+=1
end
#document_count
Document.where(project_id: @project_ids).where("created_on>?",date_from).each do |document|
@project_activity_count[document.project_id]+=1
end
#file_count
Attachment.where(container_id: @project_ids).where("container_type='Project' AND created_on>?",date_from).each do |attachment|
@project_activity_count[attachment.container_id]+=1
end
#message_count
Board.where(project_id: @project_ids).each do |board|
# @project_activity_count[board.project_id]+=1
@project_activity_count[board.project_id]+=board.messages.where("updated_on>?",date_from).count
end
#time_entry_count
TimeEntry.where(project_id: @project_ids).where("updated_on>?",date_from).each do |timeentry|
@project_activity_count[timeentry.project_id]+=1
end
#feedbackc_count
JournalsForMessage.where(jour_id: @project_ids).each do |jourformess|
@project_activity_count[jourformess.jour_id]+=1
end
#@project_activity_count!=0
@project_all_array=[]
i=0;
@projects_all.each do |project|
id=project.id
@project_all_array[i]=project
if @project_activity_count[id]==0
@project_activity_count[id]=1
end
i=i+1
end
@project_activity_count_array=@project_activity_count.values()
#gcm end
#@project_activity_count=get_project_activity @projects_all,@project_activity_count
#gcm end
case params[:project_sort_type]
@ -316,26 +229,48 @@ class ProjectsController < ApplicationController
@projects = @projects_all.order("created_on desc")
@s_type = 0
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
#gcm
@project_activity_count=get_project_activity @projects,@project_activity_count
#gcmend
when '1'
@projects = @projects_all.order("course_ac_para desc")
@s_type = 1
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
#gcm
@project_activity_count=get_project_activity @projects,@project_activity_count
#gcmend
when '2'
@projects = @projects_all.order("watchers_count desc")
@s_type = 2
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
#gcm
@project_activity_count=get_project_activity @projects,@project_activity_count
#gcmend
#gcm
when '3'
@projects=desc_sort_course_by_avtivity(@project_ids,@project_activity_count_array,@project_all_array)
#gcm
@project_activity_count=get_project_activity @projects_all,@project_activity_count
#gcmend
@projects=handle_project @projects_all,@project_activity_count
@s_type = 3
@projects = @projects[@project_pages.offset, @project_pages.per_page]
#gcmend
else
@s_type = 0
@projects = @projects_all.order("created_on desc")
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
#gcm
@project_activity_count=get_project_activity @projects,@project_activity_count
#gcmend
end
respond_to do |format|
@ -354,17 +289,76 @@ class ProjectsController < ApplicationController
end
end
#gcm
def search
#modified by nie
project_type = params[:project_type].to_i
projects_all = (project_type.eql? Project::ProjectType_course) ? Project.course_entities : Project.project_entities
@projects = projects_all.visible
@projects = @projects.visible.like(params[:name]) if params[:name].present?
@offset, @limit = api_offset_and_limit({:limit => 10})
@project_count = @projects.visible.count
@project_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @project_pages.offset
@projects = @projects.visible.offset(@offset).limit(@limit).all
@projects_all = @projects.visible.like(params[:name]) if params[:name].present?
@project_count = @projects_all.count
@project_pages = Paginator.new @project_count, per_page_option, params['page']
#gcm activity count
@project_activity_count=Hash.new
# count initialize
@projects_all.each do |project|
@project_activity_count[project.id]=0
end
#@project_activity_count=get_project_activity @projects_all,@project_activity_count
#gcm end
case params[:project_sort_type]
when '0'
@projects = @projects_all.order("created_on desc")
@s_type = 0
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
#gcm
@project_activity_count=get_project_activity @projects,@project_activity_count
#gcmend
when '1'
@projects = @projects_all.order("course_ac_para desc")
@s_type = 1
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
#gcm
@project_activity_count=get_project_activity @projects,@project_activity_count
#gcmend
when '2'
@projects = @projects_all.order("watchers_count desc")
@s_type = 2
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
#gcm
@project_activity_count=get_project_activity @projects,@project_activity_count
#gcmend
when '3'
#@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array)
@project_activity_count=get_project_activity @projects_all,@project_activity_count_array #gcm
@projects=handle_project @projects_all,@project_activity_count
@s_type = 3
@projects = @projects[@project_pages.offset, @project_pages.per_page]
else
@s_type = 0
@projects = @projects_all.order("created_on desc")
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
#gcm
@project_activity_count=get_project_activity @projects,@project_activity_count
#gcmend
end
respond_to do |format|
format.html {
render :layout => 'base'
@ -384,6 +378,38 @@ class ProjectsController < ApplicationController
}
end
end
#gcmend
# def search
# #modified by nie
# project_type = params[:project_type].to_i
# projects_all = (project_type.eql? Project::ProjectType_course) ? Project.course_entities : Project.project_entities
# @projects = projects_all.visible
# @projects = @projects.visible.like(params[:name]) if params[:name].present?
# @offset, @limit = api_offset_and_limit({:limit => 10})
# @project_count = @projects.visible.count
# @project_pages = Paginator.new @project_count, @limit, params['page']
# @offset ||= @project_pages.offset
# @projects = @projects.visible.offset(@offset).limit(@limit).all
# respond_to do |format|
# format.html {
# render :layout => 'base'
# scope = Project
# unless params[:closed]
# scope = scope.active
# end
# }
# format.api {
# # @offset, @limit = api_offset_and_limit
# # @project_count = Project.visible.count
# # @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
# }
# format.atom {
# projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
# render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
# }
# end
# end
# added by fq
def new_join
@ -1018,7 +1044,93 @@ class ProjectsController < ApplicationController
end
end
def desc_sort_course_by_avtivity(ids,activity_count,projects)
#gcm
def get_project_activity projects,activities
@project_ids=activities.keys()
days = Setting.activity_days_default.to_i
date_to ||= Date.today + 1
date_from = date_to - days-1.years
#issue_count
Issue.where(project_id: @project_ids).where("updated_on>?",date_from).each do |issue|
# activities[issue.project_id.to_s]+=1
activities[issue.project_id]+=issue.journals.where("created_on>?",date_from).count
end
#repository_count
Repository.where(project_id: @project_ids).each do |repository|
# activities[repository.project_id.to_s]+=1
activities[repository.project_id]+=repository.changesets.where("committed_on>?",date_from).count
end
#news_count
News.where(project_id: @project_ids).where("created_on>?",date_from).each do |news|
activities[news.project_id]+=1
end
#document_count
Document.where(project_id: @project_ids).where("created_on>?",date_from).each do |document|
activities[document.project_id]+=1
end
#file_count
Attachment.where(container_id: @project_ids, container_type: Project).where("created_on>?",date_from).each do |attachment|
activities[attachment.container_id]+=1
end
#message_count
Board.where(project_id: @project_ids).each do |board|
# activities[board.project_id]+=1
activities[board.project_id]+=board.messages.where("updated_on>?",date_from).count
end
#time_entry_count
TimeEntry.where(project_id: @project_ids).where("updated_on>?",date_from).each do |timeentry|
activities[timeentry.project_id]+=1
end
#feedbackc_count
JournalsForMessage.where(jour_id: @project_ids, jour_type: Project).each do |jourformess|
activities[jourformess.jour_id]+=1
end
#activities!=0
i=0;
projects.each do |project|
id=project.id
if activities[id]==0
activities[id]=1
end
end
return activities
end
#gcmend
#gcm
def handle_project projects,activities
project_activity_count_array=activities.values()
project_array=[]
i=0;
projects.each do |project|
project_array[i]=project
i=i+1
end
projects=desc_sort_course_by_avtivity(project_activity_count_array,project_array)
return projects
end
#gcmend
#gcm
def desc_sort_course_by_avtivity(activity_count,projects)
return projects if activity_count.size<2
(activity_count.size-2).downto(0) do |i|
(0..i).each do |j|
@ -1029,20 +1141,7 @@ class ProjectsController < ApplicationController
end
end
return projects
# len=activity_count.length
# for i in 0...(len-1) do
# for j in 0...(len-i-1) do
# if activity_count[j]>activity_count[j+1] do
# count_temp=activity_count[j]
# activity_count[j]=activity_count[j+1]
# activity_count[j+1]=count_temp
# end
# end
# end
#desc_sort_course_by_avtivity(@project_ids,@project_activity_count_array,@projects_all)
end
#gcmend
end

View File

@ -32,6 +32,19 @@ class SchoolController < ApplicationController
def index
end
def get_province
@provinces = School.find_by_sql("select distinct province from schools")
options = ""
@provinces.each do |p|
options << "<option value = '#{p.province}' >#{p.province}</option>"
end
render :text => options
end
def get_options
@school = School.where("province = ?", params[:province])

View File

@ -8,6 +8,30 @@ class SoftapplicationsController < ApplicationController
def index
@softapplications = Softapplication.all
#new added fenyefunction
@limit = 5
@softapplication_count = @softapplications.count
@softapplication_pages = Paginator.new @softapplication_count, @limit, params['page']
@offset ||= @softapplication_pages.offset
#@softapplications = @softapplications[@offset,@limit]
#new added end
#new added sort
if params[:softapplication_sort_type].present?
case params[:softapplication_sort_type]
when '0'
@softapplications = @softapplications[@offset, @limit]
@s_state = 0
when '1'
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
@s_state = 1
end
else
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
@s_state = 1
end
#new added end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @softapplications }
@ -16,8 +40,25 @@ class SoftapplicationsController < ApplicationController
# GET /softapplications/1
# GET /softapplications/1.json
def percent_of(num, percent)
num.to_f / percent.to_f * 100.0
end
def show
@softapplication = Softapplication.find(params[:id])
# 打分统计
stars_reates = @softapplication.
rates(:quality)
stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count
stars_status = stars_reates.select("stars, count(*) as scount").
group("stars")
@stars_status_map = Hash.new(0.0)
stars_status.each do |star_status|
@stars_status_map["star#{star_status.stars.to_i}".to_sym] =
percent_of(star_status.scount, stars_reates_count).to_s + "%"
end
@jours = @softapplication.journals_for_messages.order('created_on DESC')
@image_results = []
@softapplication.attachments.each do |f|

View File

@ -39,17 +39,18 @@ class WelcomeController < ApplicationController
@courseCount = Project.course_entities.count
@teacherCount = User.teacher.count
@studentCount = User.student.count
@logoLink = logolink(params[:school_id])
@logoLink = logolink()
end
def logolink(id)
def logolink()
id = params[:school_id]
logo_link = ""
if id.nil? and User.current.user_extensions.school.nil?
logo_link = '/images/transparent.png'
else
if id.to_i == 0
if id == "0"
logo_link = '/images/transparent.png'
else
if id.nil?

View File

@ -1,2 +1,18 @@
module SoftapplicationsHelper
def sort_softapplication(state)
content = ''.html_safe
case state
when 0
content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'softapplications', action: 'index' ,:softapplication_sort_type => '1'}))
content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'softapplications', action: 'index' ,:softapplication_sort_type => '0'}, :class=>"selected"), :class=>"selected")
when 1
content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'softapplications', action: 'index' ,:softapplication_sort_type => '1'}, :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'softapplications', action: 'index' ,:softapplication_sort_type => '0'}))
end
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")
end
end

View File

@ -54,57 +54,111 @@ module UserScoreHelper
watcher_count = Watcher.where("watchable_type = 'principal' AND watchable_id = ?", user.id).count
end
def calculate_skill_count(user)
praise_count = 0
tread_count = 0
praise_count_l0 = 0
praise_count_l1 = 0
praise_count_l2 = 0
tread_count_l0 = 0
tread_count_l1 = 0
tread_count_l2 = 0
issues = Issue.where('author_id = ?', user.id)
issues.each do |i|
ptcs = PraiseTreadCache.where('object_id = ?', i.id)
ptcs.each do |p|
praise_count = praise_count + p.praise_num
tread_count = tread_count + p.tread_num
pts = PraiseTread.where('praise_tread_object_id = ?', i.id)
pts.each do |p|
templevel = calculate_level(User.find(p.user_id))
if templevel.to_i == 0
if p.praise_or_tread == 1
praise_count_l0 = praise_count_l0 + 1
else
tread_count_l0 = tread_count_l0 + 1
end
end
if templevel.to_i == 1
if p.praise_or_tread == 1
praise_count_l1 = praise_count_l1 + 1
else
tread_count_l1 = tread_count_l1 + 1
end
end
if templevel.to_i == 2
if p.praise_or_tread == 1
praise_count_l2 = praise_count_l2 + 1
else
tread_count_l2 + tread_count_l2 + 1
end
end
end
end
bids = Bid.where('author_id = ?', user.id)
bids.each do |b|
ptcs = PraiseTreadCache.where('object_id = ?', b.id)
ptcs = PraiseTread.where('praise_tread_object_id = ?', b.id)
ptcs.each do |p|
praise_count = praise_count + p.praise_num
tread_count = tread_count + p.tread_num
templevel = calculate_level(User.find(p.user_id))
if templevel.to_i == 0
if p.praise_or_tread == 1
praise_count_l0 = praise_count_l0 + 1
else
tread_count_l0 = tread_count_l0 + 1
end
end
if templevel.to_i == 1
if p.praise_or_tread == 1
praise_count_l1 = praise_count_l1 + 1
else
tread_count_l1 = tread_count_l1 + 1
end
end
if templevel.to_i == 2
if p.praise_or_tread == 1
praise_count_l2 = praise_count_l2 + 1
else
tread_count_l2 + tread_count_l2 + 1
end
end
end
end
contests = Contest.where('author_id = ?', user.id)
contests.each do |c|
ptcs = PraiseTreadCache.where('object_id = ?', c.id)
ptcs = PraiseTread.where('praise_tread_object_id = ?', c.id)
ptcs.each do |p|
praise_count = praise_count + p.praise_num
tread_count = tread_count + p.tread_num
templevel = calculate_level(User.find(p.user_id))
if templevel.to_i == 0
if p.praise_or_tread == 1
praise_count_l0 = praise_count_l0 + 1
else
tread_count_l0 = tread_count_l0 + 1
end
end
if templevel.to_i == 1
if p.praise_or_tread == 1
praise_count_l1 = praise_count_l1 + 1
else
tread_count_l1 = tread_count_l1 + 1
end
end
if templevel.to_i == 2
if p.praise_or_tread == 1
praise_count_l2 = praise_count_l2 + 1
else
tread_count_l2 + tread_count_l2 + 1
end
end
end
end
level = calculate_level(user)
skill_score = 0
if level == 0
skill_score = praise_count - 0.5 * tread_count
end
if level == 1
skill_score = 2 * praise_count - 1.5 * tread_count
end
if level == 2
skill_socre = 3 * praise_count - 2.5 * tread_count
end
if level == 3
skill_socre = 4 * praise_count - 3.5 * tread_count
end
if level == 4
skill_socre = 5 * praise_count - 4.5 * tread_count
end
# case level
# when 0 skill_score = praise_count - 0.5 * tread_count
@ -114,12 +168,19 @@ module UserScoreHelper
# when 4 skill_socre = 5 * praise_count - 4.5 * tread_count
# end
skill_score = 2 * praise_count_l0.to_f + 3 * praise_count_l1.to_f + 4 * praise_count_l2.to_f
- 1 * tread_count_l0.to_f - 1.5 * tread_count_l1.to_f - 2 * tread_count_l2.to_f
tread_user_count = PraiseTread.where('praise_or_tread = ? AND user_id = ?', 0, user.id).count
skill_score = skill_score - 0.5 * tread_user_count
skill_score = skill_score.to_f - tread_user_count.to_f
return skill_score
@ -135,7 +196,7 @@ module UserScoreHelper
issues.each do |i|
ptcs = PraiseTreadCache.where('object_id = ?', i.id)
ptcs.each do |p|
if p.praise_num > max_praise_num
if p.praise_num.to_i > max_praise_num.to_i
max_praise_num = p.praise_num
end
end
@ -145,7 +206,7 @@ module UserScoreHelper
bids.each do |b|
ptcs = PraiseTreadCache.where('object_id = ?', b.id)
ptcs.each do |p|
if p.praise_num > max_praise_num
if p.praise_num.to_i > max_praise_num.to_i
max_praise_num = p.praise_num
end
end
@ -155,7 +216,7 @@ module UserScoreHelper
contests.each do |c|
ptcs = PraiseTreadCache.where('object_id = ?', c.id)
ptcs.each do |p|
if p.praise_num > max_praise_num
if p.praise_num.to_i > max_praise_num.to_i
max_praise_num = p.praise_num
end
end

View File

@ -14,7 +14,7 @@
<tr>
<td>简介:</td>
<td>
<%= c_softapplication.softapplication.description %>
<%= c_softapplication.softapplication.description.truncate(90, omission: '...') %>
</td>
</tr></br>
</div>

View File

@ -1,4 +1,132 @@
<!-- <h3> --><!-- %=l(:label_attachment_plural)%></h3 -->
<style>
#ver-zebra, .file_table_des
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
margin: 5px 10px;
width: 98%;
text-align: left;
border-collapse: collapse;
line-height: 20px;
font-size: 14px;
}
#ver-zebra th
{
font-size: 14px;
font-weight: normal;
padding: 12px 15px;
border-right: 1px solid #fff;
border-left: 1px solid #fff;
color: #039;
text-align: left;
}
#ver-zebra td
{
padding: 8px 15px;
border-right: 1px solid #fff;
border-left: 1px solid #fff;
color: #669;
}
#ver-zebra td.description {
background-color: white;
padding: 0px;
margin: 0px auto;
}
div.tags_area {
padding: 2px 10px 10px 10px;
margin: 0px;
margin-bottom: 10px;
/*border-bottom: 1px dashed #CCCCCC;*/
overflow: hidden;
position: relative;
}
.tags_gradint {
}
.read-more{
padding: 5px;
border-top: 4px double #ddd;
background: #fff;
color: #333;
}
.read-more a{
padding-right: 22px;
background: url() no-repeat 100% 50%;
font-weight: bold;
text-decoration: none;
}
.read-more a:hover{
color: #000;
}
.vzebra-odd
{
background: #eff2ff;
}
.vzebra-even
{
background: #e8edff;
}
#ver-zebra #vzebra-adventure, #ver-zebra #vzebra-children
{
background: #ffffff;
border-bottom: 1px solid #c8d4fd;
}
#ver-zebra #vzebra-comedy, #ver-zebra #vzebra-action
{
background: #ffffff;
border-bottom: 1px solid #d6dfff;
}
.filename{
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
div.pagination{
margin: 10px 0px;
height: 1.5em;
text-align: left;
font-size: 13px;
}
.m5p5{
display: inline-block;
height: auto;
color: white !important;
margin: 8px;
padding: 3px 7px;
}
.m5p5:hover {
text-decoration: none;
/*padding-bottom: 3px;*/
/*border-bottom: 1px solid #666666;*/
border-radius: 4px;
border: 1px solid #15bccf;
box-shadow: 3px 3px 3px #666666;
}
.relation_file_div{
margin: 0px 25px;
}
.relation_file_div fieldset{
margin: 0px 0px;
padding: 10px;
border-radius: 5px;
transition: all 2s linear 1s;
}
.relation_file_div input#attach_search:focus{
border: 1px solid #1B95C6;
box-shadow: 0px 0px 4px #1B95C6;
width: 200px;
}
.relation_file_div input#attach_search{
width: 150px;
outline: none;
border-radius: 5px;
-webkit-transition: 1s width;
-moz-transition : 1s width;
-o-transition : 1s width;
transition : 1s width;
}
</style>
<span class="borad-title"><%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区</span>
@ -88,9 +216,7 @@
<td class='description' colspan="5">
<div class="tags_area">
<% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
<div id='attach_<%=file.id%>' ><%#需要交由浏览器异步刷新或者一次连表查询n+1 查询问题搞不定%>
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%>
</div>
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%>
<div class="tags_gradint"></div>
</div>
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a></div>

View File

@ -0,0 +1,22 @@
<div class="top-content">
<table>
<tr>
<td class="info_font" style="width: 240px; color: #15bccf">创新竞赛社区</td>
<td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
<td rowspan="2" width="305px">
<div class="project-search" style="float: right">
<%= text_field_tag 'name', params[:name], :size => 25 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
</div>
</td>
</tr>
<tr>
<td style="padding-left: 8px"><%=link_to request.host()+"/softapplications", :controller=>'softapplications', :action=>'index' %></td>
<td ><%=link_to l(:field_homepage), home_path %> >
<%=link_to l(:label_contest_softapplication), :controller=>'softapplications', :action=>'index' %>
</td>
</tr>
</table>
</div>

View File

@ -108,22 +108,23 @@
<!-- added by Wen -->
<p style="width:357px;padding-left: 26px;">
<p style="padding-left: 26px;">
<% unless User.current.user_extensions.school.nil? %>
<%= 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, User.current.user_extensions.school.province), :onclick => "get_options(this.value)" %>
<input id="occupation" name="occupation" type="hidden" value="<%=User.current.user_extensions.school.id%>" />
<input id="occupation_name" type="text" value="<%=User.current.user_extensions.school.name%>" readonly />
<%= l(:field_occupation) %>&nbsp;<span class="required">*</span>
<input id="province" name="province" type="text" value="<%=User.current.user_extensions.school.province%>" readonly />
<input id="occupation" name="occupation" type="hidden" value="<%=User.current.user_extensions.school.id%>" />
<input id="occupation_name" type="text" value="<%=User.current.user_extensions.school.name%>" readonly />
<!--<%= select_tag "occupation",
options_for_select([[User.current.user_extensions.school.name, User.current.user_extensions.school.id]]) %>-->
<% else %>
<%= 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), :onclick => "get_options(this.value)" %>
<%= l(:field_occupation) %>&nbsp;<span class="required">*</span>
<input id="province" name="province" type="text" value="请单击选择省份及学校" readonly >
<input id="occupation" name="occupation" type="hidden" />
<input id="occupation_name" type="text" readonly />
<input id="occupation" name="occupation" type="hidden" />
<input id="occupation_name" type="text" readonly />
<% end %>
<!-- <input id="occupation" readonly />-->
</p>
@ -131,6 +132,18 @@
<div id="WOpenWindow">
<a class="modal_close" href="#"></a>
<h2>学校列表</h2>
<div class="pcontent">
<ul id="provincelist" class="school_list">
<% @ss = School.find_by_sql("select distinct province from schools") %>
<% @ss.each do |s| %>
<li style="width: 15%; float: left;">
<a style="cursor: pointer;" onclick = "get_options('<%= s.province %>')"><%= s.province %>
</a>
</li>
<% end %>
</ul>
</div>
<hr/>
<div class="content" style="font-size: 13px">
<ul id="schoollist" class="school_list">

View File

@ -52,7 +52,7 @@
<!--gcm-->
<p class="stats">
<%= content_tag('span', link_to("#{@project_activity_count[@project.id]}", member_project_path(@project)), :class => "info") %>
<%= content_tag('span', link_to("#{@project_activity_count[@project.id]}", project_path(@project)), :class => "info") %>
<%= content_tag('span', l(:label_x_activity, :count => @project_activity_count[@project.id])) %>
</p>
<!--gcm-->

View File

@ -1,4 +1,22 @@
<% port = ":3000" if Rails.env.development? %>
<script type="text/javascript">
$(document).ready(function() {
$("#province").html("<option value='0' selected = true style='display: none;'></option>");
$.ajax({
type :"POST",
url :'/school/get_province',
data :'text',
success: function(data){
$("#province").append(data);
}
})
});
</script>
<script type="text/javascript">
function get_school(value){
$.ajax({
@ -50,9 +68,9 @@
<a href="http://course.trustie.net<%=port%>">我的学校</a>
</p>
<ul>
<li style="width: 40%; float: left">请选择省份:<%= select_tag "province",
options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province),
:onclick => "get_school(this.value)" %></li>
<li style="width: 40%; float: left">请选择省份:
<select id="province" name="province" onchange="get_school(this.value)"></select>
</li>
<li style="width: 50%; float: left"><input type="text" id="key_word" name="key_word" />
<input type="button" class="enterprise" value="搜索" onclick="ssearch()"></li>
</ul>

View File

@ -1,33 +1,39 @@
<h1>参赛应用</h1>
<table>
<tr>
<th>Name</th>
<th>Description</th>
<th>App type</th>
<th>App type name</th>
<th>Android min version available</th>
<th>User</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @softapplications.each do |softapplication| %>
<tr>
<td><%= softapplication.name %></td>
<td><%= softapplication.description %></td>
<td><%= softapplication.app_type_id %></td>
<td><%= softapplication.app_type_name %></td>
<td><%= softapplication.android_min_version_available %></td>
<td><%= softapplication.user_id %></td>
<td><%= link_to 'Show', softapplication %></td>
<td><%= link_to 'Edit', edit_softapplication_path(softapplication) %></td>
<td><%= link_to 'Destroy', softapplication, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<%=render :partial => 'layouts/base_softapplication_index_top_content'%>
<% if @softapplications.size > 0%>
<%= sort_softapplication(@s_state)%>
<div width="95%" border="0" style="padding-left: 10px; padding-top: 10px;">
<% @softapplications.each do |softapplication| %>
<div>
<span style="font-size: 15px; margin-right: 10px;"><strong><%= link_to softapplication.name, softapplication, :target => "_blank" %></strong></span>
<span><%= rating_for softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %></span>
</div>
<div class="avatar-4"; style="float: left; margin-top: 7px "><%= image_tag('/images/app1.png')%></div>
<div style="float: left; width: 600px; padding-top: 6px; margin-left: 8px"><%= softapplication.description.truncate(95, omission: '...') %></div>
<div style="float: left; width: 200px; margin-left: 70px; margin-top: -3px; ">
<%contest = softapplication.contests.first%>
<p>所属竞赛:<%= contest ? link_to(contest.name.truncate(10, omission: '...'), show_softapplication_contest_path(contest), title: contest.name.to_s ) : '尚未加入竞赛'%></p>
<p>所属类别:<%= softapplication.app_type_name %></p>
<p>系统支持:<%= softapplication.android_min_version_available %></p>
</div>
<div style="padding-left: 53px">
<span>开发人员:<%= softapplication.application_developers %></span>
<span style="padding-left: 50px">发布时间:<%=format_time softapplication.created_at %></span>
</div>
<div style="border-left: 1px solid #d9d8d8; border-bottom: 1px solid #d9d8d8; margin-left: 50px; padding-bottom: 10px; margin-bottom: 20px; width: 66%"></div>
<div class="underline-contests_one" style="margin-top: -7px"></div>
<% end %>
</div>
<% else %>
<%= render :partial => "layouts/no_content"%>
<% end %>
</table>
<br />
<%= link_to 'New Softapplication', new_softapplication_path %>
<div class="pagination"><%= pagination_links_full @softapplication_pages, @softapplication_count, :per_page_links => false %></div>
<% html_title l(:label_softapplication_list)%>

View File

@ -27,7 +27,7 @@
<tr>
<td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all">所属类别:<%= @softapplication.app_type_name %></td>
<% contest = @softapplication.contests.first %>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">所属竞赛:<%= contest ? link_to(contest.name, show_contest_contest_path(contest)) : '尚未加入竞赛'%></td>
<td style="width: 240px; word-wrap: break-word; word-break: break-all">所属竞赛:<%= contest ? link_to(contest.name, show_softapplication_contest_path(contest)) : '尚未加入竞赛'%></td>
</tr>
<tr>
<td style="padding-left: 40px">发布人员:<%= @softapplication.user.name %></td>
@ -56,14 +56,40 @@
<div class="underline-contests_one"></div>
<div style="height: auto; padding-bottom: 10px">
<strong><div style="font-size: 15px">应用简介:</div></strong>
<div><%= @softapplication.description.truncate(150, omission: '...') %></div>
<strong><div style="font-size: 15px;">应用简介:</div></strong>
<div style="padding-top: 5px"><%= @softapplication.description %></div>
</div>
<div class="underline-contests_one"></div>
<div style="height: 240px">
<div style="height: auto; padding-bottom: 10px">
<div style="font-size: 15px;"><strong>应用得分:</strong></div>
<div style="overflow: hidden">
<div style="margin-left: 25%; float: left">
<div style="padding-left: 45px; padding-bottom: 5px">得分比例</div>
<div>
<% 100.step(20,-20) do |star| %>
<div data-kls="Softapplication" data-id="2" data-dimension="quality" data-average="3.25" class="rateable div_inline jDisabled" style="height: 20px; width: 115px; overflow: hidden; z-index: 1; position: relative;">
<div class="jRatingColor" style="width: <%=star%>%;"></div>
<div class="jRatingAverage" style="width: 0px; top: -20px;"></div>
<div class="jStar" style="width: 115px; height: 20px; top: -40px; background: url(&quot;/images/seems_rateable/stars.png&quot;) repeat-x scroll 0% 0% transparent;">
</div>
</div>
<%= @stars_status_map["star#{(star/20).to_s}".to_sym] %>
<br>
<% end %>
</div>
</div>
<div style="float: left; padding-left: 100px; padding-top:35px ">
<div style="padding-left: 25px;">最终得分</div>
<div style="padding-top: 3px"><%= rating_for @softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %></div>
</div>
</div>
</div>
<div class="underline-contests_one"></div>
<div style="height: auto; padding-bottom: 10px">
<strong><div style="font-size: 15px">软件截图:</div></strong>
<div class="softapplication-img">
<div class="softapplication-img" style="padding-top: 5px">
<% @image_results.take(4).each do |attachment| %>
<%= link_to_attachment_img attachment, :class => "soft-application", :download => "true" %>
<% end %>
@ -72,7 +98,18 @@
</div>
<div class="underline-contests_one"></div>
<!-- <div style="margin-left: 22%;">
<% 100.step(20,-20) do |star| %>
<div data-kls="Softapplication" data-id="2" data-dimension="quality" data-average="3.25" class="rateable div_inline jDisabled" style="height: 20px; width: 115px; overflow: hidden; z-index: 1; position: relative;">
<div class="jRatingColor" style="width: <%=star%>%;"></div>
<div class="jRatingAverage" style="width: 0px; top: -20px;"></div>
<div class="jStar" style="width: 115px; height: 20px; top: -40px; background: url(&quot;/images/seems_rateable/stars.png&quot;) repeat-x scroll 0% 0% transparent;">
</div>
</div>
<%= @stars_status_map["star#{(star/20).to_s}".to_sym] %>
<br>
<% end %>
</div> -->
<div style="height: 50px">
<div style="font-size: 15px"><strong>软件评论:</strong></div>
<div style="padding-left: 210px">评分: <%= rating_for @softapplication, dimension: :quality, class: 'rateable div_inline' %></div>

View File

@ -12,14 +12,13 @@
<tr>
<td><%= user.lastname %><%= user.firstname %></td>
<!-- <td><%= calculate_collaboration_count(user) %></td>
<td><%= calculate_collaboration_count(user) %></td>
<td><%= calculate_influence_count(user) %></td>
<td><%= calculate_skill_count(user) %></td>
<td><%= calculate_file(user) %></td>
<td><%= calculate_issue(user) %></td>
<td><%= calculate_file(user) %></td>
<td><%= calculate_issue(user) %></td>
<td><%= calculate_level(user) %></td>
-->
<td><%= user.changesets.count %></td>
</tr>
<% end %>
</table>

View File

@ -201,7 +201,7 @@
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<h3 style="margin-left: 5px; color: #e8770d;"><strong>最新参赛应用</strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'softapplications', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %></span>
<div class="d-p-projectlist-box">
<% if Softapplication.count > 0%>
<div class="d-p-projectlist">

View File

@ -20,40 +20,37 @@
</div>
<div class="main-content-bar">
<div style="float: left">
<%= image_tag(@logoLink, size:'75x75') %>
</div>
<div class="welcome_left" >
<span class="font_welcome_school">
<% if params[:school_id].nil? and User.current.user_extensions.school.nil? %>
<% else%>
<% if params[:school_id] == "0" %>
<% else %>
<% if params[:school_id].nil? %>
<%= image_tag(@logoLink, size:'75x75') %>
<%= School.find(User.current.user_extensions.school.id).name %>
<br />
</div>
<div class="welcome_left" >
<br />
<span class="font_welcome_school"> <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %>
<% else%>
<% if params[:school_id] == "0" %>
<% else %>
<%= School.find(params[:school_id]).name %>
<br />
<% if params[:school_id].nil? %>
<%= School.find(User.current.user_extensions.school.id).name %>
<br />
<% else %>
<%= School.find(params[:school_id]).name %>
<br />
<% end %>
<% end %>
<% end %>
<% end %>
</span>
<% end %> </span>
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> </span>
<% if params[:school_id].nil? and User.current.user_extensions.school.nil? %>
<span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span>
<span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span>
<% else %>
<% if params[:school_id] == "0" %>
<span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span>
<span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span>
<% end %>
<% end %>
</div>
<div class="search-bar">
<%= render :partial => "search_project", :locals => {:project_type => Project::ProjectType_course}%>
</div>
<div style="clear: both;"></div>
</div>
<div class="search-bar">
<%= render :partial => "search_project", :locals => {:project_type => Project::ProjectType_course}%>
</div>
<div style="clear: both;"></div>
</div>
</div>

View File

@ -1425,7 +1425,7 @@ zh:
label_has_praisers: 赞(%{count})
label_has_watchers: 关注(%{count})
label_has_fans: 粉丝(%{count})
label_coursefile_sharingarea: 课程资源共享
label_coursefile_sharingarea: 课程文件共享专
#modify by men
label_x_has_fans:
zero: 粉丝(%{count})
@ -1547,7 +1547,6 @@ zh:
label_sort_by_time: 按时间排序
label_sort_by_active: 按活跃度排序
label_sort_by_influence: 按影响力排序
label_sort_by_activity: 按动态数排序
label_bids_published: 发布于
label_bids_published_ago: 之前
label_welcome_trustie: Trustie
@ -1668,7 +1667,7 @@ zh:
label_public_info: (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该项目。)
label_course_view_student: 查看其他课程
label_course_student: 学生
label_homework: 课程实践
label_homework: 课程作业
label_course_file: 资源库 #资料共享
label_stores_index: 资源搜索
label_course_new_homework: 新建作业
@ -1716,11 +1715,6 @@ zh:
zero: 份资料
one: 份资料
other: 份资料
#added by gcm
label_x_activity:
zero: 个动态
one: 个动态
other: 个动态
@ -1765,13 +1759,13 @@ zh:
label_has_been: 已经被
label_course_userd_by: 个课程引用
label_school_all: 中国高校
role_of_course: 课程角色
label_student: 学生
#added by Wen
label_school_all: 中国高校
label_project_grade: 项目得分
label_user_grade: 个人得分
label_user_for_project_grade: 个人得分
@ -1829,8 +1823,7 @@ zh:
label_sumbit_empty: 搜索内容不能为空
#add by linchun (竞赛相关)
label_upload_files: 上传资源
label_relation_files: 关联已有资源
label_upload_files: 上传文件
label_upload_softwarepackage: 上传软件包
label_upload_cuttingphoto: 上传截图
label_contests_reward_method: 奖励方式
@ -1869,8 +1862,19 @@ zh:
label_add_contest_succeed_fail: 添加失败,该应用已参赛.
label_no_ftapplication: 暂无应用
label_edit_softapplication: 修改应用
label_contest_delete: 删除竞赛
label_softapplication_list: 应用列表
label_coursefile_sharingarea: 课程资源共享区
label_sort_by_activity: 按动态数排序
label_homework: 课程实践
label_x_activity:
zero: 个动态
one: 个动态
other: 个动态
label_school_all: 中国高校
label_upload_files: 上传资源
label_relation_files: 关联已有资源
label_contest_settings: 配置竞赛
label_contest_delete: 删除竞赛

View File

@ -581,6 +581,9 @@ RedmineApp::Application.routes.draw do
#######confusing########
post 'school/get_options/:province', :to => 'school#get_options'
get 'school/get_options/:province', :to => 'school#get_options'
post 'school/get_province', :to => 'school#get_province'
get 'school/get_province', :to => 'school#get_province'
post 'school/get_schoollist/:province', :to => 'school#get_schoollist'
get 'school/get_schoollist/:province', :to => 'school#get_schoollist'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

View File

@ -624,7 +624,7 @@ ul.tool li{list-style-type:none;
font-family: Tahoma,"Microsoft YaHei";
font-weight: bold;
font-size: 20px;
color:#FF9900;
color:#e8770d;
}
.font_welcome_Cdescription{

View File

@ -227,17 +227,15 @@ body {
display: none;
padding-bottom: 2px;
width: 1000px;
height: 500px;
z-index: 100;
left: 50%;
margin-left: -202px;
opacity: 1;
position: fixed;
top: 200px;
overflow: scroll;
}
#WOpenWindow .school_list{
width1000px;
width: 900px;
line-height: 20px;
}
@ -259,6 +257,12 @@ body {
}
#WOpenWindow .content{
width: 1000px;
height: 220px;
overflow: scroll;
}
#WOpenWindow .pcontent{
}

View File

@ -2247,130 +2247,4 @@ ul.messages-for-user-reply li {
.footer_text_link{
margin: 0px 5px;
}
/*gcm*/
#ver-zebra, .file_table_des
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
margin: 5px 10px;
width: 98%;
text-align: left;
border-collapse: collapse;
line-height: 20px;
font-size: 14px;
}
#ver-zebra th
{
font-size: 14px;
font-weight: normal;
padding: 12px 15px;
border-right: 1px solid #fff;
border-left: 1px solid #fff;
color: #039;
text-align: left;
}
#ver-zebra td
{
padding: 8px 15px;
border-right: 1px solid #fff;
border-left: 1px solid #fff;
color: #669;
}
#ver-zebra td.description {
background-color: white;
padding: 0px;
margin: 0px auto;
}
div.tags_area {
padding: 2px 10px 10px 10px;
margin: 0px;
margin-bottom: 10px;
/*border-bottom: 1px dashed #CCCCCC;*/
overflow: hidden;
position: relative;
}
.tags_gradint {
}
.read-more{
padding: 5px;
border-top: 4px double #ddd;
background: #fff;
color: #333;
}
.read-more a{
padding-right: 22px;
background: url() no-repeat 100% 50%;
font-weight: bold;
text-decoration: none;
}
.read-more a:hover{
color: #000;
}
.vzebra-odd
{
background: #eff2ff;
}
.vzebra-even
{
background: #e8edff;
}
#ver-zebra #vzebra-adventure, #ver-zebra #vzebra-children
{
background: #ffffff;
border-bottom: 1px solid #c8d4fd;
}
#ver-zebra #vzebra-comedy, #ver-zebra #vzebra-action
{
background: #ffffff;
border-bottom: 1px solid #d6dfff;
}
.filename{
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
div.pagination{
margin: 10px 0px;
height: 1.5em;
text-align: left;
font-size: 13px;
}
.m5p5{
display: inline-block;
height: auto;
color: white !important;
margin: 8px;
padding: 3px 7px;
}
.m5p5:hover {
text-decoration: none;
/*padding-bottom: 3px;*/
/*border-bottom: 1px solid #666666;*/
border-radius: 4px;
border: 1px solid #15bccf;
box-shadow: 3px 3px 3px #666666;
}
.relation_file_div{
margin: 0px 25px;
}
.relation_file_div fieldset{
margin: 0px 0px;
padding: 10px;
border-radius: 5px;
transition: all 2s linear 1s;
}
.relation_file_div input#attach_search:focus{
border: 1px solid #1B95C6;
box-shadow: 0px 0px 4px #1B95C6;
width: 200px;
}
.relation_file_div input#attach_search{
width: 150px;
outline: none;
border-radius: 5px;
-webkit-transition: 1s width;
-moz-transition : 1s width;
-o-transition : 1s width;
transition : 1s width;
}
/*gcm*/