Merge branch 'develop'

This commit is contained in:
xianbo 2014-04-25 16:35:48 +08:00
commit 6ac503eac5
115 changed files with 2129 additions and 1044 deletions

View File

@ -6,7 +6,7 @@ unless RUBY_PLATFORM =~ /w32/
gem 'rubyzip'
gem 'zip-zip'
end
gem 'seems_rateable'
gem 'seems_rateable', path: 'lib/seems_rateable'
gem "rails", "3.2.13"
gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0"
@ -72,6 +72,10 @@ end
group :development do
gem "rdoc", ">= 2.4.2"
if nil
gem 'thin'
gem 'rack-mini-profiler'
end
end

119
Gemfile.lock Normal file
View File

@ -0,0 +1,119 @@
PATH
remote: lib/seems_rateable
specs:
seems_rateable (1.0.13)
jquery-rails
rails
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.13)
actionpack (= 3.2.13)
mail (~> 2.5.3)
actionpack (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
activerecord (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
activesupport (3.2.13)
i18n (= 0.6.1)
multi_json (~> 1.0)
acts-as-taggable-on (2.4.1)
rails (>= 3, < 5)
arel (3.0.2)
builder (3.0.0)
coderay (1.0.9)
erubis (2.7.0)
fastercsv (1.5.0)
hike (1.2.3)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.0.3)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
json (1.8.0)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.23)
multi_json (1.7.6)
mysql2 (0.3.11-x86-mingw32)
net-ldap (0.3.1)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.13)
actionmailer (= 3.2.13)
actionpack (= 3.2.13)
activerecord (= 3.2.13)
activeresource (= 3.2.13)
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.13)
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.4)
rdoc (3.12.2)
json (~> 1.4)
ruby-openid (2.1.8)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.18.1)
tilt (1.4.1)
treetop (1.4.14)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.37)
PLATFORMS
x86-mingw32
DEPENDENCIES
activerecord-jdbc-adapter (= 1.2.5)
activerecord-jdbcmysql-adapter
acts-as-taggable-on
builder (= 3.0.0)
coderay (~> 1.0.6)
fastercsv (~> 1.5.0)
i18n (~> 0.6.0)
jquery-rails (~> 2.0.2)
mysql2 (~> 0.3.11)
net-ldap (~> 0.3.1)
rack-openid
rails (= 3.2.13)
rdoc (>= 2.4.2)
ruby-openid (~> 2.1.4)
seems_rateable!

View File

@ -114,22 +114,12 @@ class IssuesController < ApplicationController
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
# @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
if User.current.admin? || User.current.id == @issue.author_id || User.current.id == @issue.assigned_to_id || ProjectInfo.manager?(User.current.id, @project)
@edit_allowed = true
# elsif User.current.id == @issue.author.id
else
@edit_allowed = false
end
# @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
@priorities = IssuePriority.active
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
@project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young
#by huang
# @change_flag = (@issue.author == User.current) || (User.current.admin?)
#end
respond_to do |format|
format.html {
retrieve_previous_and_next_issue_ids

View File

@ -128,7 +128,7 @@ class ProjectsController < ApplicationController
def index
#Modified by nie
@project_type = params[:project_type]
@project_type = params[:project_type].to_i
per_page_option = 10
@projects_all = Project.active.visible.
@ -177,30 +177,166 @@ class ProjectsController < ApplicationController
def course
@project_type = params[:project_type]
@school_id = params[:school_id]
per_page_option = 10
@projects_all = Project.active.visible.
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").
where("#{Project.table_name}.project_type = ? ", Project::ProjectType_course)
if @school_id == "0" or @school.nil?
@projects_all = Project.active.visible.
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").
where("#{Project.table_name}.project_type = ? ", Project::ProjectType_course)
else
@projects_all = Project.active.visible.
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").
joins(:course_extra).
where("#{Project.table_name}.project_type = ? AND #{Course.table_name}.school_id = ?", Project::ProjectType_course, @school_id)
end
@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_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
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)
when '1'
@projects = @projects_all.order("course_ac_para desc")
@s_type = 1
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
when '2'
@projects = @projects_all.order("watchers_count desc")
@s_type = 2
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
#gcm
when '3'
@projects=desc_sort_course_by_avtivity(@project_ids,@project_activity_count_array,@project_all_array)
@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)
end
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
respond_to do |format|
format.html {
@ -220,8 +356,8 @@ class ProjectsController < ApplicationController
def search
#modified by nie
project_type = params[:project_type]
projects_all = (project_type.eql? Project::ProjectType_project) ? Project.project_entities : Project.course_entities
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})
@ -392,7 +528,8 @@ class ProjectsController < ApplicationController
# added by bai
@course.term = params[:term]
@course.time = params[:time]
@course.school_id = params[:occupation]
#@course.school_id = params[:occupation]
@course.school_id = User.current.user_extensions.school_id
@course.setup_time = params[:setup_time]
@course.endup_time = params[:endup_time]
@course.class_period = params[:class_period]
@ -575,7 +712,7 @@ class ProjectsController < ApplicationController
"show_journals_for_messages" => true
}
@date_to ||= Date.today + 1
@date_from = @date_to - @days
@date_from = @date_to - @days-1.years
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
# 决定显示所用用户或单个用户活动
@ -725,7 +862,7 @@ class ProjectsController < ApplicationController
if params[:project][:is_public] == '0'
project_status = ProjectStatus.find_by_project_id(@project.id)
project_status.destroy
project_status.destroy if project_status
elsif params[:project][:is_public] == '1'
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => @project.watchers.count, :changesets_count => @project.changesets.count,:grade => 0, :project_type => @project.project_type)
end
@ -880,4 +1017,32 @@ class ProjectsController < ApplicationController
@users -= watched.watcher_users
end
end
def desc_sort_course_by_avtivity(ids,activity_count,projects)
return projects if activity_count.size<2
(activity_count.size-2).downto(0) do |i|
(0..i).each do |j|
if activity_count[j]<activity_count[j+1]
projects[j],projects[j+1]=projects[j+1],projects[j]
activity_count[j],activity_count[j+1]=activity_count[j+1],activity_count[j]
end
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
end

View File

@ -1,15 +0,0 @@
require_dependency "seems_rateable/application_controller"
class RatingsController < ::ApplicationController
def create
raise NoCurrentUserInstanceError unless current_user
obj = params[:kls].classify.constantize.find(params[:idBox])
begin
obj.rate(params[:rate].to_i, current_user.id, params[:dimension])
render :json => true
rescue Errors::AlreadyRatedError
render :json => {:error => true}
end
end
end

View File

@ -1,4 +1,16 @@
class SchoolController < ApplicationController
before_filter :require_admin, :only => :upload_logo
def upload_logo
end
def index
end
def get_options
@school = School.where("province = ?", params[:province])
p = params[:province]
@ -6,10 +18,34 @@ class SchoolController < ApplicationController
options = ""
@school.each do |s|
options << "<option value=#{s.id}>#{s.name}</option>"
#options << "<option value=#{s.id}>#{s.name}</option>"
options << "<li style = 'width: 33%; float: left'><a id=#{s.id} onclick='test(this.id, this.text)'>#{s.name}</a></li>"
end
render :text => options
end
def get_schoollist
@school = School.where("province = ?", params[:province])
options = ""
@school.each do |s|
options << "<li style = 'width: 33%; float: left'><a id=#{s.id} onclick='test(this.id)'>#{s.name}</a></li>"
end
render :text => options
end
def search_school
@school = School.where("province = ? AND name LIKE '%"+params[:key_word]+"%'", params[:province]);
options = ""
@school.each do |s|
options << "<li style = 'width: 33%; float: left'><a id=#{s.id} onclick='test(this.id)'>#{s.name}</a></li>"
end
render :text => options
end
end

View File

@ -1,4 +1,8 @@
class SoftapplicationsController < ApplicationController
before_filter :find_softapplication, only: [:edit, :update, :destroy]
before_filter :editable, only: [:edit, :update]
before_filter :destroyable, only: :destroy
# GET /softapplications
# GET /softapplications.json
def index
@ -71,8 +75,9 @@ class SoftapplicationsController < ApplicationController
# PUT /softapplications/1
# PUT /softapplications/1.json
def update
@softapplication = Softapplication.find(params[:id])
# @softapplication = Softapplication.find(params[:id])
@softapplication.attachments.map{|attach| attach.destroy }
@softapplication.save_attachments(params[:attachments])
respond_to do |format|
if @softapplication.update_attributes(params[:softapplication])
format.html { redirect_to @softapplication, notice: 'Softapplication was successfully updated.' }
@ -92,11 +97,11 @@ class SoftapplicationsController < ApplicationController
# DELETE /softapplications/1
# DELETE /softapplications/1.json
def destroy
@softapplication = Softapplication.find(params[:id])
# @softapplication = Softapplication.find(params[:id])
@softapplication.destroy
respond_to do |format|
format.html { redirect_to softapplications_url }
format.html { redirect_to home_path }
format.json { head :no_content }
end
end
@ -192,4 +197,24 @@ class SoftapplicationsController < ApplicationController
#format.api { render_api_ok }
end
end
private
def find_softapplication
@softapplication = Softapplication.find_by_id(params[:id])
end
def editable
unless @softapplication.editable_by? User.current
render_403
return false
end
end
def destroyable
unless @softapplication.destroyable_by? User.current
render_403
return false
end
end
end

View File

@ -1,4 +1,6 @@
class TestController < ApplicationController
helper :UserScore
def zip
homeworks_attach_path = []

View File

@ -0,0 +1,6 @@
class UserScoreController < ApplicationController
helper :UserScore
end

View File

@ -17,7 +17,7 @@
class WelcomeController < ApplicationController
caches_action :robots
before_filter :fake, :only => [:index, :course]
# before_filter :fake, :only => [:index, :course]
before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index]
def index

View File

@ -255,26 +255,17 @@ module ApplicationHelper
end
classes = (ancestors.empty? ? 'root' : 'child')
s << "<li class='project-table'><div class='#{classes}'>"
if params[:project_type] == "0"
if project.try(:project_type) == Project::ProjectType_project
s << h(block_given? ? yield(project) : project.name)
else
end
# if @project.project_type == 1
# unless Course.find_by_extra(@project.identifier).nil?
# unless Course.find_by_extra(@project.identifier).tea_id == User.current.id
# s << "<span style = 'float: right;'>"
# s << join_in_course(@project, User.current)#, ['whiteButton'])
# s << "</span>"
# end
# end
# end
if params[:project_type] == "0"
if project.try(:project_type) == Project::ProjectType_project
unless User.current.member_of?(@project)
s << "<span style = 'float: right;'>"
s << watcher_link(@project, User.current)#, ['whiteButton'])
s << "</span>"
end
end
s << (render :partial => 'projects/project', :locals => {:project => project}).to_s
else
s << (render :partial => 'projects/course', :locals => {:project => project}).to_s
@ -1579,9 +1570,14 @@ module ApplicationHelper
forum_link = link_to l(:label_project_module_forums), {:controller => "forums", :action => "index"}
stores_link = link_to l(:label_stores_index), {:controller => 'stores', :action=> 'index'}
school_all_school_link = link_to l(:label_school_all), {:controller => 'school', :action => 'index'}
#@nav_dispaly_project_label
nav_list = Array.new
nav_list.push(home_link) if !@nav_dispaly_home_path_label
nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label
nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label
nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label

View File

@ -69,18 +69,29 @@ module ProjectsHelper
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type)))
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type)))
when 1
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type)))
when 2
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type)))
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type)))
#gcm
when 3
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type)))
# content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:project_sort_type => '3', :project_type => project_type), :class=>"selected"), :class=>"selected")
end
#gcmend
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")
end
@ -164,7 +175,7 @@ module ProjectsHelper
def render_project_hierarchy(projects)
render_project_nested_lists(projects) do |project|
#Modified by young
if (project.project_type==1)
if (project.try(:project_type) == Project::ProjectType_course )
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}").html_safe
else
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")

View File

@ -24,21 +24,171 @@ module UserScoreHelper
issues.each do |issue|
issue_c = issue_c + issue.journals.where("user_id <> ?", user.id).count
end
issue_c = issue_c + Journal.where("user_id = ?", user.id)
issue_c = issue_c + Journal.where("user_id = ?", user.id).count
############################
memos = Memo.where('author_id = ? AND parent_id IS NOT NULL', user.id)
memos.each do |m|
if Memo.find(m.parent_id).author.id != user.id
issue_c = issue_c + 1
else
issue_c = issue_c - 1
end
end
pmemos = Memo.where('author_id = ? AND parent_id IS NULL', user.id)
pmemos.each do |pm|
issue_c = issue_c + pm.replies_count
end
############################
issue_c = issue_c + JournalsForMessage.where('user_id = ? AND reply_id IS NOT NULL AND reply_id <> ?', user.id, user.id).count + JournalsForMessage.where('reply_id = ? AND user_id <> ?', user.id, user.id).count
return issue_c
end
def calculate_influence_count(user)
watcher_count = watcher_users(User.current.id).count
watcher_count = Watcher.where("watchable_type = 'principal' AND watchable_id = ?", user.id).count
end
def calculate_skill_count(user)
0
praise_count = 0
tread_count = 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
end
end
bids = Bid.where('author_id = ?', user.id)
bids.each do |b|
ptcs = PraiseTreadCache.where('object_id = ?', b.id)
ptcs.each do |p|
praise_count = praise_count + p.praise_num
tread_count = tread_count + p.tread_num
end
end
contests = Contest.where('author_id = ?', user.id)
contests.each do |c|
ptcs = PraiseTreadCache.where('object_id = ?', c.id)
ptcs.each do |p|
praise_count = praise_count + p.praise_num
tread_count = tread_count + p.tread_num
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
# when 1 skill_score = 2 * praise_count - 1.5 * tread_count
# when 2 skill_socre = 3 * praise_count - 2.5 * tread_count
# when 3 skill_socre = 4 * praise_count - 3.5 * tread_count
# when 4 skill_socre = 5 * praise_count - 4.5 * tread_count
# end
tread_user_count = PraiseTread.where('praise_or_tread = ? AND user_id = ?', 0, user.id).count
skill_score = skill_score - 0.5 * tread_user_count
return skill_score
end
def calculate_level(user)
1
commit_count = user.changesets.count
max_praise_num = 0
issues = Issue.where('author_id = ?', user.id)
issues.each do |i|
ptcs = PraiseTreadCache.where('object_id = ?', i.id)
ptcs.each do |p|
if p.praise_num > max_praise_num
max_praise_num = p.praise_num
end
end
end
bids = Bid.where('author_id = ?', user.id)
bids.each do |b|
ptcs = PraiseTreadCache.where('object_id = ?', b.id)
ptcs.each do |p|
if p.praise_num > max_praise_num
max_praise_num = p.praise_num
end
end
end
contests = Contest.where('author_id = ?', user.id)
contests.each do |c|
ptcs = PraiseTreadCache.where('object_id = ?', c.id)
ptcs.each do |p|
if p.praise_num > max_praise_num
max_praise_num = p.praise_num
end
end
end
best_answer_num = 0
isManager = 0
members = Member.where('user_id = ?', user.id)
members.each do |m|
roles = m.member_roles
roles.each do |r|
if r.role_id == 3
isManager = 1
end
end
end
level = 0
if max_praise_num > 4
level = 1
end
if commit_count > 0 and commit_count < 101
level = 1
end
if commit_count > 100 or isManager == 1
level = 2
end
return level
end
def calculate_activity_count(user)
@ -51,13 +201,13 @@ module UserScoreHelper
# end
# file_count = user.file_commit.count
# issue_count = Issue.where('author_id = ?', user.id).count
f = user.user_score.file
i = user.user_score.issue
f_max = UserScore.find_max_file
f_min = UserScore.find_min_file
i_max = UserScore.find_max_issue
i_min = UserScore.find_min_issue
score = 100 * ((f - f_min)/(f_max - f_min) + (i - i_min)/(i_max - i_min))
#f = user.user_score.file
#i = user.user_score.issue
#f_max = UserScore.find_max_file
#f_min = UserScore.find_min_file
#i_max = UserScore.find_max_issue
#i_min = UserScore.find_min_issue
#score = 100 * ((f - f_min)/(f_max - f_min) + (i - i_min)/(i_max - i_min))
end
def calculate_file(user)
@ -72,8 +222,14 @@ module UserScoreHelper
issue_details_count = 0
issues = Issue.where('assigned_to_id = ?', user.id)
change_count = 0
issues.each do |issue|
change_count = issue.journals.where("prop_key = ?", "done_ratio").count
js = issue.journals
js.each do |j|
change_count = change_count + j.details.where("prop_key = ?", "done_ratio").count
end
issue_details_count = change_count + issue_details_count
end
@ -89,7 +245,9 @@ module UserScoreHelper
file = calculate_file(user)
issue = calculate_issue(user)
level = calculate_level(user)
user.user_score << UserScore.new(:collaboration => collaboration, :influence => influence, :skill => skill,
#user.user_score << UserScore.new(:collaboration => collaboration, :influence => influence, :skill => skill,
# :activity => activity, :file => file, :issue => issue, :level => level)
UserScore.new(:collaboration => collaboration, :influence => influence, :skill => skill,
:activity => activity, :file => file, :issue => issue, :level => level)
end
@ -97,12 +255,17 @@ module UserScoreHelper
collaboration = calculate_collaboration_count(user)
influence = calculate_influence_count(user)
skill = calculate_skill_count(user)
activity = calculate_activity_count(user)
file = calculate_file(user)
issue = calculate_issue(user)
##activity = calculate_activity_count(user)
level = calculate_level(user)
user.user_score.update_attributes(:collaboration => collaboration, :influence => influence, :skill => skill,
:activity => activity, :file => file, :issue => issue, :level => level)
end
end

View File

@ -56,12 +56,49 @@ module WelcomeHelper
# # => 前7个项目为新课程后面三个是参与人数最多的
#
# Returns project&courses array
def find_miracle_course(sum=10, max_rate=7)
Project.active.visible.course_entities.
joins(:course_extra).
joins(:memberships).
group('members.project_id').
reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
def find_miracle_course(sum=10, max_rate=7, school_id)
if User.current.user_extensions.school.nil? and school_id.nil?
Project.active.visible.course_entities.
joins(:course_extra).
joins(:memberships).
group('members.project_id').
reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
# elseif school_id.nil?
else
if school_id.nil?
Project.active.visible.course_entities.
joins(:course_extra).
joins(:memberships).
where("#{Course.table_name}.school_id = ?", User.current.user_extensions.school.id).
group('members.project_id').
reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
else
if school_id == "0"
Project.active.visible.course_entities.
joins(:course_extra).
joins(:memberships).
group('members.project_id').
reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
else
Project.active.visible.course_entities.
joins(:course_extra).
joins(:memberships).
where("#{Course.table_name}.school_id = ?", school_id).
group('members.project_id').
reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
end
end
end
# else
# Project.active.visible.course_entities.
# joins(:course_extra).
# joins(:memberships).
# where("#{Course.table_name}.school_id = ?", school_id).
# group('members.project_id').
# reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
# end
# max = sum*(max_rate.to_f/10)
# c1 = find_new_course(sum).to_a.dup
# c2 = find_all_hot_course(sum).to_a.dup
@ -98,14 +135,14 @@ module WelcomeHelper
end
def find_all_hot_contest limit=10
# Contest.reorder("created_on DESC").all.take limit
mix_bid = []
mix_bid += Contest.reorder("created_on DESC").take(limit).to_a
mix_bid += Bid.visible.where('reward_type = ?', 2).reorder('bids.created_on desc').take(limit).to_a
mix_bid.sort do |older, newer|
newer.created_on - older.created_on
end
mix_bid.take limit
Contest.reorder("created_on DESC").all.take limit
# mix_bid = []
# mix_bid += Contest.reorder("created_on DESC").take(limit).to_a
# mix_bid += Bid.visible.where('reward_type = ?', 2).reorder('bids.created_on desc').take(limit).to_a
# mix_bid.sort do |older, newer|
# newer.created_on - older.created_on
# end
# mix_bid.take limit
end
def find_all_hot_softapplication limit=10

View File

@ -181,7 +181,7 @@ class Attachment < ActiveRecord::Base
end
def pack?
!!(self.filename =~ /\.(zip|rar|tar|gz)$/i)
!!(self.filename =~ /\.(zip|rar|tar|gz|exe|jar|7z|iso)$/i)
end
def thumbnailable?

View File

@ -29,6 +29,7 @@ class Bid < ActiveRecord::Base
has_many :courses, :through => :homework_for_courses, :source => :project
has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy
has_many :join_in_contests, :dependent => :destroy
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
# has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}"

View File

@ -12,6 +12,7 @@ class Contest < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
has_many :join_in_competitions, foreign_key: 'competition_id', :dependent => :destroy
has_many :join_in_contests, class_name: 'JoinInCompetition', foreign_key: 'competition_id', :dependent => :destroy
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
@ -24,7 +25,7 @@ class Contest < ActiveRecord::Base
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_format_of :budget, :with => /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/
# validates_format_of :budget, :with => /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/
validate :validate_user
after_create :act_as_activity

View File

@ -45,7 +45,8 @@ class Issue < ActiveRecord::Base
# added by fq
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# end
# end
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
acts_as_nested_set :scope => 'root_id', :dependent => :destroy

View File

@ -446,7 +446,9 @@ class Mailer < ActionMailer::Base
def self.deliver_mail(mail)
return false if mail.to.blank? && mail.cc.blank? && mail.bcc.blank?
super
Thread.new do
super
end
end
def self.method_missing(method, *args, &block)

View File

@ -1,4 +1,6 @@
class PraiseTread < ActiveRecord::Base
attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread
belongs_to :user
belongs_to :praise_tread_object, polymorphic: true
end

View File

@ -7,7 +7,7 @@ class Softapplication < ActiveRecord::Base
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :contesting_softapplications, :dependent => :destroy
belongs_to :user
belongs_to :contest
has_many :contests, :through => :contesting_softapplications
def add_jour(user, notes, reference_user_id = 0, options = {})
if options.count == 0
@ -21,6 +21,13 @@ class Softapplication < ActiveRecord::Base
def set_commit(commit)
self.update_attribute(:commit, commit)
end
def editable_by? usr
usr.admin? || self.user == usr
end
def destroyable_by? usr
self.user == usr || usr.admin?
end
end

View File

@ -96,7 +96,7 @@ class User < Principal
has_many :students_for_courses
has_many :courses, :through => :students_for_courses, :source => :project
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
has_many :file_commit, :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_tpye = 'Project' or container_type = 'Version'"
has_many :file_commit, :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Project' or container_type = 'Version'"
####
# added by bai
has_many :join_in_contests, :dependent => :destroy
@ -105,7 +105,7 @@ class User < Principal
has_many :wiki_contents, :foreign_key => 'author_id'
has_many :journals
has_many :messages, :foreign_key => 'author_id'
has_one :user_socre, :dependent => :destroy
has_one :user_score, :dependent => :destroy
# end
######added by nie

View File

@ -6,7 +6,7 @@
<tr>
<td><strong>应用软件:</strong></td>
<td>
<%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication)) %>
<%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication), :target => '_blank') %>
</td>
</tr></br>
</div>

View File

@ -1,5 +1,9 @@
<!-- added by bai -->
<h3><%=l(:label_settings)%></h3>
<p>
<td><%=l(:label_contest_settings)%></td>&nbsp;&nbsp;&nbsp;
</p>
<script type="text/javascript" language="javascript">
function show(id, id_t, label_reward, label_money, label_credit, label_content) {
var text = $('#' + id);

View File

@ -1,142 +1,14 @@
<!-- <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>
<span class="borad-title"><%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区</span>
<div class="content-title-top">
<%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
<div class="clearfix"></div>
<div id="file_buttons" class="nhidden">
<%#= link_to('上传文件', new_project_file_path(@project), :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
<%= link_to('上传文件', 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %>
<%= link_to('关联已有文件', 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
<%= link_to( l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %>
<%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
<div id="upload_file_div" class="relation_file_div hidden" >
<%= render :partial => 'new', locals: {project: @project}%>
</div>
@ -216,7 +88,9 @@ div.pagination{
<td class='description' colspan="5">
<div class="tags_area">
<% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%>
<div id='attach_<%=file.id%>' ><%#需要交由浏览器异步刷新或者一次连表查询n+1 查询问题搞不定%>
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%>
</div>
<div class="tags_gradint"></div>
</div>
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a></div>

View File

@ -2,7 +2,7 @@
<%= error_messages_for 'issue', 'time_entry' %>
<%= render :partial => 'conflict' if @conflict %>
<div class="box">
<% if @edit_allowed && !@allowed_statuses.empty? %>
<% if @edit_allowed || !@allowed_statuses.empty? %>
<fieldset class="tabular"><legend><%= l(:label_change_properties) %></legend>
<div id="all_attributes">
<%= render :partial => 'form', :locals => {:f => f} %>

View File

@ -9,6 +9,7 @@
<p>
<span>主办单位:</span>
<span class="footer_text_link"><%= link_to "国防科学技术大学并行与分布处理国家重点实验室","http://www.nudt.edu.cn/ArticleShow.asp?ID=47",:target=>"_blank"%></span>
<span class="footer_text_link"><%= link_to "计算机科学与技术系", "http://www.nudt.edu.cn/ArticleShow.asp?ID=41", :target => "_blank" %></span>
<span id="copyright">版权@2007~2014</span>
<span id="contact_us" class="footer_text_link"><%= link_to "联系我们","http://forge.trustie.net/projects/2/member",:target=>"_blank"%></span>
<span id="record"class="footer_text_link"><%= link_to "湘ICP备09019772","http://www.miibeian.gov.cn/"%></span>
@ -26,3 +27,18 @@
</div>
</div>
</div>
</div>
<div class="debug">
<%= debug(params) if Rails.env.development? %>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-46523987-1', 'trustie.net');
ga('send', 'pageview');
</script>
</div>

View File

@ -0,0 +1,20 @@
<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="250px"></td>
</tr>
<tr>
<td style="padding-left: 8px"><%=link_to request.host()+"/contests", :controller=>'contests', :action=>'index' %></td>
<td ><%=link_to l(:field_homepage), home_path %> >
<%=link_to l(:label_contest_innovate), :controller=>'contests', :action=>'index' %> >
<span>
<% contest = @softapplication.contests.first %><%= contest ? link_to(contest.name, show_contest_contest_path(contest)) : '尚未加入竞赛'%>
</span>
</td>
</tr>
</table>
</div>

View File

@ -10,6 +10,7 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "jquery.leanModal.min" %>
<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>

View File

@ -26,23 +26,23 @@
<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="250px">
<div class="project-search">
<%= form_tag(:controller => 'bids', :action => 'contest', :method => :get) do %>
<%= text_field_tag 'name', params[:name], :size => 20 %>
<%= hidden_field_tag 'reward_type', @bid.reward_type %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<% end %>
</div>
</td>
<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="250px">
<div class="project-search">
<%= form_tag(:controller => 'bids', :action => 'contest', :method => :get) do %>
<%= text_field_tag 'name', params[:name], :size => 20 %>
<%= hidden_field_tag 'reward_type', @bid.reward_type %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<% end %>
</div>
</td>
</tr>
<tr>
<td style="padding-left: 8px"><%=link_to request.host()+"/contest", :controller => 'bids', :action => 'contest' %></td>
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_contest_innovate), :controller => 'bids', :action => 'contest' %> >
<span><%= link_to @bid.name, bid_path %></span></td>
<td style="padding-left: 8px"><%=link_to request.host()+"/contest", :controller => 'bids', :action => 'contest' %></td>
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_contest_innovate), :controller => 'bids', :action => 'contest' %> >
<span><%= link_to @bid.name, bid_path %></span></td>
</tr>
</table>
</div>

View File

@ -33,7 +33,7 @@
<td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
<td rowspan="2" width="250px">
<div class="top-content-search" style="display:none">
<%= form_tag(:controller => 'projects', :action => "search", :method => :get) do %>
<%= form_tag(projects_search_path, :method => :get) do %>
<%= text_field_tag 'name', params[:name], :size => 20 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>

View File

@ -27,24 +27,24 @@
<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="250px">
<div class="project-search">
<%= form_tag({controller: 'contests', action: 'index'}, method: :get) do %>
<%= text_field_tag 'name', params[:name], :size => 20 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<% end %>
</div>
</td>
<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="250px">
<div class="project-search">
<%= form_tag({controller: 'contests', action: 'index'}, method: :get) do %>
<%= text_field_tag 'name', params[:name], :size => 20 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<% end %>
</div>
</td>
</tr>
<tr>
<td style="padding-left: 8px"><%=link_to request.host()+"/contests", :controller=>'contests', :action=>'index' %></td>
<td ><%=link_to l(:field_homepage), home_path %> >
<%=link_to l(:label_contest_innovate), :controller=>'contests', :action=>'index' %> >
<span><%= link_to @contest.name, show_contest_contest_path %></span>
</td>
<td style="padding-left: 8px"><%=link_to request.host()+"/contests", :controller=>'contests', :action=>'index' %></td>
<td ><%=link_to l(:field_homepage), home_path %> >
<%=link_to l(:label_contest_innovate), :controller=>'contests', :action=>'index' %> >
<span><%= link_to @contest.name, show_contest_contest_path %></span>
</td>
</tr>
</table>
</div>
@ -67,19 +67,24 @@
<% if User.current.login? %>
<tr colspan='3'>
<td valign="middle">
<span style="display:block; margin-left:20px; margin-bottom: 5px"><%= join_in_competition(@contest, User.current)%></span>
<!-- <span style="display:block; margin-left:20px; margin-bottom: 5px"><%= join_in_competition(@contest, User.current)%></span> -->
<span style="display:block; margin-left:20px;"><%= new_watcher_link(@contest, User.current) %></span>
</td>
</tr>
<% end %>
<!-- 竞赛的配置 -->
<% if User.current.logged? %>
<% if @contest.author.id == User.current.id %>
<% if (@contest.author.id == User.current.id) || User.current.admin? %>
<tr colspan='3'>
<td valign="middle">
<span style="display:block; margin-left:20px;"><%= link_to l(:label_contest_modify_settings), {:controller => 'contests', :action => 'settings', :id => @contest} %></span>
</td>
</tr>
<tr colspan='3'>
<td valign="middle">
<span style="display:block; margin-left:20px;"><%= link_to l(:label_contest_delete), {:controller => 'contests', :action => 'destroy_contest', :id => @contest}, data: { confirm: '你确定要删除该竞赛吗?' } %></span>
</td>
</tr>
<% end %>
<% end %>
</table>
@ -91,9 +96,9 @@
<div class="user_fans">
<table width="240" border="0">
<tr align="center" width="80px">
<td class="font_index">
<!-- <td class="font_index">
<%=link_to "#{@contest.join_in_competitions.count}",:controller => "contests",:action => "show_participator" %>
</td>
</td> -->
<td class="font_index">
<%=link_to "#{@contest.projects.where('is_public=1').count}", :controller => 'contests', :action => 'show_project' %>
</td>
@ -103,7 +108,7 @@
</tr>
<tr class="font_aram">
<td align="center" width="70px"> <%= l(:label_participate) %></td>
<!-- <td align="center" width="70px"> <%= l(:label_participate) %></td> -->
<td align="center" width="70px"> <%= l(:label_contest_project) %></td>
<td align="center" width="70px"> <%= l(:label_contest_application) %></td>
@ -145,13 +150,13 @@
<div class="created_on_project">
<strong style="color: #068d9c"><%= l(:label_create_time) %></strong><%= format_time(@contest.created_on) %>
</div>
<% if User.current.logged? %>
<!-- <% if User.current.logged? %>
<% if @contest.author.id == User.current.id %>
<div>
<%= link_to '删除', {:controller => 'contests', :action => 'destroy_contest', :id => @contest}, data: { confirm: '你确定要删除该竞赛吗?' } %>
</div>
<% end %>
<% end %>
<% end %> -->
</div>
<div class="user_underline"></div>
</div>
@ -199,7 +204,7 @@
<div class="user_underline"></div>
<!--参与者-->
<div class="user_fans">
<!-- <div class="user_fans">
<div class="font_title_left">
<strong><%= l(:label_participate) %></strong>
<% if show_more_participate?(@contest) %>
@ -216,7 +221,7 @@
</tr>
</table>
</div>
</div>
</div> -->
<div class="user_underline"></div>
</div>

View File

@ -30,7 +30,7 @@
<td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
<td rowspan="2" width="250px">
<div class="top-content-search">
<%= form_tag(:controller => 'projects', :action => "search", :method => :get) do %>
<%= form_tag(projects_search_path, :method => :get) do %>
<%= text_field_tag 'name', params[:name], :size => 20 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>

View File

@ -1,3 +1,16 @@
<script type="text/javascript">
$(document).ready(
function(){
$("#province").attr("href", "#WOpenWindow")
$("#province").leanModal({top: 100, closeButton: ".modal_close"});
}
);
</script>
<script type="text/javascript">
function get_options(value){
$.ajax({
@ -5,13 +18,18 @@
url :'/school/get_options/'+encodeURIComponent(value),
data :'text',
success: function(data){
$("#occupation").html(data);
$("#schoollist").html(data);
}
}
)
}
</script>
@ -88,12 +106,50 @@
-->
<!-- added by Wen -->
<p style="width:357px;padding-left: 26px;">
<%= l(:field_occupation) %>&nbsp;<span class="required">*</span><%= select_tag "province", options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province), :onchange => "get_options(this.value)" %>
<%= select_tag "occupation" %>
<p style="width:357px;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 />
<!--<%= 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)" %>
<input id="occupation" name="occupation" type="hidden" />
<input id="occupation_name" type="text" readonly />
<% end %>
<!-- <input id="occupation" readonly />-->
</p>
<div id="WOpenWindow">
<a class="modal_close" href="#"></a>
<h2>学校列表</h2>
<div class="content" style="font-size: 13px">
<ul id="schoollist" class="school_list">
</ul>
</div>
</div>
<script type="text/javascript">
function test(id, name){
//$("#occupation").html("<option value='"+id+"'>"+name+"</option>");
$("#occupation").val(id);
$("#occupation_name").val(name);
$("#lean_overlay").hide();
$("#WOpenWindow").hide();
}
</script>
<!-- added by bai 增加了地区 -->

View File

@ -16,7 +16,10 @@
<%= content_tag('span', "#{l(:label_institution_name)}:", :class => "course-font")%>
<% @admin = @project.project_infos%>
<%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%>
<%= @admin.first.user.user_extensions.occupation %>
<!-- <%= @admin.first.user.user_extensions.occupation %> -->
<% unless @project.course_extra.school.nil? %>
<%= @project.course_extra.school.name %>
<% end %>
<% end %>
</p>
<p >
@ -45,6 +48,15 @@
<%= content_tag('span', link_to("#{@project.members.count}", member_project_path(@project)), :class => "info") %>
<%= content_tag('span', l(:label_x_member, :count => @project.members.count)) %>
</p>
<!--gcm-->
<p class="stats">
<%= content_tag('span', link_to("#{@project_activity_count[@project.id]}", member_project_path(@project)), :class => "info") %>
<%= content_tag('span', l(:label_x_activity, :count => @project_activity_count[@project.id])) %>
</p>
<!--gcm-->
<div class="buttons_for_course" style="margin-top:30px;margin-left:144px">
<span class="info"></span>
<% if @project.project_type==Project::ProjectType_course %>

View File

@ -284,13 +284,7 @@
<!--added by Wen -->
<p style="margin-left:-76px;">
<strong><%=l(:label_new_course_school)%></strong><span class="required">*</span>&nbsp;&nbsp;&nbsp;
<%= select_tag "province", options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province), :onclick => "get_options(this.value)" %>
<%= select_tag "occupation" %>
</p>
<!-- end -->

View File

@ -3,7 +3,7 @@
<% end %>
<div class="top-content">
<%= form_tag(:controller => 'projects', :action => 'search', :method => :get) do %>
<%= form_tag(projects_search_path, :method => :get) do %>
<table width="940px">
<tr>
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_practice) %></td>

View File

@ -3,7 +3,7 @@
<% end %>
<div class="top-content">
<%= form_tag(:controller => 'projects', :action => "search", :method => :get) do %>
<%= form_tag(projects_search_path, :method => :get) do %>
<table width="940px">
<tr>
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_project_deposit) %></td>

View File

@ -2,7 +2,7 @@
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
<% end %>
<div class="top-content">
<%= form_tag(:controller => 'projects', :action => "search", :method => :get) do %>
<%= form_tag(projects_search_path, :method => :get) do %>
<% if params[:project_type] == "1" %>
<table width="940px">
<tr>

View File

@ -0,0 +1,66 @@
<% port = ":3000" if Rails.env.development? %>
<script type="text/javascript">
function get_school(value){
$.ajax({
type :"POST",
url :'/school/get_schoollist/'+encodeURIComponent(value),
data :'text',
success: function(data){
$("#schoollist").html(data);
//$("#schoollist").html(data);
}
}
)
}
</script>
<script type="text/javascript">
function test(id){
location.href = encodeURI('http://course.trustie.net<%=port%>?school_id='+id);
}
</script>
<script type="text/javascript">
function ssearch(){
//alert($("#key_word").val());
value = $("#key_word").val();
province = $("#province").val();
//alert(province);
$.ajax({
type :"POST",
url :'/school/search_school/?key_word='+encodeURIComponent(value)+'&province='+province,
data :'text',
success: function(data){
$("#schoollist").html(data);
//$("#schoollist").html(data);
}
})
}
</script>
<div>
<p>
<a href="http://course.trustie.net<%=port%>?school_id=0">全部学校</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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: 50%; float: left"><input type="text" id="key_word" name="key_word" />
<input type="button" class="enterprise" value="搜索" onclick="ssearch()"></li>
</ul>
</div>
<div>
<ul id="schoollist" style="line-height: 25px">
</ul>
</div>

View File

@ -0,0 +1 @@
<input type="file" />

View File

@ -1,64 +1,70 @@
<%= form_for(@softapplication) do |f| %>
<%= form_for(softapplication) do |f| %>
<% if @softapplication.errors.any? %>
<% if softapplication.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@softapplication.errors.count, "error") %> prohibited this softapplication from being saved:</h2>
<h2><%= pluralize(softapplication.errors.count, "error") %> prohibited this softapplication from being saved:</h2>
<ul>
<% @softapplication.errors.full_messages.each do |msg| %>
<% softapplication.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<tr style="width:700px; margin-left: -10px">
<td><%= l(:label_softapplication_name) %></td>
<td style="require, color: #bb0000"> * </td>:
<td ><%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %></td>
<td><%= l(:label_softapplication_name_condition)%></td>
</tr></ br><br /><br />
<fieldset class="contes-new-box">
<tr style="width:700px; margin-left: -10px">
<span><%= l(:label_softapplication_name) %></span>
<span class="contest-star"> * </span>: <td ><%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %></td>
<span><%= l(:label_softapplication_name_condition)%></span>
</tr></ br>
<br />
<br />
<tr style="width:800px;">
<span><%= l(:label_softapplication_version_available) %></span>
<span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %></td>
<tr style="width:800px;">
<td><%= l(:label_softapplication_version_available) %></td>
<td style="require, color: #bb0000"> * </td>:
<td style="width: 100px"><%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %></td>
</tr></ br>
<br />
<br />
<tr style="width:800px;">
<span><%= l(:label_softapplication_type) %></span>
</tr></ br><br /><br />
<span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %></td>
<tr style="width:800px;">
<td><%= l(:label_softapplication_type) %></td>
<td style="require, color: #bb0000"> * </td>:
<td style="width: 100px"><%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %></td>
</tr></ br>
<br />
<br />
<tr style="width:800px;">
<span><%= l(:label_softapplication_description) %></span>
<span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %></td>
</tr></ br><br /><br />
</tr></ br>
<br />
<br />
<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:400px;" %></td>
<tr style="width:800px;">
<td><%= l(:label_softapplication_description) %></td>
<td style="require, color: #bb0000"> * </td>:
<td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %></td>
</tr></ br><br /><br />
<fieldset style="width: 600px">
<div>
<%=l(:label_upload_softapplication_packets)%>&nbsp;:<br />
<p id="put-bid-form-partial">
<%= render :partial => 'attachments/form' %>
</p>
</div>
</fieldset></tr></ br></ br></ br></ br></ br>
<fieldset style="width: 600px">
<div>
<span><%=l(:label_upload_softapplication_photo)%>&nbsp;:</span>(<span style="font-size: 3px"><%=l(:label_upload_softapplication_photo_condition)%></span>)<br />
<p id="put-bid-form-partial">
<%= render :partial => 'attachments/form' %>
</p>
</div>
</fieldset>
</tr></ br>
<br />
<br />
<fieldset style="width: 500px">
<legend>上传应用软件包和应用截图</legend>
<%= render_flash_messages %>
<p id="put-bid-form-partial">
<%= render :partial => 'attachments/form' %>
</p>
<p style="font-size: 10px">1、<%=l(:label_upload_softapplication_packets_mustpacketed)%><br>2、<%=l(:label_upload_softapplication_photo_condition)%></p>
<p style="font-size: 10px; color: red"><%=l(:label_updated_caution)%></p>
</fieldset>
</fieldset></br>
<div class="align-center"><%= submit_tag l(:button_create), :onclick => "return true" %></div>
<% end %>

View File

@ -1,6 +1,8 @@
<h1>Editing softapplication</h1>
<h3 style="font-size: 18px"><%= l(:label_edit_softapplication)%></h3>
<%= render partial: 'form', locals:{softapplication: @softapplication} %>
<!-- <%= link_to 'Show', @softapplication %>
<%= link_to 'Back', softapplications_path %> -->
<%= render 'form' %>
<%= link_to 'Show', @softapplication %> |
<%= link_to 'Back', softapplications_path %>

View File

@ -1,4 +1,4 @@
<h1>Listing softapplications</h1>
<h1>参赛应用</h1>
<table>
<tr>

View File

@ -1,76 +1,5 @@
<h3 style="font-size: 18px"><%= l(:label_release_softapplication)%></h3>
<%= render partial: 'form', locals:{softapplication: @softapplication} %>
<div >
<%= form_for Softapplication.new, :url => {:controller => 'softapplications', :action => 'create'}, :update => "bidding_project_list", :complete => '$("#put-bid-form").hide();', :html => {:multipart => true, :id => 'add_homework_form'} do |f| %>
<fieldset class="contes-new-box">
<!-- <legend>
<%= l(:label_attachment_plural) %>
</legend> -->
<tr style="width:700px; margin-left: -10px">
<span><%= l(:label_softapplication_name) %></span>
<span class="contest-star"> * </span>: <td ><%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %></td>
<span><%= l(:label_softapplication_name_condition)%></span>
</tr></ br>
<br />
<br />
<tr style="width:800px;">
<span><%= l(:label_softapplication_version_available) %></span>
<span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %></td>
</tr></ br>
<br />
<br />
<tr style="width:800px;">
<span><%= l(:label_softapplication_type) %></span>
<span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %></td>
</tr></ br>
<br />
<br />
<tr style="width:800px;">
<span><%= l(:label_softapplication_description) %></span>
<span class="contest-star"> * </span>: <td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %></td>
</tr></ br>
<br />
<br />
<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:400px;" %></td>
</tr></ br>
<br />
<br />
<fieldset style="width: 500px">
<legend>上传应用软件包和应用截图</legend>
<%= render_flash_messages %>
<p id="put-bid-form-partial">
<%= render :partial => 'attachments/form' %>
</p>
<p style="font-size: 10px">(<%=l(:label_upload_softapplication_photo_condition)%>)</p>
</fieldset>
</fieldset></br>
<div class="align-center"><%= submit_tag l(:button_create), :onclick => "return true" %></div>
<script type="text/javascript">
function j_submit () {
alert('start')
var submit_homework = function(){
$('#add_homework_form').clone().attr('action', '<%= url_for({:controller => "softapplications", :action => "create"})+".js" %>').ajaxSubmit()
};
alert('stop')
$.globalEval(submit_homework());
return false;
}
</script>
</div>
<% end %>
</div>

View File

@ -1,3 +1,4 @@
<%=render :partial => 'layouts/base_softapplication_top_content'%>
<style>
.softapplication-img .soft-application {
float: left;
@ -10,7 +11,7 @@
<p id="notice"><%= notice %></p>
<!-- <%= image_tag(url_to_avatar(@user), :class => "avatar2") %> -->
<div style="height: 130px">
<div style="height: auto; padding-bottom: 10px">
<tr>
<td colspan="2" valign="top" width="320" >
</td>
@ -18,27 +19,33 @@
<table width="100%" border="0">
<tr style="font-size: 18px">
<td colspan="2" valign="top"><strong><%= @softapplication.name %></strong></td>
<td style="font-size: 15px; padding-left: 0px">
<%= link_to '删除', softapplication_path(@softapplication), method: :delete, data: { confirm: '您确定要删除吗?' } if @softapplication.destroyable_by? User.current %>&nbsp;
<%= link_to '编辑', edit_softapplication_path(@softapplication), method: :get if @softapplication.destroyable_by? User.current %>
</td>
</tr>
<tr>
<td>所属类别:<%= @softapplication.app_type_name %></td>
<td>发布时间:<%=format_time @softapplication.created_at %></td>
<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>
</tr>
<tr>
<td>发布人员:<%= @softapplication.user.name %></td>
<td style="padding-left: 40px">发布人员:<%= @softapplication.user.name %></td>
<td>系统支持:<%= @softapplication.android_min_version_available %></td>
</tr>
<tr>
<td>
<td style="padding-left: 40px">
<span>应用下载:</span>
<span><% options = {:author => true, :deletable => @softapplication.user.eql?(User.current) } %>
<%= render :partial => 'attachments/app_link', :locals => {:attachments => @app_items, :options => options} %></span>
<span>
<% options = {:author => true, :deletable => @softapplication.user.eql?(User.current) } %><%= render :partial => 'attachments/app_link', :locals => {:attachments => @app_items, :options => options} %>
</span>
</td>
<td>开发人员:<%= @softapplication.application_developers %></td>
</tr>
<tr>
<td>平均评分: <%= rating_for @softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %></td>
<td></td>
<td style="padding-left: 40px">平均评分: <%= rating_for @softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %></td>
<td>发布时间:<%=format_time @softapplication.created_at %></td>
</tr>
@ -48,9 +55,9 @@
</div>
<div class="underline-contests_one"></div>
<div style="height: 60px">
<div style="height: auto; padding-bottom: 10px">
<strong><div style="font-size: 15px">应用简介:</div></strong>
<div><%= @softapplication.description %></div>
<div><%= @softapplication.description.truncate(150, omission: '...') %></div>
</div>
<div class="underline-contests_one"></div>

View File

@ -23,7 +23,7 @@
<%= form_for "tag_for_save",:remote=>true,:url=>tag_path,
:update => "tags_show",
:complete => '$("#put-tag-form-issue").hide();' do |f| %>
<%= f.text_field :name ,:id => "name-issue",:size=>"30",:require=>true,:maxlength => 25,:minlength=>1 %>
<%= f.text_field :name ,:id => "name-issue",:size=>"30",:require=>true,:maxlength => Setting.tags_max_length,:minlength=>1 %>
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
<%= f.submit l(:button_project_tags_add),:class => "small"%>

View File

@ -1,6 +1,30 @@
<h3>test</h3>
<%= debug request %>
<% users = User.all%>
<table>
<tr>
<th>name</th><th>C</th><th>I</th><th>S</th><th>filecount</th><th>issuecount</th><th>level</th>
</tr>
<% users.each do |user| %>
<tr>
<td><%= user.lastname %><%= user.firstname %></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_level(user) %></td>
-->
<td><%= user.changesets.count %></td>
</tr>
<% end %>
</table>
<hr/>
<%= request.host().class %>
<hr/>

View File

@ -1,7 +1,7 @@
<% if User.current.id == @user.id%>
<%= show_activity @state%>
<%= form_tag(:controller => 'users', :action => "show") do %>
<div class="user-search-block" style="float:right;margin-top:-55px">
<div class="user-search-block hidden" style="float:right;margin-top:-55px">
<table width="100%" valign="center">
<tr>
<td align="right">

View File

@ -2,7 +2,7 @@
$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
$('#put-tag-form-issue').hide();
//$('#put-tag-form-issue').hide();
$('#name-issue').val("");
<% elsif @obj_flag == '6'%>
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
@ -15,6 +15,6 @@ $('#name-issue').val("");
$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
$('#put-tag-form #name').val("");
$('#put-tag-form').hide();
//$('#put-tag-form').hide();
<% end %>

View File

@ -98,7 +98,11 @@
</div>
<div class="main-content-bar">
<!--文字-->
<div style="float: left">
<%= image_tag '/images/transparent.png', size: "75x75" %>
</div>
<div class="welcome_left" >
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_contest) %></span> <span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_contest_description) %></span>
</div>
<!--网站状态-->
@ -138,22 +142,23 @@
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :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[6]) %>
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
<div class="avatar-4"; style="float: left; margin-top: 7px">
<%= image_tag('/images/039.gif')%>
<%= image_tag('/images/contest1.png')%>
</div>
<div style="float: left; margin-left: -8px; margin-top: 5px; width: 380px;">
<%= link_to(contest.name, contest.event_url, :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %>
<div style="float: left; margin-left: 12px; margin-top: 10px; margin-bottom: -4px; width: 380px;">
<!-- <%= link_to(contest.name, contest.event_url, :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %> -->
<%= link_to(contest.name, show_contest_contest_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %>
</div>
<div class='text_nowrap' style="float: left;margin:5px; margin-left: -8px; width: 380px;">
<div class='text_nowrap' style="float: left;margin:5px; margin-left: 12px; margin-bottom: 2px; width: 380px;">
<span class='font_lighter' title =<%=contest.description.to_s%>><%=contest.description.truncate(50, omission: '...')%></span>
</div><br />
<div style="padding-left: 36px; clear: left;">
<div style="padding-left: 57px; clear: left;">
<span class="font_lighter">发布时间:<%=format_time contest.created_on %></span>
</div>
@ -204,18 +209,18 @@
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
<div class="avatar-4"; style="float: left; margin-top: 7px">
<%= image_tag('/images/009.gif')%>
<%= image_tag('/images/app1.png')%>
</div>
<div style="float: left; margin-left: -8px; margin-top: 5px; width: 380px;">
<div style="float: left; margin-left: 10px; margin-top: 7px;margin-bottom: -2px; width: 380px;">
<%= link_to(softapplication.name, softapplication_path(softapplication.id), :class => "d-g-blue d-p-project-name", :title => "#{softapplication.name}", :target => "_blank") %>
</div>
<div class='text_nowrap' style="float: left;margin:5px; margin-left: -8px; width: 380px;">
<div class='text_nowrap' style="float: left;margin:5px; margin-left: 10px; margin-bottom:1px; width: 380px;">
<span class='font_lighter' title =<%=softapplication.description.to_s%>><%=softapplication.description.truncate(50, omission: '...')%></span>
</div><br />
<div style="padding-left: 36px; clear: left;">
<div style="padding-left: 55px; clear: left;">
<span class="font_lighter">发布时间:<%=format_time softapplication.created_at %></span>
</div>

View File

@ -1,223 +1,270 @@
<%= stylesheet_link_tag 'welcome' %>
<script type="text/javascript" language="javascript">
function clearInfo(id, content) {
var text = $('#' + id);
if (text.val() == content) {
$('#' + id).val('');
}
}
$(function(){
$("#main").find("a").attr("target", "_blank");
});
function showInfo(id, content) {
var text = $('#' + id);
if (text.val() == '') {
$('#' + id).val(content);
}
}
// 给主页用户弹新页面
$(document).ready(function($) {
$("#loggedas").find("a").attr("target", "_blank");
//$("#content .tabs_new~ .pagination").find("a").removeAttr("target");
});
</script>
<script type="text/javascript">
(function (){
window.onload = function(){
function fixedBar(id, options){
var ele = document.getElementById(id);
if(!ele) return;
if(/msie (\d+\.\d+)/i.test(navigator.userAgent)){
var pageHeight=window.innerHeight;
var d=document;
if(typeof pageHeight!="number"){
if(document.compatMode=="CSS1Compat"){
pageHeight=document.documentElement.clientHeight;
}else{
pageHeight=document.body.clientHeight;
}
}
var ieScrollTop=window.pageYOffset || d.documentElement.scrollTop || d.body.scrollTop;
if(options.addclass) ele.className = options.addclass;
ele.style.position= 'absolute';
if(options.show){
ele.style.top = 0 + "px";
ele.style.display= 'block';
}
window.attachEvent('onscroll' , function (){
var ieScrollTop=window.pageYOffset || d.documentElement.scrollTop || d.body.scrollTop;
ele.style.top = 0 + "px";
if(options.autoHidden){
if(ieScrollTop==0){
ele.style.display="none";
}else{
ele.style.display="block";
}
}
});
}else{
var ele = document.getElementById(id);
if(typeof pageHeight!="number"){
if(document.compatMode=="CSS1Compat"){
pageHeight=document.documentElement.clientHeight;
}else{
pageHeight=document.body.clientHeight;
}
}
if(options.show) ele.style.display= 'block';
ele.style.top = 0 +'px';
window.addEventListener('scroll',function (){
if(options.autoHidden){
if(baidu.page.getScrollTop()==0){
ele.style.display="none";
}else{
ele.style.display="block";
}
}
},false);
}
}
fixedBar('backTopBtn' , {autoHidden: true, top : 186});
fixedBar('identifier-pannel' , {autoHidden: false , top : 956 , show : true});
}
})();
</script>
<div class='top_bar'>
<div id="identifier-pannel" style="display:none">
<%= image_tag '/images/qrweixin.jpg', size: '150x150', alt: 'trustie', class: "weixin" %>
<div class="weixin-content">微信扫码</div>
</div>
<div class="main-content-bar">
<div class="welcome_left" >
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> </span><span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span>
</div>
<div class="search-bar">
<%= render :partial => "search_project", :locals => {:project_type => Project::ProjectType_course}%>
</div>
<div style="clear: both;"></div>
</div>
</div>
<div style="clear:both"></div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<h3><strong>新开课程</strong></h3>
<span><%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1} %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_miracle_course(10, 7).map do |project| %>
<li class='<%= cycle("odd", "even") %>' title=<%=project.description.to_s%>>
<div class='avatar'>
<%= image_tag(get_course_avatar(project), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item text_nowrap' >
[<%= get_course_term project %>]
<%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
(<%= link_to "#{studentCount(project)}人", project_member_path(project, :role => 2) ,:course =>'1' %>)
<% files_count = (project.attachments.count.to_i+Version.joins(:project).where("projects.id=#{project.id}").count.to_i).to_s %>
(<%=link_to "#{files_count}份", project_files_path(project) %>资料)
</div>
<div class='desc_item' >
<span class=''>
<% course = Course.find_by_extra(project.identifier) %>
<%= course.teacher.user_extensions.occupation.try(:gsub, /(.+)$/, '\1:') %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %>
<%#=course.try(:teacher).try(:name)%>
</span>
</div>
<!-- <div class='desc_item' style="">
<span class='font_lighter' title=<%#=project.description.to_s%>><%#=project.description.truncate(25, omission: '...')%></span>
</div> -->
<div class='join_course_link'>
<% if !course_endTime_timeout?(project)%>
<div >
<%= join_in_course(project, User.current)%>
</div>
<% end %>
</div>
</li>
<% end; reset_cycle %>
</ul>
</div>
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject hidden" style="float: right;">
<div class="web_status">
<h3 style="margin-left: 5px; color: #e8770d;"><strong>当前网站状态</strong></h3>
<table>
<tbody>
<tr>
<td>课程总量: <%#=@course.count%></td>
<td>教师数量: <%#=@teacher.count%></td>
</tr>
<tr>
<td>用户总量: <%#=User.count%></td>
<td>学生数量: <%#=@student.count%></td>
</tr>
<tr>
<td>资源总量: <%#=Attachment.count%></td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<div class='hidden' style="text-align: right; padding-right: 20px">
<%= link_to "意见反馈" , suggestion_send_path, {:class => 'orangeButton', :style => "color: #EEEEEE" }%>
</div>
</div>
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
<h3 style="padding-bottom:px ;margin-left: 5px; color: #e8770d;">
<strong>问题和反馈动态</strong>
<%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
<%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
</h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", forums_path %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_new_forum_topics(10).each do |topic|%>
<li class="message-brief-intro" style="min-height: 65px; line-height:2em; ">
<div style="display: inline-block; width: 100%;">
<span style="color:gray; display: inline-block; margin-bottom:6px; background: url('/images/list-icon.png') no-repeat scroll ;background-position: left center;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %>
</span>
<br>
<span style="margin-left: 24px; color: rgb(172, 174, 177); white-space: nowrap; font-size 9pt !important;;"><%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前</span>
<span style="margin-left: 8px; margin-bottom: 0px; color: rgb(172, 174, 177) !important; white-space: nowrap;">
由&nbsp;<%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);" %>&nbsp;发表
</span>
<span style="float: right; color: rgb(172, 174, 177); white-space: nowrap; font-size 9pt !important;;">回复(<%= link_to (topic.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url %>)</span>
</div>
</li>
<% end %>
</ul>
</div>
</div>
<div class="clearfix"></div>
<div style="width:100%;">
<div style="width:600px;margin:0px auto;margin-top:80px;">
<table style="width:600px;font-size:15px; color: #e8770d;">
<tr>
<td><strong>当前网站状态</strong></td>
<td>活跃课程: <%=@courseCount%></td>
<td>高校: 2个</td>
<td>教师: <%=@teacherCount%> 名</td>
<td>学生: <%=@studentCount%> 名<td>
</tr>
</table>
</div>
<%= stylesheet_link_tag 'welcome' %>
<script type="text/javascript" language="javascript">
function clearInfo(id, content) {
var text = $('#' + id);
if (text.val() == content) {
$('#' + id).val('');
}
}
$(function(){
$("#main").find("a").attr("target", "_blank");
});
function showInfo(id, content) {
var text = $('#' + id);
if (text.val() == '') {
$('#' + id).val(content);
}
}
// 给主页用户弹新页面
$(document).ready(function($) {
$("#loggedas").find("a").attr("target", "_blank");
//$("#content .tabs_new~ .pagination").find("a").removeAttr("target");
});
</script>
<script type="text/javascript">
(function (){
window.onload = function(){
function fixedBar(id, options){
var ele = document.getElementById(id);
if(!ele) return;
if(/msie (\d+\.\d+)/i.test(navigator.userAgent)){
var pageHeight=window.innerHeight;
var d=document;
if(typeof pageHeight!="number"){
if(document.compatMode=="CSS1Compat"){
pageHeight=document.documentElement.clientHeight;
}else{
pageHeight=document.body.clientHeight;
}
}
var ieScrollTop=window.pageYOffset || d.documentElement.scrollTop || d.body.scrollTop;
if(options.addclass) ele.className = options.addclass;
ele.style.position= 'absolute';
if(options.show){
ele.style.top = 0 + "px";
ele.style.display= 'block';
}
window.attachEvent('onscroll' , function (){
var ieScrollTop=window.pageYOffset || d.documentElement.scrollTop || d.body.scrollTop;
ele.style.top = 0 + "px";
if(options.autoHidden){
if(ieScrollTop==0){
ele.style.display="none";
}else{
ele.style.display="block";
}
}
});
}else{
var ele = document.getElementById(id);
if(typeof pageHeight!="number"){
if(document.compatMode=="CSS1Compat"){
pageHeight=document.documentElement.clientHeight;
}else{
pageHeight=document.body.clientHeight;
}
}
if(options.show) ele.style.display= 'block';
ele.style.top = 0 +'px';
window.addEventListener('scroll',function (){
if(options.autoHidden){
if(baidu.page.getScrollTop()==0){
ele.style.display="none";
}else{
ele.style.display="block";
}
}
},false);
}
}
fixedBar('backTopBtn' , {autoHidden: true, top : 186});
fixedBar('identifier-pannel' , {autoHidden: false , top : 956 , show : true});
}
})();
</script>
<div class='top_bar'>
<div id="identifier-pannel" style="display:none">
<%= image_tag '/images/qrweixin.jpg', size: '150x150', alt: 'trustie', class: "weixin" %>
<div class="weixin-content">微信扫码</div>
</div>
<div class="main-content-bar">
<div style="float: left">
<% if params[:school_id].nil? and User.current.user_extensions.school.nil? %>
<%= image_tag '/images/transparent.png', size: "75x75" %>
<% else%>
<% if params[:school_id] == "0" %>
<%= image_tag '/images/transparent.png', size: "75x75" %>
<% else %>
<% if params[:school_id].nil? %>
<% if School.find(User.current.user_extensions.school.id).logo_link.nil? %>
<%= image_tag '/images/transparent.png', size: "75x75" %>
<% else %>
<%= image_tag(School.find(User.current.user_extensions.school.id).logo_link, size: "75x75") %>
<% end %>
<br />
<% else %>
<%= image_tag(School.find(params[:school_id]).logo_link, size: "75x75") %>
<br />
<% end %>
<% end %>
<% end %>
</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? %>
<%= School.find(User.current.user_extensions.school.id).name %>
<br />
<% else %>
<%= School.find(params[:school_id]).name %>
<br />
<% end %>
<% end %>
<% 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>
<% else %>
<% if params[:school_id] == "0" %>
<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>
<div style="clear:both"></div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<h3><strong>新开课程</strong></h3>
<span><%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :school_id => params[:school_id]} %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_miracle_course(10, 7,params[:school_id]).map do |project| %>
<li class='<%= cycle("odd", "even") %>' title=<%=project.description.to_s%>>
<div class='avatar'>
<%= image_tag(get_course_avatar(project), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div class='desc_item text_nowrap' >
[<%= get_course_term project %>]
<%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
(<%= link_to "#{studentCount(project)}人", project_member_path(project, :role => 2) ,:course =>'1' %>)
<% files_count = (project.attachments.count.to_i+Version.joins(:project).where("projects.id=#{project.id}").count.to_i).to_s %>
(<%=link_to "#{files_count}份", project_files_path(project) %>资料)
</div>
<div class='desc_item' >
<span class=''>
<% course = Course.find_by_extra(project.identifier) %>
<%= course.school.name.try(:gsub, /(.+)$/, '\1:') %>
</span>
<span class='font_bolder'>
<%= link_to(course.try(:teacher).try(:name), user_path(course.teacher)) %>
<%#=course.try(:teacher).try(:name)%>
</span>
</div>
<!-- <div class='desc_item' style="">
<span class='font_lighter' title=<%#=project.description.to_s%>><%#=project.description.truncate(25, omission: '...')%></span>
</div> -->
<div class='join_course_link'>
<% if !course_endTime_timeout?(project)%>
<div >
<%= join_in_course(project, User.current)%>
</div>
<% end %>
</div>
</li>
<% end; reset_cycle %>
</ul>
</div>
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject hidden" style="float: right;">
<div class="web_status">
<h3 style="margin-left: 5px; color: #e8770d;"><strong>当前网站状态</strong></h3>
<table>
<tbody>
<tr>
<td>课程总量: <%#=@course.count%></td>
<td>教师数量: <%#=@teacher.count%></td>
</tr>
<tr>
<td>用户总量: <%#=User.count%></td>
<td>学生数量: <%#=@student.count%></td>
</tr>
<tr>
<td>资源总量: <%#=Attachment.count%></td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<div class='hidden' style="text-align: right; padding-right: 20px">
<%= link_to "意见反馈" , suggestion_send_path, {:class => 'orangeButton', :style => "color: #EEEEEE" }%>
</div>
</div>
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
<h3 style="padding-bottom:px ;margin-left: 5px; color: #e8770d;">
<strong>问题和反馈动态</strong>
<%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
<%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
</h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", forums_path %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_new_forum_topics(10).each do |topic|%>
<li class="message-brief-intro" style="min-height: 65px; line-height:2em; ">
<div style="display: inline-block; width: 100%;">
<span style="color:gray; display: inline-block; margin-bottom:6px; background: url('/images/list-icon.png') no-repeat scroll ;background-position: left center;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %>
</span>
<br>
<span style="margin-left: 24px; color: rgb(172, 174, 177); white-space: nowrap; font-size 9pt !important;;"><%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前</span>
<span style="margin-left: 8px; margin-bottom: 0px; color: rgb(172, 174, 177) !important; white-space: nowrap;">
由&nbsp;<%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);" %>&nbsp;发表
</span>
<span style="float: right; color: rgb(172, 174, 177); white-space: nowrap; font-size 9pt !important;;">回复(<%= link_to (topic.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url %>)</span>
</div>
</li>
<% end %>
</ul>
</div>
</div>
<div class="clearfix"></div>
<div class="hidden" style="width:100%;">
<div style="width:600px;margin:0px auto;margin-top:80px;">
<table style="width:600px;font-size:15px; color: #e8770d;">
<tr>
<td><strong>当前网站状态</strong></td>
<td>活跃课程: <%=@courseCount%></td>
<td>高校: 2个</td>
<td>教师: <%=@teacherCount%> 名</td>
<td>学生: <%=@studentCount%> 名<td>
</tr>
</table>
</div>
</div>

View File

@ -97,8 +97,11 @@
<div class="weixin-content">微信扫码</div>
</div>
<div class="main-content-bar">
<div style="float: left">
<%= image_tag '/images/transparent.png', size: "75x75" %>
</div>
<div class="welcome_left" >
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_project) %></span> <span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_project_description) %></span>
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_project) %></span> <span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_project_description) %></span>
</div>
<div class="search-bar">
<%= render :partial => "search_project", :locals => {:project_type => 0}%>
@ -243,14 +246,14 @@
<div class="clearfix"></div>
<div style="width:100%;">
<div style="width:600px;margin:0px auto;margin-top:80px;">
<div class="hidden" style="width:100%;">
<div style="width:600px;margin:0px auto;margin-top:180px;">
<table style="width:600px;font-size:15px; color: gray;">
<tr>
<td><strong>当前网站状态</strong></td>
<td>活跃项目:<%=@projectCount%>个</td>
<td>私有项目: <%=@projectHidenCount%>个</td>
<td>开发者:<%=@developerCount%>个 </td>
<td>开发者:<%=@allUsercount%>个 </td>
</tr>
</table>
</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,6 +1547,7 @@ 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
@ -1667,7 +1668,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: 新建作业
@ -1715,6 +1716,11 @@ zh:
zero: 份资料
one: 份资料
other: 份资料
#added by gcm
label_x_activity:
zero: 个动态
one: 个动态
other: 个动态
@ -1759,6 +1765,10 @@ zh:
label_has_been: 已经被
label_course_userd_by: 个课程引用
label_school_all: 中国高校
role_of_course: 课程角色
label_student: 学生
@ -1819,7 +1829,8 @@ zh:
label_sumbit_empty: 搜索内容不能为空
#add by linchun (竞赛相关)
label_upload_files: 上传文件
label_upload_files: 上传资源
label_relation_files: 关联已有资源
label_upload_softwarepackage: 上传软件包
label_upload_cuttingphoto: 上传截图
label_contests_reward_method: 奖励方式
@ -1837,7 +1848,9 @@ zh:
label_release_softapplication: 发布应用
label_upload_softapplication_packets: 上传应用软件包
label_upload_softapplication_photo: 上传产品截图
label_upload_softapplication_photo_condition: 截图至少上传2张至多4张格式为gif/jpg/png 尺寸480*800, 每张小于2M
label_upload_softapplication_packets_mustpacketed: 应用软件作品必须打包后以压缩包的形式上传,便于上传和下载
label_upload_softapplication_photo_condition: 应用软件截图需上传4张格式为gif/jpg/png 尺寸480*800, 每张小于2M
label_updated_caution: 注意:若修改应用,则之前上传的软件包和截图都将被删除,请重新上传!
label_softapplication_name: 应用名称
label_softapplication_description: 应用简介
label_softapplication_type: 应用分类
@ -1855,6 +1868,9 @@ zh:
label_release_add_contest_succeed: 该应用发布并添加成功.
label_add_contest_succeed_fail: 添加失败,该应用已参赛.
label_no_ftapplication: 暂无应用
label_edit_softapplication: 修改应用
label_contest_settings: 配置竞赛
label_contest_delete: 删除竞赛

View File

@ -16,7 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
RedmineApp::Application.routes.draw do
resources :ratings, :only => :create
mount SeemsRateable::Engine => '/rateable', :as => :rateable
namespace :zipdown do
match 'assort'
end
@ -581,7 +582,11 @@ RedmineApp::Application.routes.draw do
post 'school/get_options/:province', :to => 'school#get_options'
get 'school/get_options/:province', :to => 'school#get_options'
post 'school/get_schoollist/:province', :to => 'school#get_schoollist'
get 'school/get_schoollist/:province', :to => 'school#get_schoollist'
post 'school/search_school/', :to => 'school#search_school'
get 'school/search_school/', :to => 'school#search_school'
######added by nie
match 'tags/show_projects_tags',:to => 'tags#show_projects_tags'

View File

@ -232,7 +232,7 @@ tags_min_length:
default: 1
tags_max_length:
format: int
default: 13
default: 30
tags_show_search_results:
format: int
default: 5

View File

@ -1,10 +1,10 @@
class ChangeCreatedAtOfContestsToCreatedOn < ActiveRecord::Migration
def self.up
def up
rename_column :contests, :created_at, :created_on
rename_column :contests, :updated_at, :updated_on
end
def self.down
def down
rename_column :contests, :created_on, :created_at
rename_column :contests, :updated_on, :updated_at
end

View File

@ -0,0 +1,10 @@
class RemoveBudgetFromContests < ActiveRecord::Migration
def self.up
change_column :contests, :budget, :string, :default => ""
end
def self.down
change_column :contests, :budget, :integer, :default => 0
end
end

View File

@ -0,0 +1,5 @@
class AddLogolinkToSchools < ActiveRecord::Migration
def change
add_column :schools, :logo_link, :string
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140421044830) do
ActiveRecord::Schema.define(:version => 20140424072458) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -23,6 +23,15 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type"
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
create_table "apply_project_masters", :force => true do |t|
t.integer "user_id"
t.string "apply_type"
t.integer "apply_id"
t.integer "status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "attachments", :force => true do |t|
t.integer "container_id"
t.string "container_type", :limit => 30
@ -62,6 +71,20 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type"
create_table "bak_mentioned", :primary_key => "Id", :force => true do |t|
t.string "this_real_name", :limit => 1000
t.integer "is_mentioned_in"
t.string "context", :limit => 2000
end
add_index "bak_mentioned", ["this_real_name", "is_mentioned_in"], :name => "name_mention", :length => {"this_real_name"=>900, "is_mentioned_in"=>nil}
add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name"
add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_2"
add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_3", :length => {"this_real_name"=>900}
add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_4"
add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_5"
add_index "bak_mentioned", ["this_real_name"], :name => "this_real_name_6"
create_table "biding_projects", :force => true do |t|
t.integer "project_id"
t.integer "bid_id"
@ -101,6 +124,11 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id"
add_index "boards", ["project_id"], :name => "boards_project_id"
create_table "categories", :primary_key => "Id", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "proj_categories"
end
create_table "changes", :force => true do |t|
t.integer "changeset_id", :null => false
t.string "action", :limit => 1, :default => "", :null => false
@ -179,14 +207,14 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
create_table "contests", :force => true do |t|
t.string "name"
t.integer "budget"
t.string "budget", :default => ""
t.integer "author_id"
t.date "deadline"
t.string "description"
t.integer "commit"
t.string "password"
t.datetime "created_on", :null => false
t.datetime "updated_on", :null => false
t.datetime "created_on", :null => false
t.datetime "updated_on", :null => false
end
create_table "courses", :force => true do |t|
@ -265,6 +293,14 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
add_index "documents", ["project_id"], :name => "documents_project_id"
create_table "eco_projects", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.integer "eco_proj_id"
t.datetime "date_collected"
end
add_index "eco_projects", ["proj_id"], :name => "proj_id"
create_table "enabled_modules", :force => true do |t|
t.integer "project_id"
t.string "name", :null => false
@ -286,6 +322,137 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type"
add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id"
create_table "events", :primary_key => "event_id", :force => true do |t|
t.string "job_name"
t.datetime "event_time"
t.string "event_type", :limit => 20
end
create_table "fm_article", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "article_title", :limit => 16777215
t.text "article_link", :limit => 16777215
t.text "article_time", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_article", ["proj_id"], :name => "proj_id"
create_table "fm_bugtracker_link", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "description", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_bugtracker_link", ["proj_id"], :name => "proj_id"
create_table "fm_datametric_link", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "description", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_datametric_link", ["proj_id"], :name => "proj_id"
create_table "fm_dependency_link", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "description", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_dependency_link", ["proj_id"], :name => "proj_id"
create_table "fm_download_link", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "download_link", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_download_link", ["proj_id"], :name => "proj_id"
create_table "fm_heartbeat", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.float "popularity_score", :limit => 12
t.float "vitality_score", :limit => 12
t.integer "subscription"
t.integer "voting_score"
t.integer "voting_count"
t.datetime "date_collected"
end
add_index "fm_heartbeat", ["proj_id"], :name => "proj_id"
create_table "fm_license", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "description", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_license", ["proj_id"], :name => "proj_id"
create_table "fm_mailinglist_link", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "description", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_mailinglist_link", ["proj_id"], :name => "proj_id"
create_table "fm_operating_system", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "description", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_operating_system", ["proj_id"], :name => "proj_id"
create_table "fm_programming_language", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "description", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_programming_language", ["proj_id"], :name => "proj_id"
create_table "fm_project_spotlight", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "description", :limit => 16777215
t.text "project_name", :limit => 16777215
t.text "project_spotlight_link", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_project_spotlight", ["proj_id"], :name => "proj_id"
create_table "fm_release", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "description", :limit => 16777215
t.text "release_version", :limit => 16777215
t.text "release_time", :limit => 16777215
t.text "release_tag", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_release", ["proj_id"], :name => "proj_id"
create_table "fm_submit", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "submitter", :limit => 16777215
t.text "submitter_link", :limit => 16777215
t.text "submit_time", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_submit", ["proj_id"], :name => "proj_id"
create_table "fm_summary", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.text "description", :limit => 16777215
t.datetime "date_collected"
end
add_index "fm_summary", ["proj_id"], :name => "proj_id"
create_table "forums", :force => true do |t|
t.string "name", :null => false
t.string "description", :default => ""
@ -518,6 +685,22 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
add_index "news", ["created_on"], :name => "index_news_on_created_on"
add_index "news", ["project_id"], :name => "news_project_id"
create_table "no_uses", :force => true do |t|
t.integer "user_id", :null => false
t.string "no_use_type"
t.integer "no_use_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "ohloh_tagged", :force => true do |t|
t.integer "proj_id", :default => 0, :null => false
t.string "description", :limit => 100, :null => false
t.datetime "date_collected"
end
add_index "ohloh_tagged", ["proj_id"], :name => "proj_id"
create_table "open_id_authentication_associations", :force => true do |t|
t.integer "issued"
t.integer "lifetime"
@ -533,6 +716,19 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
t.string "salt", :null => false
end
create_table "open_source_projects", :force => true do |t|
t.string "name"
t.text "description"
t.integer "commit_count", :default => 0
t.integer "code_line", :default => 0
t.integer "users_count", :default => 0
t.date "last_commit_time"
t.string "url"
t.date "date_collected"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "praise_tread_caches", :force => true do |t|
t.integer "object_id", :null => false
t.string "object_type"
@ -612,6 +808,23 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
add_index "queries", ["project_id"], :name => "index_queries_on_project_id"
add_index "queries", ["user_id"], :name => "index_queries_on_user_id"
create_table "relative_memos", :force => true do |t|
t.integer "osp_id", :null => false
t.integer "parent_id"
t.string "subject", :null => false
t.text "content", :null => false
t.integer "author_id"
t.integer "replies_count", :default => 0
t.integer "last_reply_id"
t.boolean "lock", :default => false
t.boolean "sticky", :default => false
t.boolean "is_quote", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "viewed_count_crawl", :default => 0
t.integer "viewed_count_local", :default => 0
end
create_table "repositories", :force => true do |t|
t.integer "project_id", :default => 0, :null => false
t.string "url", :default => "", :null => false
@ -642,6 +855,7 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
t.string "province"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "logo_link"
end
create_table "seems_rateable_cached_ratings", :force => true do |t|
@ -754,6 +968,11 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
add_index "time_entries", ["project_id"], :name => "time_entries_project_id"
add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id"
create_table "tmp", :force => true do |t|
t.string "name"
t.string "part_number"
end
create_table "tokens", :force => true do |t|
t.integer "user_id", :default => 0, :null => false
t.string "action", :limit => 30, :default => "", :null => false
@ -764,6 +983,22 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id"
add_index "tokens", ["value"], :name => "tokens_value", :unique => true
create_table "tprojects", :force => true do |t|
t.string "name", :limit => 1000, :default => "0"
t.text "description", :limit => 16777215
t.string "commit_count", :limit => 100, :default => "0"
t.string "code_line", :limit => 100
t.string "last_commit_time", :limit => 100
t.string "url", :limit => 1000
t.datetime "date_collected"
t.string "created_at", :limit => 100
t.string "updated_at", :limit => 100
t.integer "proj_id", :null => false
t.string "user_count", :limit => 100
end
add_index "tprojects", ["proj_id"], :name => "proj_id"
create_table "trackers", :force => true do |t|
t.string "name", :limit => 30, :default => "", :null => false
t.boolean "is_in_chlog", :default => false, :null => false
@ -813,6 +1048,19 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id"
create_table "user_scores", :force => true do |t|
t.integer "user_id", :null => false
t.integer "collaboration"
t.integer "influence"
t.integer "skill"
t.integer "active"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "level"
t.integer "file"
t.integer "issue"
end
create_table "user_statuses", :force => true do |t|
t.integer "changesets_count"
t.integer "watchers_count"
@ -947,4 +1195,10 @@ ActiveRecord::Schema.define(:version => 20140421044830) do
add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status"
add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id"
create_table "yans", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end

View File

@ -1,21 +0,0 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
.project
.rvmrc
spec
test

View File

@ -1,32 +0,0 @@
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'SeemsRateable'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
Bundler::GemHelper.install_tasks
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
require 'rspec/core'
require 'rspec/core/rake_task'
task :default => :spec

View File

@ -1,4 +0,0 @@
module SeemsRateable
class ApplicationController < ActionController::Base
end
end

View File

@ -1,4 +0,0 @@
module SeemsRateable
module ApplicationHelper
end
end

View File

@ -1,4 +0,0 @@
module SeemsRateable
module RatingsHelper
end
end

View File

@ -1,6 +0,0 @@
module SeemsRateable
class Rate < ActiveRecord::Base
belongs_to :rater, :class_name => SeemsRateable::Engine.config.owner_class
belongs_to :rateable, :polymorphic => true
end
end

View File

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>SeemsRateable</title>
<%= stylesheet_link_tag "seems_rateable/application", media: "all" %>
<%= javascript_include_tag "seems_rateable/application" %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>

View File

@ -1,39 +0,0 @@
require 'rails/generators/migration'
require 'fileutils'
module SeemsRateable
module Generators
class InstallGenerator < ::Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path('../templates', __FILE__)
def self.next_migration_number(path)
unless @prev_migration_nr
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
else
@prev_migration_nr += 1
end
@prev_migration_nr.to_s
end
desc "generating migration files"
def copy_migrations
migration_template "rates_migration.rb", "db/migrate/create_seems_rateable_rates.rb"
migration_template "cached_ratings_migration.rb", "db/migrate/create_seems_rateable_cached_ratings.rb"
end
desc "generating initializer"
def copy_initializer
template "initializer.rb", "config/initializers/seems_rateable.rb"
end
desc "generating javascript files"
def copy_javascript_asset
Dir.mkdir "app/assets/javascripts/rateable" unless File.directory?("app/assets/javascripts/rateable")
copy_file "rateable.js.erb", "app/assets/javascripts/rateable/rateable.js.erb" unless File.exists?("app/assets/javascripts/rateable/rateable.js.erb")
copy_file "jRating.js.erb", "app/assets/javascripts/rateable/jRating.js.erb" unless File.exists?("app/assets/javascripts/rateable/jRating.js.erb")
end
end
end
end

View File

@ -1,17 +0,0 @@
class CreateSeemsRateableCachedRatings < ActiveRecord::Migration
def self.up
create_table :seems_rateable_cached_ratings do |t|
t.belongs_to :cacheable, :polymorphic => true
t.float :avg, :null => false
t.integer :cnt, :null => false
t.string :dimension
t.integer :cacheable_id, :limit => 8
t.string :cacheable_type
t.timestamps
end
end
def self.down
drop_table :cached_ratings
end
end

View File

@ -1,17 +0,0 @@
module SeemsRateable
class Engine < ::Rails::Engine
isolate_namespace SeemsRateable
config.generators do |g|
g.test_framework :rspec, :fixture => false
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
end
initializer :seems_rateable do
ActiveRecord::Base.send :include, SeemsRateable::Model
ActionView::Base.send :include, SeemsRateable::Helpers
ActionDispatch::Routing::Mapper.send :include, SeemsRateable::Routes
end
end
end

View File

@ -1,21 +0,0 @@
module SeemsRateable
module Errors
class InvalidRateableObjectError < StandardError
def to_s
"Stated object is not rateable. Add 'seems_rateable' to your object's class model."
end
end
class NoCurrentUserInstanceError < StandardError
def to_s
"User instance current_user is not available."
end
end
class AlreadyRatedError < StandardError
def to_s
"User has already rated an object."
end
end
end
end

View File

@ -1,27 +0,0 @@
module SeemsRateable
module Helpers
def rating_for(obj, opts={})
raise Errors::InvalidRateableObjectError unless obj.class.respond_to?(:rateable?)
options = {
:dimension => nil,
:static => false,
:class => 'rateable',
:id => nil
}.update(opts)
content_tag :div, "", "data-average" => obj.average(options[:dimension]) ? obj.average(options[:dimension]).avg : 0, :id => options[:id],
:class => "#{options[:class]}#{jdisabled?(options[:static])}",
"data-id" => obj.id, "data-kls" => obj.class.name, "data-dimension" => options[:dimension]
end
def seems_rateable_stylesheet
stylesheet_link_tag "seems_rateable/application", media: "all", "data-turbolinks-track" => true
end
private
def jdisabled?(option)
" jDisabled" if option || !current_user
end
end
end

View File

@ -1,111 +0,0 @@
require 'active_support/concern'
module SeemsRateable
module Model
extend ActiveSupport::Concern
def rate(stars, user_id, dimension=nil)
if !has_rated?(user_id, dimension)
self.rates.create do |r|
r.stars = stars
r.rater_id = user_id
end
update_overall_average_rating(stars, dimension)
elsif has_rated?(user_id, dimension) && can_update?
update_users_rating(stars, user_id, dimension)
else
raise Errors::AlreadyRatedError
end
end
def update_overall_average_rating(stars, dimension=nil)
if average(dimension).nil?
CachedRating.create do |r|
r.avg = stars
r.dimension = dimension
r.cacheable_id = self.id
r.cacheable_type = self.class.name
r.cnt = 1
end
else
r = average(dimension)
r.avg = (r.avg * r.cnt + stars) / (r.cnt+1)
r.cnt += 1
r.save!
end
end
def update_users_rating(stars, user_id, dimension=nil)
obj = rates(dimension).where(:rater_id => user_id).first
current_record = average(dimension)
current_record.avg = (current_record.avg*current_record.cnt - obj.stars + stars) / (current_record.cnt)
current_record.save!
obj.stars = stars
obj.save!
end
def average(dimension=nil)
if dimension.nil?
self.send "rate_average_without_dimension"
else
self.send "#{dimension}_average"
end
end
def rates(dimension=nil)
if dimension.nil?
self.send "rates_without_dimension"
else
self.send "#{dimension}_rates"
end
end
def raters(dimension=nil)
if dimension.nil?
self.send "raters_without_dimension"
else
self.send "#{dimension}_raters"
end
end
def has_rated?(user_id, dimension=nil)
record = self.rates(dimension).where(:rater_id => user_id)
record.empty? ? false : true
end
def can_update?
self.class.can_update?
end
module ClassMethods
def seems_rateable(opts={})
#has_many :rates_without_dimension, -> { where(dimension: nil) }, :as => :rateable, :class_name => SeemsRateable::Rate, :dependent => :destroy
has_many :rates_without_dimension, :conditions => { dimension: nil }, :as => :rateable, :class_name => SeemsRateable::Rate, :dependent => :destroy
has_many :raters_without_dimension, :through => :rates_without_dimension, :source => :rater
has_one :rate_average_without_dimension, :conditions => { dimension: nil }, :as => :cacheable, :class_name => SeemsRateable::CachedRating, :dependent => :destroy
@permission = opts[:allow_update] ? true : false
def self.can_update?
@permission
end
def self.rateable?
true
end
if opts[:dimensions].is_a?(Array)
opts[:dimensions].each do |dimension|
has_many :"#{dimension}_rates", :conditions => { dimension: dimension.to_s }, :dependent => :destroy, :class_name => SeemsRateable::Rate, :as => :rateable
has_many :"#{dimension}_raters", :through => :"#{dimension}_rates", :source => :rater
has_one :"#{dimension}_average", :conditions => { dimension: dimension.to_s }, :as => :cacheable, :class_name => SeemsRateable::CachedRating, :dependent => :destroy
end
end
end
def seems_rateable_rater
has_many :ratings_given, :class_name => SeemsRateable::Rate, :foreign_key => :rater_id
end
end
end
end

View File

@ -1,4 +0,0 @@
# desc "Explaining what the task does"
# task :seems_rateable do
# # Task goes here
# end

View File

@ -45,7 +45,7 @@ Don't forget to run
$ rake db:migrate
To prepare model add <code> seems_rateable </code> to your rateable model file. You can also pass a hash of options to
To prepare model add <code> seems_rateable </code> to your rateable model file. You can also pass a hash of options to
customize the functionality
<ul>
@ -76,7 +76,7 @@ And to object's raters e.g
@object.raters(:quantity)
To track user's given ratings add <code>seems_rateable_rater</code> to your rater model.
If your rater class is not "User"(e.g "Client" or "Customer") change configuration in initializer generated by this engine.
If your rater class is not "User"(e.g "Client" or "Customer") change configuration in initializer generated by this engine.
Now you can access user's ratings by <code>@user.ratings_given</code>
### Usage
@ -84,13 +84,13 @@ Now you can access user's ratings by <code>@user.ratings_given</code>
To display star rating use helper method <code>rating_for</code> in your view
#index.html.erb
rating_for @post
rating_for @post, :dimension => :quality, :class => 'post', :id => 'list'
rating_for @post, :static => true
You can specify these options :
<ul>
<li><code>:dimension</code>The dimension of the object</li>

View File

@ -0,0 +1,17 @@
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'SeemsRateable'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include('lib/**/*.rb')
end
Bundler::GemHelper.install_tasks

View File

Before

Width:  |  Height:  |  Size: 1018 B

After

Width:  |  Height:  |  Size: 1018 B

View File

@ -20,43 +20,43 @@
.jRatingAverage {
background-color:#f62929;
position:relative;
top:0;
left:0;
z-index:2;
height:100%;
background-color:#f62929;
position:relative;
top:0;
left:0;
z-index:2;
height:100%;
}
.jRatingColor {
background-color:#FFD400; /* bgcolor of the stars*/
position:relative;
top:0;
left:0;
z-index:2;
height:100%;
background-color:#FFD400; /* bgcolor of the stars*/
position:relative;
top:0;
left:0;
z-index:2;
height:100%;
}
/** Div containing the stars **/
.jStar {
position:relative;
left:0;
z-index:3;
position:relative;
left:0;
z-index:3;
}
/** P containing the rate informations **/
p.jRatingInfos {
position: absolute;
z-index:9999;
background: transparent url('bg_jRatingInfos.png') no-repeat;
color: #CACACA;
display: none;
width: 91px;
height: 29px;
font-size:16px;
text-align:center;
padding-top:5px;
position: absolute;
z-index:9999;
background: transparent url('bg_jRatingInfos.png') no-repeat;
color: #CACACA;
display: none;
width: 91px;
height: 29px;
font-size:16px;
text-align:center;
padding-top:5px;
}
p.jRatingInfos span.maxRate {
color:#c9c9c9;
font-size:14px;
color:#c9c9c9;
font-size:14px;
}

View File

@ -0,0 +1,7 @@
module SeemsRateable
class ApplicationController < ::ApplicationController
rescue_from SeemsRateable::Errors::AlreadyRatedError do |exception|
render :json => {:error => true}
end
end
end

View File

@ -0,0 +1,16 @@
require_dependency "seems_rateable/application_controller"
module SeemsRateable
class RatingsController < ApplicationController
def create
raise Errors::NoCurrentUserInstanceError unless current_user
obj = params[:kls].classify.constantize.find(params[:idBox])
obj.rate(params[:rate].to_i, current_user.id, params[:dimension])
render :json => true
rescue Errors::NoCurrentUserInstanceError
render :json => {:error => 'you must be login.'}
end
end
end

View File

@ -1,5 +1,5 @@
module SeemsRateable
class CachedRating < ActiveRecord::Base
belongs_to :cacheable, :polymorphic => true
belongs_to :cacheable, :polymorphic => true
end
end

View File

@ -0,0 +1,6 @@
module SeemsRateable
class Rate < ActiveRecord::Base
belongs_to :rater, :class_name => SeemsRateable::Engine.config.owner_class
belongs_to :rateable, :polymorphic => true
end
end

View File

@ -0,0 +1,42 @@
require 'rails/generators/migration'
require 'fileutils'
module SeemsRateable
module Generators
class InstallGenerator < ::Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path('../templates', __FILE__)
def self.next_migration_number(path)
unless @prev_migration_nr
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
else
@prev_migration_nr += 1
end
@prev_migration_nr.to_s
end
def routegen
route("seems_rateable")
end
desc "generating migration files"
def copy_migrations
migration_template "rates_migration.rb", "db/migrate/create_seems_rateable_rates.rb"
migration_template "cached_ratings_migration.rb", "db/migrate/create_seems_rateable_cached_ratings.rb"
end
desc "generating initializer"
def copy_initializer
template "initializer.rb", "config/initializers/seems_rateable.rb"
end
desc "generating javascript files"
def copy_javascript_asset
Dir.mkdir "app/assets/javascripts/rateable" unless File.directory?("app/assets/javascripts/rateable")
copy_file "rateable.js.erb", "app/assets/javascripts/rateable/rateable.js.erb" unless File.exists?("app/assets/javascripts/rateable/rateable.js.erb")
copy_file "jRating.js.erb", "app/assets/javascripts/rateable/jRating.js.erb" unless File.exists?("app/assets/javascripts/rateable/jRating.js.erb")
end
end
end
end

View File

@ -0,0 +1,17 @@
class CreateSeemsRateableCachedRatings < ActiveRecord::Migration
def self.up
create_table :seems_rateable_cached_ratings do |t|
t.belongs_to :cacheable, :polymorphic => true
t.float :avg, :null => false
t.integer :cnt, :null => false
t.string :dimension
t.integer :cacheable_id, :limit => 8
t.string :cacheable_type
t.timestamps
end
end
def self.down
drop_table :cached_ratings
end
end

View File

@ -12,9 +12,9 @@
$.fn.jRating = function(op) {
var defaults = {
/** String vars **/
bigStarsPath : '<%= image_path "seems_rateable/stars.png" %>', // path of the icon stars.png
smallStarsPath : '<%= image_path "seems_rateable/small.png" %>', // path of the icon small.png
path : '<%= SeemsRateable::Engine.routes.url_helpers.ratings_path %>',
bigStarsPath : 'images/seems_rateable/stars.png', // path of the icon stars.png
smallStarsPath : 'images/seems_rateable/small.png', // path of the icon small.png
path : '/ratings',
type : 'big', // can be set to 'small' or 'big'
/** Boolean vars **/

View File

@ -11,7 +11,7 @@ $(document).ready(function(){
//showRateInfo:false, //Rate info panel, set true to display
//rateInfosX : 45, //In pixel - Absolute left position of the information box during mousemove.
//rateInfosY : 5, //In pixel - Absolute top position of the information box during mousemove.
path : '<%= SeemsRateable::Engine.routes.url_helpers.ratings_path %>',
path : '/ratings',
onSuccess : function(element, rate){
//something like ->
//alert('success');
@ -21,5 +21,5 @@ $(document).ready(function(){
$('<span class="text-error"><small style="display:inline-block;">You have already rated!</small></span>').insertAfter(element)
}
});
});

View File

@ -15,4 +15,4 @@ class CreateSeemsRateableRates < ActiveRecord::Migration
def self.down
drop_table :rates
end
end
end

View File

@ -1,8 +1,10 @@
begin
require 'rails'
require 'rails'
rescue LoadError
end
require "jquery-rails"
require "seems_rateable/engine"
require "seems_rateable/errors"
require "seems_rateable/helpers"

View File

@ -0,0 +1,16 @@
module SeemsRateable
class Engine < ::Rails::Engine
isolate_namespace SeemsRateable
config.generators do |g|
g.test_framework :rspec, :fixture => false
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
end
initializer :seems_rateable do
ActiveRecord::Base.send :include, SeemsRateable::Model
ActionView::Base.send :include, SeemsRateable::Helpers
ActionDispatch::Routing::Mapper.send :include, SeemsRateable::Routes
end
end
end

View File

@ -0,0 +1,21 @@
module SeemsRateable
module Errors
class InvalidRateableObjectError < StandardError
def to_s
"Stated object is not rateable. Add 'seems_rateable' to your object's class model."
end
end
class NoCurrentUserInstanceError < StandardError
def to_s
"User instance current_user is not available."
end
end
class AlreadyRatedError < StandardError
def to_s
"User has already rated an object."
end
end
end
end

View File

@ -0,0 +1,27 @@
module SeemsRateable
module Helpers
def rating_for(obj, opts={})
raise Errors::InvalidRateableObjectError unless obj.class.respond_to?(:rateable?)
options = {
:dimension => nil,
:static => false,
:class => 'rateable',
:id => nil
}.update(opts)
content_tag :div, "", "data-average" => obj.average(options[:dimension]) ? obj.average(options[:dimension]).avg : 0, :id => options[:id],
:class => "#{options[:class]}#{jdisabled?(options[:static])}",
"data-id" => obj.id, "data-kls" => obj.class.name, "data-dimension" => options[:dimension]
end
def seems_rateable_stylesheet
stylesheet_link_tag "seems_rateable/application", media: "all", "data-turbolinks-track" => true
end
private
def jdisabled?(option)
" jDisabled" if option || !current_user
end
end
end

View File

@ -0,0 +1,91 @@
require 'active_support/concern'
module SeemsRateable
module Model
extend ActiveSupport::Concern
def rate(stars, user_id, dimension=nil)
if !has_rated?(user_id, dimension)
self.rates.create do |r|
r.stars = stars
r.rater_id = user_id
r.dimension = dimension
end
update_overall_average_rating(stars, dimension)
elsif has_rated?(user_id, dimension) && can_update?
update_users_rating(stars, user_id, dimension)
else
raise Errors::AlreadyRatedError
end
end
def update_overall_average_rating(stars, dimension=nil)
r = average(dimension)
if r.nil?
self.rate_averages.create do |r|
r.avg = stars
r.dimension = dimension
r.cnt = 1
end
else
r.avg = (r.avg * r.cnt + stars) / (r.cnt+1)
r.cnt += 1
r.save!
r
end
end
def update_users_rating(stars, user_id, dimension=nil)
obj = rates(dimension).where(:rater_id => user_id).first
current_record = average(dimension)
current_record.avg = (current_record.avg*current_record.cnt - obj.stars + stars) / (current_record.cnt)
current_record.save!
obj.stars = stars
obj.save!
end
def average(dimension=nil)
rate_averages.where(dimension: dimension).first
end
def rates(dimension=nil)
rates_all.where(dimension: dimension)
end
def raters(dimension=nil)
raters_all.where('seems_rateable_rates.dimension = ?', dimension)
end
def has_rated?(user_id, dimension=nil)
record = self.rates(dimension).where(:rater_id => user_id)
record.empty? ? false : true
end
def can_update?
self.class.can_update?
end
module ClassMethods
def seems_rateable(opts={})
has_many :rates_all, :as => :rateable, :class_name => SeemsRateable::Rate, :dependent => :destroy
has_many :raters_all, :through => :rates_all, :class_name => SeemsRateable::Engine.config.owner_class, :source => :rater
has_many :rate_averages, :as => :cacheable, :class_name => SeemsRateable::CachedRating, :dependent => :destroy
self.class_variable_set(:@@permission, opts[:allow_update] ? true : false)
def self.can_update?
self.class_variable_get(:@@permission)
end
def self.rateable?
true
end
end
def seems_rateable_rater
has_many :ratings_given, :class_name => SeemsRateable::Rate, :foreign_key => :rater_id
end
end
end
end

Some files were not shown because too many files have changed in this diff Show More