From 272be122e548e57c667f11346504696bdb1b575d Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Thu, 3 Apr 2014 16:46:22 +0800 Subject: [PATCH 01/43] =?UTF-8?q?=E6=8C=89=E6=97=B6=E9=97=B4=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 35e27a87f..86a20d3eb 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -33,8 +33,8 @@ class FilesController < ApplicationController 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" - @containers = [ Project.includes(:attachments).reorder("attachments.created_on DESC").find(@project.id)] #modify by Long Jun - @containers += @project.versions.includes(:attachments).reorder("created_on DESC").all.sort + @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun + @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort if @project.project_type == 1 render :layout => 'base_courses' From 120e84cfc794eeed84bef0b2867d4f743745a264 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Thu, 3 Apr 2014 17:26:56 +0800 Subject: [PATCH 02/43] =?UTF-8?q?=E6=96=B0=E7=AB=9E=E8=B5=9B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=A7=BB=E6=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/praise_tread_controller.rb | 2 + app/controllers/projects_controller.rb | 3 + app/controllers/users_controller.rb | 27 ++- app/controllers/welcome_controller.rb | 4 +- app/controllers/words_controller.rb | 4 + app/helpers/application_helper.rb | 46 +++- app/helpers/watchers_helper.rb | 59 ++++- app/models/project.rb | 1 + app/models/user.rb | 2 + app/views/welcome/contest.html.erb | 240 ++++++++++++++++++++- app/views/words/destroy.js.erb | 2 +- config/locales/zh.yml | 13 ++ config/routes.rb | 22 ++ lib/redmine.rb | 10 + 14 files changed, 424 insertions(+), 11 deletions(-) diff --git a/app/controllers/praise_tread_controller.rb b/app/controllers/praise_tread_controller.rb index 0fdb1b2c6..53df54e9f 100644 --- a/app/controllers/praise_tread_controller.rb +++ b/app/controllers/praise_tread_controller.rb @@ -69,6 +69,8 @@ class PraiseTreadController < ApplicationController @obj = Project.find_by_id(id) when 'Bid' @obj = Bid.find_by_id(id) + when 'Contest' + @obj = Contest.find_by_id(id) end return @obj end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d3481e2ae..81135865d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -68,6 +68,8 @@ class ProjectsController < ApplicationController helper :bids include BidsHelper + helper :contests + include ContestsHelper helper :sort include SortHelper helper :custom_fields @@ -567,6 +569,7 @@ class ProjectsController < ApplicationController "show_messages" => true, "show_news" => true, "show_bids" => true, + "show_contests" => true, "show_journals_for_messages" => true } @date_to ||= Date.today + 1 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5fcac2d59..e9e649181 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -23,19 +23,20 @@ class UsersController < ApplicationController menu_item :user_homework, :only => :user_homeworks menu_item :user_project, :only => [:user_projects, :watch_projects] menu_item :requirement_focus, :only => :watch_bids + menu_item :requirement_focus, :only => :watch_contests menu_item :user_newfeedback, :only => :user_newfeedback #Ended by young - before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, + before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info, :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index] #edit has been deleted by huang, 2013-9-23 before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, - :watch_bids, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, + :watch_bids, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index] accept_api_auth :index, :show, :create, :update, :destroy,:tag_save @@ -116,6 +117,28 @@ class UsersController < ApplicationController format.api end end + +#new add by linchun + def watch_contests + @bids = Contest.watched_by(@user) + @offset, @limit = api_offset_and_limit({:limit => 10}) + @contest_count = @contests.count + @contest_pages = Paginator.new @contest_count, @limit, params['page'] + @offset ||= @contest_pages.reverse_offset + unless @offset == 0 + @contest = @contests.offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + @contest = @contests.offset(@offset).limit(limit).all.reverse + end + + respond_to do |format| + format.html { + render :layout => 'base_users' + } + format.api + end + end # added by fq def user_activities diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 904920c5a..d35be75d2 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -81,7 +81,7 @@ class WelcomeController < ApplicationController end def contest - + end def search @@ -120,7 +120,7 @@ class WelcomeController < ApplicationController def entry_select_contest if request.original_url.match(/contest\.trustie\.net/) contest - render :contest, layout: false + render :contest return 0 end end diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index be1e31776..416b40db0 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -190,6 +190,8 @@ class WordsController < ApplicationController obj = User.find_by_id(obj_id) elsif ( referer.match(/bids/) || referer.match(/calls/) ) obj = Bid.find_by_id(obj_id) + elsif ( referer.match(/contests/) || referer.match(/contests/) ) #new added + obj = Contest.find_by_id(obj_id) else raise 'create reply obj unknow type.' end @@ -204,6 +206,8 @@ class WordsController < ApplicationController Project.add_new_jour(nil, nil, obj.id, options) elsif obj.kind_of? Bid obj.add_jour(nil, nil, nil, options) + elsif obj.kind_of? Contest + obj.add_jour(nil, nil, obj.id, options) #new added else raise 'create reply obj unknow type.' end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6047fcf2b..c606d0535 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1410,6 +1410,50 @@ module ApplicationHelper end html.html_safe end + +#display contest project + def show_more_contest_project?(contest) + if contest.projects.where('is_public = 1').count > 12 + return true + else + return false + end + end + + def show_contest_project(bid) + html = '' + if contest.projects.where('is_public = 1').count == 0 + html << (content_tag "p", l(:label_no_bid_project), :class => "font_lighter") + else + contest.projects.where('is_public = 1').take(12).each do |project| + html << (link_to image_tag(url_to_avatar(project), :class => "avatar", :title => project.name), project_path(project), :class => "avatar") + end + end + html.html_safe + end + + def show_contest_project(contest) + html = '' + if contest.projects.where('is_public = 1').count == 0 + html << (content_tag "p", l(:label_no_bid_project), :class => "font_lighter") + else + contest.projects.where('is_public = 1').take(12).each do |project| + html << (link_to image_tag(url_to_avatar(project), :class => "avatar", :title => project.name), project_path(project), :class => "avatar") + end + end + html.html_safe + end + def show_contest_fans_picture(obj) + html = '' + if obj.watcher_users.count == 0 + html << (content_tag "span", l(:label_project_no_follow)) + else + obj.watcher_users.take(12).each do |user| + html << (link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :class => "avatar", :title => user.name) + end + end + html.html_safe + end #display fans picture def show_more_fans?(obj) @@ -1500,7 +1544,7 @@ module ApplicationHelper courses_link = link_to l(:label_course_practice), {:controller => 'projects', :action => 'course', :project_type => 1, :host => Setting.course_domain} projects_link = link_to l(:label_project_deposit), {:controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain} users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.user_domain} - contest_link = link_to l(:label_contest_innovate), {:controller => 'bids', :action => 'contest', :project_type => 1 , :host => Setting.contest_domain} + contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'} bids_link = link_to l(:label_requirement_enterprise), {:controller => 'bids', :action => 'index'} 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'} diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index e05ef6ebd..fcaf63604 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -30,7 +30,7 @@ module WatchersHelper objects = Array.wrap(objects) watched = objects.any? {|object| object.watched_by?(user)} - @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Bid))) + @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid))) css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) @@ -46,6 +46,27 @@ module WatchersHelper link_to text, url, :remote => true, :method => method, :class => css end + ############## added by linchun + def new_watcher_link(objects, user, options=[]) + return '' unless user && user.logged? + objects = Array.wrap(objects) + + watched = objects.any? {|object| object.watched_by?(user)} + @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Contest))) + css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) : + ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s) + + text = @watch_flag ? + (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) + + url = watch_path( + :object_type => objects.first.class.to_s.underscore, + :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) + ) + method = watched ? 'delete' : 'post' + + link_to text, url, :remote => true, :method => method, :class => css + end # added by fq, modify nyan # Somebody may use option params def join_in_course(course, user, options=[]) @@ -93,8 +114,40 @@ module WatchersHelper end end end - - + ##new add by linchun + def join_in_contest(contest, user, options=[]) + return '' unless user && user.logged? + joined = user.join_in_contest?(contest) + text = joined ? l(:label_exit_contest) : l(:label_join_contest) + url_t = join_in_contest_path(:id => contest.id) + url_f = try_join_in_contest_path(:id => contest.id) + # url = join_in_contest_path(:id => contest.id) + method = joined ? 'delete' : 'post' + if joined + link_to text, url_t, :remote => true, :method => method, :id => "#{contest.id}", :confirm => l(:text_are_you_sure_out), :class => []+options + else + link_to text, url_f, :remote => true, :method => method, :id => "#{contest.id}", :class => []+options + end + end + + # liuwanwei 的需求, 新竞赛 + # 新路由命名为 competition + def join_in_competition(competition, user) + return '' unless user && user.logged? + joined = JoinInCompetition.where('competition_id = ? AND user_id = ?', competition.id, user.id).count>0 + text = joined ? l(:label_exit_contest) : l(:label_join_contest) + url_f = new_join_contests_path(:id => competition.id) + url_t = unjoin_in_contest_contests_path(:id => competition.id) + method = joined ? 'delete' : 'post' + if joined + # 退出竞赛用 + link_to text, url_t, :remote => true, :method => method, :id => "#{competition.id}", :confirm => l(:text_are_you_sure_out) + else + # 加入竞赛用 + link_to text, url_f, :remote => true, :method => method, :id => "#{competition.id}" + end + end + # Returns the css class used to identify watch links for a given +object+ def watcher_css(objects) objects = Array.wrap(objects) diff --git a/app/models/project.rb b/app/models/project.rb index fd576b637..0f68d3ab2 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -55,6 +55,7 @@ class Project < ActiveRecord::Base has_many :changesets, :through => :repository #added by xianbo for delete biding_project has_many :biding_projects, :dependent => :destroy + has_many :contesting_projects, :dependent => :destroy #ended by xianbo # added by fq has_many :journals_for_messages, :as => :jour, :dependent => :destroy diff --git a/app/models/user.rb b/app/models/user.rb index 4042fd84f..8c867512e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -78,11 +78,13 @@ class User < Principal belongs_to :ucourse, :class_name => 'Course', :foreign_key => :id #huang ## added by xianbo for delete has_many :biding_projects, :dependent => :destroy + has_many :contesting_projects, :dependent => :destroy ##ended by xianbo #####fq has_many :jours, :class_name => 'JournalsForMessage', :dependent => :destroy has_many :bids, :foreign_key => 'author_id', :dependent => :destroy + has_many :contests, :foreign_key => 'author_id', :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" has_many :journal_replies, :dependent => :destroy diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 6a0a8413f..a343f2ea2 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -1,8 +1,244 @@ +<%= stylesheet_link_tag 'welcome' %> + + + +
-
- 正在升级中。。。。。。。。。。。。 + +
+
+ <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %> +
+ +
+ +
+ +
+

热门项目

+ <%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}, :target => "_blank" %> +
+
    + <% find_miracle_project(10, 3).map do |project| %> +
  • +
    + <%= image_tag(get_project_avatar(project), :class => "avatar-4") %> +
    + +
    + <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%> + (<%= link_to "#{projectCount(project)}人", project_member_path(project) ,:course =>'0' %>) +
    +
    + ><%=project.description.truncate(50, omission: '...')%> +
    +
    + <%= content_tag "span", show_grade(project), + :style => "cursor: pointer; display: inline-block; float: right; color: #ec6300; ", + :title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度", + :class => "tooltip", + :id => "tooltip-#{project.id}" %> +

    +
    +
  • + <% end; reset_cycle %> +
+
+
+ +
+
    +

    用户动态

    + <%= link_to "更多>>", { :controller => 'users', :action => 'index'}, :target => "_blank" %> +
    + <% find_all_activities.each do |event| %> +
  • +
    + <%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %> +
    + +
    + <%= link_to event.event_author, (user_path(event.event_author) if event.event_author), :style => "color:green;", :target => "_blank" %><%= show_user_content event %> +

    <%= l(:field_updated_on) %><%= time_tag_welcome event.event_datetime %>前     <%= show_event_reply event %>

    +
    +
  • + <% end %> +
    +
+
+ +
+
    +
    +

    + 贴吧动态 + <%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> + <%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>

    + <%= link_to "更多>>", forums_path %> +
    +
    + <% find_new_forum_topics(7).each do |topic|%> +
  • +
    +       + <%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;", :target => "_blank" %> + +
    + <%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前 + + 由 <%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);", :target => "_blank" %> 发表 + + 回复(<%= link_to (topic.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url, :target => "_blank" %>) +
    +
  • + <% end %> +
    +
+
+ + + + + + + + +
+
+ + +






diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb index c583e0449..d3f3acc91 100644 --- a/app/views/words/destroy.js.erb +++ b/app/views/words/destroy.js.erb @@ -1,6 +1,6 @@ <% if @journal_destroyed.nil? %> alert('<%=l(:notice_failed_delete)%>'); -<% elsif (['Principal','Project', 'Bid'].include? @journal_destroyed.jour_type)%> +<% elsif (['Principal','Project', 'Bid', 'Contest'].include? @journal_destroyed.jour_type)%> var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>') destroyedItem.fadeOut(600,function(){ destroyedItem.remove(); diff --git a/config/locales/zh.yml b/config/locales/zh.yml index a006ae53c..e2b69082d 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1549,8 +1549,10 @@ zh: label_welcome_trustie: Trustie label_welcome_trustie_project: 在线项目托管平台 label_welcome_trustie_course: 在线课程实践平台 + label_welcome_trustie_contest: 在线竞赛实战平台 label_welcome_trustie_project_description: 面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。 label_welcome_trustie_course_description: 面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。 + label_welcome_trustie_contest_description: 面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。 label_user_project: 项目 label_user_course: 课程 label_user_homework: 作业 @@ -1811,3 +1813,14 @@ zh: label_contest_reason: 参赛宣言: label_notification: 通知 label_sumbit_empty: 搜索内容不能为空 + + #add by linchun (竞赛相关) + label_upload_files: 上传文件 + label_upload_softwarepackage: 上传软件包 + label_upload_cuttingphoto: 上传截图 + label_contests_reward_method: 奖励方式 + label_system_platform: 系统平台 + label_nextstep: 下一步 + label_participate: 参赛者 + label_contest_project: 参赛项目 + label_contest_application: 参赛应用 diff --git a/config/routes.rb b/config/routes.rb index 8ad29472b..e72f83aca 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,28 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do + ## new added by linchun #新竞赛相关 + resources :contests, only: [:index] do + collection do + match 'new_contest' , via: :get + match 'join_in_contest' , via: :post + match 'unjoin_in_contest' , via: :delete + match 'create_contest' , via: :post + match 'new_join' , via: :post + match 'new' , via: :post + end + member do + match 'update_contest' , via: [:put] + match 'show_contest' , via: :get + match 'show_project' , via: :get + match 'show_application' , via: :get + match 'show_participator' , via: :get + match 'add' , via: [:get, :post] + match 'create' , via: :post + match 'settings' , via: [:get, :post] + end + end + resources :stores do collection do match 'search', via: [:get, :post] diff --git a/lib/redmine.rb b/lib/redmine.rb index 0f8b3acc3..cce178a55 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -276,6 +276,16 @@ Redmine::MenuManager.map :bid_menu do |menu| # menu.push :result, { :controller => 'bids', :action => 'show_results' }, # :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p } end +###new add by linchun +Redmine::MenuManager.map :contest_menu do |menu| + menu.push :respond, :show_contest_contest_path, :caption => :label_user_response + menu.push :project, :show_project_contest_path, :caption => :label_contest_project + menu.push :application, :show_application_contest_path, :caption => :label_contest_application + # menu.push :result, { :controller => 'bids', :action => 'show_results' }, + # :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p } +end + +#### Redmine::MenuManager.map :application_menu do |menu| # Empty end From 1e7e0a1bb54cdd0d198aad32ae97148c1a21684c Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Thu, 3 Apr 2014 22:15:19 +0800 Subject: [PATCH 03/43] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E5=92=8C=E9=80=80=E5=87=BA=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E5=88=B7=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9B=E6=96=B0=E5=BB=BA=E9=A1=B9=E7=9B=AE=E5=90=8E=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E5=88=B7=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E5=88=97=E8=A1=A8=E5=92=8C=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=90=9C=E7=B4=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 10 +++++----- app/controllers/welcome_controller.rb | 4 ++-- app/views/welcome/contest.html.erb | 8 +++++--- config/locales/zh.yml | 3 +++ config/routes.rb | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 32878a2cd..ebe8342d4 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -461,22 +461,22 @@ class BidsController < ApplicationController # added by bai type ==1 需求,type==2 竞赛, type==3 作业 if @bid.reward_type == 1 - flash[:notice] = l(:label_bidding_succeed) + flash.now[:notice] = l(:label_bidding_succeed) elsif @bid.reward_type == 2 - flash[:notice] = l(:label_bidding_contest_succeed) + flash.now[:notice] = l(:label_bidding_contest_succeed) else @bid.reward_type == 3 - flash[:notice] = l(:label_bidding_homework_succeed) + flash.now[:notice] = l(:label_bidding_homework_succeed) end # end end else if @bid.reward_type == 3 - flash[:error] = l(:label_bidding_homework_fail) + flash.now[:error] = l(:label_bidding_homework_fail) else - flash[:error] = l(:label_bidding_fail) + flash.now[:error] = l(:label_bidding_fail) end end @bidding_project = @bid.biding_projects diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index d35be75d2..a7b3b421a 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -81,7 +81,7 @@ class WelcomeController < ApplicationController end def contest - + end def search @@ -120,7 +120,7 @@ class WelcomeController < ApplicationController def entry_select_contest if request.original_url.match(/contest\.trustie\.net/) contest - render :contest + render :contest return 0 end end diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index a343f2ea2..222ff7dc6 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -100,13 +100,15 @@
<%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %>
-
- +
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index e2b69082d..448690b46 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1824,3 +1824,6 @@ zh: label_participate: 参赛者 label_contest_project: 参赛项目 label_contest_application: 参赛应用 + button_contesting_as_project: 我要参赛(新建项目) + button_contesting_as_application: 我要参赛(发布应用) + diff --git a/config/routes.rb b/config/routes.rb index e72f83aca..7a782449b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -560,7 +560,7 @@ RedmineApp::Application.routes.draw do match 'calls', :controller => 'bids', :action => 'index' match 'calls/:id', :controller => 'bids', :action => 'show', :as => 'respond' - match 'contest', :controller => 'bids', :action => 'contest', :as => 'contest' + match 'contest', :controller => 'bids', :action => 'contests', :as => 'contest' #modified @20140403 ######added by nie match 'tags/show_projects_tags',:to => 'tags#show_projects_tags' From 2a278e0a2d7fbb0c46ba71b176c023a41fcd9f35 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Thu, 3 Apr 2014 22:38:18 +0800 Subject: [PATCH 04/43] all --- app/controllers/contests_controller.rb | 428 ++++++++++++++++++ app/helpers/contests_helper.rb | 158 +++++++ app/models/contest.rb | 117 +++++ app/models/contesting_project.rb | 51 +++ app/models/join_in_competition.rb | 10 + app/views/contests/_application_list.html.erb | 15 + app/views/contests/_contest_list.html.erb | 49 ++ app/views/contests/_form_contest.html.erb | 36 ++ app/views/contests/_history.html.erb | 53 +++ app/views/contests/_list_projects.html.erb | 102 +++++ app/views/contests/_new.html.erb | 53 +++ app/views/contests/_new_join.html.erb | 57 +++ app/views/contests/_pre_show.html.erb | 13 + app/views/contests/_project_list.html.erb | 15 + app/views/contests/_set_join.js.erb | 8 + app/views/contests/add.js.erb | 4 + app/views/contests/back.js.erb | 2 + app/views/contests/create.js.erb | 4 + app/views/contests/destroy.js.erb | 2 + app/views/contests/index.html.erb | 38 ++ app/views/contests/more.js.erb | 2 + app/views/contests/new.js.erb | 5 + app/views/contests/new_contest.html.erb | 10 + app/views/contests/new_join.js.erb | 3 + app/views/contests/set_reward.js.erb | 31 ++ app/views/contests/settings.html.erb | 30 ++ app/views/contests/show_application.html.erb | 67 +++ app/views/contests/show_contest.html.erb | 34 ++ app/views/contests/show_contest_user.html.erb | 30 ++ app/views/contests/show_participator.html.erb | 71 +++ app/views/contests/show_project.html.erb | 99 ++++ app/views/layouts/base_newcontest.html.erb | 264 +++++++++++ db/migrate/20140327071420_create_contests.rb | 15 + ...140327073052_create_contesting_projects.rb | 12 + ...ge_created_at_of_contests_to_created_on.rb | 11 + ...21611_add_reward_to_contesting_projects.rb | 5 + ...40402023357_create_join_in_competitions.rb | 10 + 37 files changed, 1914 insertions(+) create mode 100644 app/controllers/contests_controller.rb create mode 100644 app/helpers/contests_helper.rb create mode 100644 app/models/contest.rb create mode 100644 app/models/contesting_project.rb create mode 100644 app/models/join_in_competition.rb create mode 100644 app/views/contests/_application_list.html.erb create mode 100644 app/views/contests/_contest_list.html.erb create mode 100644 app/views/contests/_form_contest.html.erb create mode 100644 app/views/contests/_history.html.erb create mode 100644 app/views/contests/_list_projects.html.erb create mode 100644 app/views/contests/_new.html.erb create mode 100644 app/views/contests/_new_join.html.erb create mode 100644 app/views/contests/_pre_show.html.erb create mode 100644 app/views/contests/_project_list.html.erb create mode 100644 app/views/contests/_set_join.js.erb create mode 100644 app/views/contests/add.js.erb create mode 100644 app/views/contests/back.js.erb create mode 100644 app/views/contests/create.js.erb create mode 100644 app/views/contests/destroy.js.erb create mode 100644 app/views/contests/index.html.erb create mode 100644 app/views/contests/more.js.erb create mode 100644 app/views/contests/new.js.erb create mode 100644 app/views/contests/new_contest.html.erb create mode 100644 app/views/contests/new_join.js.erb create mode 100644 app/views/contests/set_reward.js.erb create mode 100644 app/views/contests/settings.html.erb create mode 100644 app/views/contests/show_application.html.erb create mode 100644 app/views/contests/show_contest.html.erb create mode 100644 app/views/contests/show_contest_user.html.erb create mode 100644 app/views/contests/show_participator.html.erb create mode 100644 app/views/contests/show_project.html.erb create mode 100644 app/views/layouts/base_newcontest.html.erb create mode 100644 db/migrate/20140327071420_create_contests.rb create mode 100644 db/migrate/20140327073052_create_contesting_projects.rb create mode 100644 db/migrate/20140327082704_change_created_at_of_contests_to_created_on.rb create mode 100644 db/migrate/20140401121611_add_reward_to_contesting_projects.rb create mode 100644 db/migrate/20140402023357_create_join_in_competitions.rb diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb new file mode 100644 index 000000000..39e9a2053 --- /dev/null +++ b/app/controllers/contests_controller.rb @@ -0,0 +1,428 @@ +# fq +# class BidsController < ApplicationController +class ContestsController < ApplicationController + menu_item :respond + menu_item :project, :only => :show_project + menu_item :application, :only => :show_application + before_filter :find_contest, :only => [:show_contest, :show_project, :show_application, :create,:destroy,:more,:back,:add,:new,:show_results, :set_reward, + :show_contest_project, :show_contest_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] + + # added by fq + before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest] + # end + before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ] + + helper :watchers + helper :attachments + include AttachmentsHelper + include ApplicationHelper + helper :projects + helper :words + + + def index + # @contests = Contest.visible + # @contests ||= [] + @offset, @limit = api_offset_and_limit({:limit => 10}) + @contests = Contest.visible + @contests = @contests.like(params[:name]) if params[:name].present? + @contest_count = @contests.count + @contest_pages = Paginator.new @contest_count, @limit, params['page'] + + @offset ||= @contest_pages.reverse_offset + if params[:contest_sort_type].present? + case params[:contest_sort_type] + when '0' + unless @offset == 0 + @contests = @contests.offset(@offset).limit(@limit).all.reverse + else + limit = @contest_count % @limit + limit = @limit if limit == 0 + @contests = @contests.offset(@offset).limit(limit).all.reverse + end + @s_state = 0 + when '1' + unless @offset == 0 + @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse + else + limit = @contest_count % @limit + limit = @limit if limit == 0 + @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse + end + @s_state = 1 + when '2' + unless @offset == 0 + @contests = @contests.offset(@offset).limit(@limit).all.reverse + else + limit = @contest_count % @limit + limit = @limit if limit == 0 + @contests = @contests.offset(@offset).limit(@limit).all.reverse + end + @s_state = 0 + end + else + unless @offset == 0 + @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse + else + limit = @contest_count % @limit + limit = @limit if limit == 0 + @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse + end + @s_state = 1 + end + end + + def show_contest + @user = @contest.author + @jours = @contest.journals_for_messages.order('created_on DESC') + @limit = 10 + @feedback_count = @jours.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @jour = @jours[@offset, @limit] + @state = false + + respond_to do |format| + layout_file = 'base_newcontest' + format.html { + render :layout => layout_file + } + format.api + end + end + + def join_in_contest + if params[:contest_password] == @contest.password + JoinInCompetition.create(:user_id => User.current.id, :competition_id => @contest.id) + @state = 0 + else + @state = 1 + end + + respond_to do |format| + format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} } + end + end + + def unjoin_in_contest + + joined = JoinInCompetition.where('competition_id = ? and user_id = ?', @contest.id, User.current.id) + + joined.each do |join| + join.delete + end + + respond_to do |format| + format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} } + end + end + + def new_join + + + end + + def show_participator + render :layout => 'base_newcontest' + + end + + + def settings + if @contest.author.id == User.current.id + @contest = Contest.find(params[:id]) + render :layout => 'base_newcontest' + else + render_403 :message => :notice_not_contest_setting_authorized + end + end + + def show_contest_project + contests = Contest.where('parent_id = ?', @contest.id) + @projects = [] + for contest in contests + @projects += contest.contesting_projects + end + + respond_to do |format| + format.html { + render :layout => 'base_newcontest' + } + format.api + + end + end + + def show_contest_user + contests = Contest.find(:all) + @users = [] + for contest in contests + for project in contest.projects + @users += project.users + end + end + + respond_to do |format| + format.html { + render :layout => 'base_newcontest' + } + format.api + + end + end + #显示参赛的项目 + def show_project + @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) + @option = [] + @membership.each do |membership| + unless(membership.project.project_type==1) + membership.member_roles.each{|role| + if(role.role_id == 3) + @option << membership.project + end + } + end + end + @user = @contest.author + @contesting_project = @contest.contesting_projects.all + if params[:student_id].present? + @temp = [] + @contesting_project.each do |pro| + if pro.project && pro.project.project_status + if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id + @temp << pro + end + end + @temp + end + @contesting_project = @temp + else + + @temp = [] + @contesting_project.each do |pro| + if pro.project && pro.project.project_status + @temp << pro + end + @temp + end + if @temp.size > 0 + @contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} + end + end + respond_to do |format| + format.html { + render :layout => 'base_newcontest' + } + format.api + end + end + ############ + ##显示参赛的应用 + def show_application + respond_to do |format| + format.html { + render :layout => 'base_newcontest' + } + format.api + end + end + + ###添加应标项目 + def add + project = Project.find(params[:contest]) + contest_message = params[:contest_for_save][:contest_message] + if ContestingProject.where("project_id = ? and contest_id = ?", project.id, @contest.id).size == 0 + if ContestingProject.cerate_contesting(@contest.id, project.id, contest_message) + flash.now[:notice] = l(:label_bidding_contest_succeed) + end + else + flash.now[:error] = l(:label_bidding_fail) + end + + @contesting_project = @contest.contesting_projects + + respond_to do |format| + + format.html { redirect_to :back } + format.js + end + end + + ## 新建留言 + def create + + if params[:contest_message][:message].size>0 + if params[:reference_content] + message = params[:contest_message][:message] + "\n" + params[:reference_content] + else + message = params[:contest_message][:message] + end + refer_user_id = params[:contest_message][:reference_user_id].to_i + @contest.add_jour(User.current, message, refer_user_id) + end + @user = @contest.author + @jours = @contest.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + @limit = 10 + @feedback_count = @jours.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @jour = @jours[@offset, @limit] + @contest.set_commit(@feedback_count) + + respond_to do |format| + format.js + end + + end + + ##删除留言 + def destroy + @user = @contest.author + if User.current.admin? || User.current.id == @user.id + JournalsForMessage.delete_message(params[:object_id]) + end + @jours = @contest.journals_for_messages.reverse + @limit = 10 + @feedback_count = @jours.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @jour = @jours[@offset, @limit] + + @contest.set_commit(@feedback_count) + respond_to do |format| + format.js + end + end + + ##引用留言 + def new + @jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id] + if @jour + user = @jour.user + text = @jour.notes + else + user = @contest.author + text = @contest.description + end + text = text.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]') + @content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> " + @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" + @id = user.id + rescue ActiveRecord::RecordNotFound + render_404 + end + + ##新建竞赛 + def new_contest + @contest = Contest.new + @contest.safe_attributes = params[:contest] + end + + ##提交创建的竞赛 + def create_contest + @contest = Contest.new + @contest.name = params[:contest][:name] + @contest.description = params[:contest][:description] + @contest.budget = params[:contest][:budget] + @contest.deadline = params[:contest][:deadline] + @contest.password = params[:contest][:password] + @contest.author_id = User.current.id + @contest.commit = 0 + if @contest.save + unless @contest.watched_by?(User.current) + if @contest.add_watcher(User.current) + flash[:notice] = l(:label_contesting_created_succeed) + end + end + redirect_to show_contest_contest_path(@contest) + else + @contest.safe_attributes = params[:contest] + render :action => 'new_contest' + end + end + + ##更新竞赛配置信息 + def update_contest + @contest = Contest.find(params[:id]) + @contest.name = params[:contest][:name] + @contest.description = params[:contest][:description] + + @contest.budget = params[:contest][:budget] + @contest.deadline = params[:contest][:deadline] + @contest.password = params[:contest][:password] + @contest.author_id = User.current.id + @contest.commit = 0 + if @contest.save + unless @contest.watched_by?(User.current) + if @contest.add_watcher(User.current) + flash[:notice] = l(:label_contesting_updated_succeed) + end + end + redirect_to show_contest_contest_path(@contest) + + else + @contest.safe_attributes = params[:contest] + render :action => 'new_contest' + end + end + + def more + @jour = @contest.journals_for_messages + @jour.each_with_index {|j,i| j.indice = i+1} + @state = true + + respond_to do |format| + format.html { redirect_to :back } + format.js + #format.api { render_api_ok } + end + end + + def back + @jour = @contest.journals_for_messages + @jour.each_with_index {|j,i| j.indice = i+1} + @state = false + + respond_to do |format| + format.html { redirect_to :back } + format.js + #format.api { render_api_ok } + end + end + + def set_reward + @b_p = nil + @contesting_project_id = nil + + if params[:set_reward][:reward]&&((User.current.id==@contest.author_id)||User.current.admin) + # @contest_id = params[:id] + @contesting_project_id = params[:set_reward][:b_id] #[:b_id]??? + @b_p = ContestingProject.find_by_id(@contesting_project_id) + + # 把字段存进表中 + @b_p.update_reward(params[:set_reward][:reward].to_s) + end + + respond_to do |format| + format.js + end + end + + + def manage + + end + + private + + def find_contest + if params[:id] + @contest = Contest.find(params[:id]) + @user = @contest.author + end + rescue + render_404 + end + +end + diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb new file mode 100644 index 000000000..e13641b1d --- /dev/null +++ b/app/helpers/contests_helper.rb @@ -0,0 +1,158 @@ +#enconding:utf-8 +# fq +module ContestsHelper + + def render_notes(contest, journal, options={}) + content = '' + removable = User.current == journal.user || User.current == contest.author + links = [] + if !journal.notes.blank? + links << link_to(image_tag('comment.png'), + {:controller => 'contests', :action => 'new', :id => contest, :journal_id => journal}, + :remote => true, + :method => 'post', + :title => l(:button_quote)) if options[:reply_links] + if removable + url = {:controller => 'contests', + :action => 'destroy', + :object_id => journal, + :id => contest} + links << ' ' + links << link_to(image_tag('delete.png'), url, + :remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete)) + end + end + content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty? + content << textilizable(journal.notes) + css_classes = "wiki" + content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes) + end + + def link_to_in_place_notes_editor(text, field_id, url, options={}) + onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;" + link_to text, '#', options.merge(:onclick => onclick) + end + + # this method is used to get all projects that tagged one tag + # added by william + def get_contests_by_tag(tag_name) + Contest.tagged_with(tag_name).order('updated_on desc') + end + + #added by huang + def sort_contest_enterprise(state, project_type) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:contest_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:contest_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") + + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:contest_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:contest_sort_type => '0', :project_type => project_type))) + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs_enterprise") + end + #end + + # def sort_bid(state, project_type) + # content = ''.html_safe + # case state + # when 0 + # content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type))) + # content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") +# + # when 1 + # content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") + # content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0', :project_type => project_type))) + # end + # content = content_tag('ul', content) + # content_tag('div', content, :class => "tabs") + # end + + #huang + def sort_contest(state) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'))) + content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'), :class=>"selected"), :class=>"selected") + + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'))) + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs") + end + #end + + # def course_options_for_select(courses) + # # + # html = '' + # courses.each do |course| + # html << "" + # end + # html.html_safe + # end + + + # used to get the reward and handle the value which can be used to display in views + # added by william + def get_prize(c_project) + c_project.get_reward + end + + def count_contest_project + contests = Contest.find(:id) + @projects = [] + for contest in contests + @projects += contest.contesting_projects + end + @projects.count + end + + def count_contest_user + contests = Contest.find(:id) + @users = [] + for contest in contests + for project in contest.projects + @users += project.users + end + end + @users.count + end + + def im_watching_student_id? contest + people = [] + people << contest.author + # case bid.reward_type # 天煞的bid分了三用途,里面各种hasmany还不定能用! + # when 1 + # when 2 + # bid.join_in_contests.each do |jic| + # people << jic.user + # end + # when 3 + # people += bid.courses.first.users.to_a + # else + # raise 'bids_helper: unknow bid type' # 出了错看这里!不知道的抛异常,省的找不到出错的地方! + # end + + contest.join_in_contests.each do |jic| + people << jic.user + end + people.include?(User.current) + end + + def select_option_helper option + tmp = Hash.new + option.each do |project| + tmp[project.name] = project.identifier + end + tmp + end + +end \ No newline at end of file diff --git a/app/models/contest.rb b/app/models/contest.rb new file mode 100644 index 000000000..a4427d24c --- /dev/null +++ b/app/models/contest.rb @@ -0,0 +1,117 @@ +class Contest < ActiveRecord::Base + attr_accessible :author_id, :budget, :commit, :deadline, :description, :name, :password + include Redmine::SafeAttributes + + belongs_to :author, :class_name => 'User', :foreign_key => :author_id + has_many :contesting_projects, :dependent => :destroy + has_many :projects, :through => :contesting_projects + has_many :projects_member, :class_name => 'User', :through => :projects + has_many :journals_for_messages, :as => :jour, :dependent => :destroy + 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 + + + + acts_as_attachable + + NAME_LENGTH_LIMIT = 60 + DESCRIPTION_LENGTH_LIMIT = 250 + + validates_length_of :name, :maximum => NAME_LENGTH_LIMIT + validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT + validates_presence_of :author_id, :name, :deadline + validates_format_of :deadline, :with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/ + validates_format_of :budget, :with => /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/ + validate :validate_user + after_create :act_as_activity + + scope :visible, lambda {|*args| + nil + } + + scope :like, lambda {|arg| + if arg.blank? + where(nil) + else + pattern = "%#{arg.to_s.strip.downcase}%" + where("LOWER(id) LIKE :p OR LOWER(name) LIKE :p OR LOWER(description) LIKE :p", :p => pattern) + end + } + + acts_as_watchable + acts_as_taggable + + acts_as_event :title => Proc.new {|o| "#{l(:label_requirement)} ##{o.id}: #{o.name}" }, + :description => :description, + :author => :author, + :url => Proc.new {|o| {:controller => 'contests', :action => 'show_contest', :id => o.id}} + + acts_as_activity_provider :find_options => {:include => [:projects, :author]}, + :author_key => :author_id + + safe_attributes 'name', + 'description', + 'budget', + 'deadline', + 'password' + + + def add_jour(user, notes, reference_user_id = 0, options = {}) + if options.count == 0 + self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) + else + jfm = self.journals_for_messages.build(options) + jfm.save + jfm + end + end + + def self.creat_contests(budget, deadline, name, description=nil) + self.create(:author_id => User.current.id, :budget => budget, + :deadline => deadline, :name => name, :description => description, :commit => 0) + end + + def update_contests(budget, deadline, name, description=nil) + if(User.current.id == self.author_id) + self.name = name + self.budget = budget + self.deadline = deadline + self.description = description + self.save + end + end + + def delete_contests + unless self.nil? + if User.current.id == self.author_id + self.destroy + end + end + end + + def set_commit(commit) + self.update_attribute(:commit, commit) + end + + private + + def validate_user + errors.add :author_id, :invalid if author.nil? || !author.active? + end + + + def act_as_activity + self.acts << Activity.new(:user_id => self.author_id) + end + + def validate_contest_manager(user_id) + unless user_id.nil? + if self.author_id == user_id + return true + else + return false + end + end + end +end diff --git a/app/models/contesting_project.rb b/app/models/contesting_project.rb new file mode 100644 index 000000000..773c04c68 --- /dev/null +++ b/app/models/contesting_project.rb @@ -0,0 +1,51 @@ +class ContestingProject < ActiveRecord::Base + attr_accessible :contest_id, :description, :project_id, :user_id, :reward + + belongs_to :contest + belongs_to :project + belongs_to :user + + DESCRIPTION_LENGTH_LIMIT = 500 + + validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT + validates_presence_of :user_id, :contest_id, :project_id + validate :validate_user + validate :validate_contest + validate :validate_project + validates_uniqueness_of :contest_id, :scope => :project_id + + def self.cerate_contesting(contest_id, project_id, description = nil) + self.create(:user_id => User.current.id, :contest_id => contest_id, + :project_id => project_id, :description => description) + end + + def update_reward(which) + self.update_attribute(:reward,which) + end + + def get_reward + self.reward + end + + def cancel_contesting + unless self.nil? + if User.current.id == self.user_id + self.destroy + end + end + end + + private + + def validate_user + errors.add :user_id, :invalid if user.nil? || !user.active? + end + + def validate_contest + errors.add :contest_id, :invalid if contest.nil? + end + + def validate_project + errors.add :project_id, :invalid if project.nil? + end +end diff --git a/app/models/join_in_competition.rb b/app/models/join_in_competition.rb new file mode 100644 index 000000000..707dccf07 --- /dev/null +++ b/app/models/join_in_competition.rb @@ -0,0 +1,10 @@ +# 新竞赛参加关系表 +class JoinInCompetition < ActiveRecord::Base + attr_accessible :competition_id, :user_id + belongs_to :user, :class_name => "User", :foreign_key => :user_id + belongs_to :competition, :class_name => "Contest", :foreign_key => :competition_id + + validates :user_id, presence: true + validates :competition_id, presence: true + +end diff --git a/app/views/contests/_application_list.html.erb b/app/views/contests/_application_list.html.erb new file mode 100644 index 000000000..081a9f4de --- /dev/null +++ b/app/views/contests/_application_list.html.erb @@ -0,0 +1,15 @@ + +<%= render_flash_messages %> + + + + <% if User.current.logged? %> + + <% end %> +
<%= l(:label_bidding_project) %> +
+ <%= toggle_link l(:button_contesting_as_project), 'put-bid-form' %> +
+
+ +<%#= render :partial=> "list_projects" %> diff --git a/app/views/contests/_contest_list.html.erb b/app/views/contests/_contest_list.html.erb new file mode 100644 index 000000000..cdc390410 --- /dev/null +++ b/app/views/contests/_contest_list.html.erb @@ -0,0 +1,49 @@ + +<% contests.each do |contest|%> + + + + + +
<%= link_to(image_tag(url_to_avatar(contest.author), :class => 'avatar'), user_path(contest.author), :class => "avatar") %> + + + + + + + + + + + +
<%= link_to(contest.author, user_path(contest.author), :class => 'bid_user') %>:  <%= link_to(contest.name, show_contest_contest_path(contest), :class => 'bid_path') %>
+ + + + + + + + + +
+ <%= l(:label_contests_reward_method) %><%= contest.budget%> +
<%= l(:label_x_biding_project, :count => contest.contesting_projects.count) %>(<%= link_to contest.contesting_projects.count %>) + <%= l(:label_x_bids_responses, :count => contest.commit) %>(<%= link_to contest.commit, respond_path(contest) %>) + <%= l(:label_x_followers, :count => contest.watcher_users.count) %>(<%= link_to contest.watcher_users.count, respond_path(contest) %>) +
<%= l :label_create_time %>: <%= format_time contest.created_on %>
+
+ + + + +
<%= contest.description%>
+
+<% end %> + + diff --git a/app/views/contests/_form_contest.html.erb b/app/views/contests/_form_contest.html.erb new file mode 100644 index 000000000..5dc824d28 --- /dev/null +++ b/app/views/contests/_form_contest.html.erb @@ -0,0 +1,36 @@ + + +<%= error_messages_for 'contest' %> + +

<%= l(:label_bids_form_contest_new_description) %>

+

<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Contest::NAME_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_name)}" %>

+ +

<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Contest::DESCRIPTION_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_description)}" %>

+ +

<%= f.text_field :password, :size => 60, :style => "width:488px;margin-left: 10px;" %>

+ +

+ <%= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %> + + +

+ +

<%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;", :placeholder => "#{l(:label_deadline)}" %><%= calendar_for('contest_deadline')%>

diff --git a/app/views/contests/_history.html.erb b/app/views/contests/_history.html.erb new file mode 100644 index 000000000..6be572c65 --- /dev/null +++ b/app/views/contests/_history.html.erb @@ -0,0 +1,53 @@ +<% reply_allow = JournalsForMessage.create_by_user? User.current %> +<% tip1 = l(:label_user_response) %> +

<%=tip1%>

+ +
+ <%= render :partial => 'new', :locals => {:contest => @contest, :sta => @state} %> +
+ + +<% if journals.size >0 %> +
    + <% for journal in journals%> +
  • + <%= image_tag(url_to_avatar(journal.user), :class => "avatar") %> + + <%= link_to journal.user, user_path(journal.user)%> + <% label = l(:label_contest_requirement) %> +
    <%= textilizable journal.notes%>
    + <%= l(:label_bids_published) %> <%= time_tag(journal.created_on).html_safe %> <%= l(:label_bids_published_ago) %> + + <% ids = 'project_respond_form_'+ journal.id.to_s%> + + + <% if reply_allow %> + <%#= link_to(l(:button_quote), {:controller => 'contests', :action => 'new', :id => contest, :journal_id => journal}, :remote => true, :method => 'post', :title => l(:button_quote))%> + <%= link_to(l(:button_quote), contests_path(:id => contest, :journal_id => journal), :remote => true, :method => 'post', :title => l(:button_quote))%> + <%= link_to l(:label_bid_respond_quote),'', + {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: '); $('##{ids} textarea') ;return false;"}%> + <% end %> + + <% if @user==User.current|| User.current.admin? %> + <%#= link_to(l(:label_bid_respond_delete), {:controller => 'bids', :action => 'destroy', :object_id => journal, :id => bid},:confirm => l(:label_delete_confirm), + :remote => true, :method => 'delete', :class => "delete", :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %> + <%= link_to(l(:label_bid_respond_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => @user}, :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %> + <% end %> + +
    + +
    + <% ids = 'project_respond_form_'+ journal.id.to_s%> + <% if reply_allow %> +
    + <%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal} %> +
    + <% end %> +
    +
    + <%= render :partial => "words/journal_reply", :locals => {:journal => journal } %> +
    +
  • + <% end %> +
+<% end %> diff --git a/app/views/contests/_list_projects.html.erb b/app/views/contests/_list_projects.html.erb new file mode 100644 index 000000000..6a778819d --- /dev/null +++ b/app/views/contests/_list_projects.html.erb @@ -0,0 +1,102 @@ + +<% contesting_project.each do |c_project|%> + <% if c_project.project %> + + + + +
+ + + + + + + +
+
+ <%= image_tag(url_to_avatar(c_project.project), :class => 'avatar3') %> + +
+ + + + + + + + + + + + + + + + + +
+ + <%= link_to(c_project.project.name, project_path(c_project.project)) %> + + <%= l(:label_joined_contest)%> + + + + <%= l(:label_system_grade) %>:<%= (c_project.project.project_status.nil? ? 0.0 : c_project.project.project_status.grade) unless (c_project.project.project_status.nil? && c_project.project.nil?) %> + <% if get_prize(c_project).nil? or get_prize(c_project) == "" %> + <% if @contest.deadline < Date.today %> + <%= l(:label_noawards)%> + <% end %> + <% else %> + + <% case get_prize(c_project) %> + <% when '-1' %> + <%= image_tag("/images/bid/special_reward.png")%> + <% when '0' %> + <%= image_tag("/images/bid/first_reward.png")%> + <% when '1' %> + <%= image_tag("/images/bid/second_reward.png")%> + <% when '2' %> + <%= image_tag("/images/bid/third_reward.png")%> + <% when '3' %> + <%= image_tag("/images/bid/forth_reward.png")%> + <% when '4' %> + <%= image_tag("/images/bid/fifth_reward.png")%> + <% when '5' %> + <%= image_tag("/images/bid/qualified.png")%> + <% end %> + <% end %> + + +
<%= c_project.project.description %>
+ <%= format_time c_project.created_at%> +
+
+
+ + + + + + + + +
+ + <%= l(:label_contest_user) %> + <% unless c_project.user.nil? %> + <%= c_project.user.lastname %><%= c_project.user.firstname %> + <% end %> + + +
+ <%= l(:label_contest_reason) %> + <%= c_project.description %> +
+
+
+
+ <% end %> +<% end %> + diff --git a/app/views/contests/_new.html.erb b/app/views/contests/_new.html.erb new file mode 100644 index 000000000..2462d3fb1 --- /dev/null +++ b/app/views/contests/_new.html.erb @@ -0,0 +1,53 @@ + + + +<%= form_for('contest_message', + :remote => true, :method => :post, + :url => {:controller => 'contests', + :action => 'create', + :id => contest, + :sta => sta} + ) do |f|%> + +
+ <%= render :partial => 'pre_show', :locals => {:content => @content} %> +
+ + <% if User.current.logged? %> + + + + +
<%= f.text_area 'message', :rows => 3, :cols => 65, :placeholder => l(:label_my_respond), :style => "resize: none;", :class => 'noline'%>
+ + <%= f.text_field :reference_user_id, :style=>"display:none"%> + + + + + + +
<%= submit_tag l(:button_leave_meassge), :name => nil , :class => "contest_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> + <%= submit_tag l(:button_clear), :name => nil, :onclick => "clearMessage('contest_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
+ + <% else %> +
+ <%= l(:label_user_login_tips) %> + <%= link_to l(:label_user_login_new), signin_path %> +
+ <% end %> +<% end %> diff --git a/app/views/contests/_new_join.html.erb b/app/views/contests/_new_join.html.erb new file mode 100644 index 000000000..c764690de --- /dev/null +++ b/app/views/contests/_new_join.html.erb @@ -0,0 +1,57 @@ + + + +

请输入竞赛密码

+ +<%= form_tag( join_in_contest_contests_path(id: contest.id), + :remote => true, + :method => :post, + :id => 'new-watcher-form') do %> + + + + + <%= text_field_tag 'contest_password', nil, :size => 45 %> + +

+ <%= submit_tag l(:label_new_join), :name => nil, :class => "contest_btn", :onclick => "hideModal(this);" %> + <%= submit_tag l(:button_cancel), :name => nil, :class => "contest_btn", :onclick => "hideModal(this);", :type => 'button' %> + +

+
+<% end %> diff --git a/app/views/contests/_pre_show.html.erb b/app/views/contests/_pre_show.html.erb new file mode 100644 index 000000000..fef1f16e4 --- /dev/null +++ b/app/views/contests/_pre_show.html.erb @@ -0,0 +1,13 @@ + +<% unless content.nil?%> + + + + + + + +
<%= textilizable content %>
<%= hidden_field_tag 'reference_content', params[:reference_content], :value => content%>
+<% end %> + + diff --git a/app/views/contests/_project_list.html.erb b/app/views/contests/_project_list.html.erb new file mode 100644 index 000000000..325e87105 --- /dev/null +++ b/app/views/contests/_project_list.html.erb @@ -0,0 +1,15 @@ + +<%= render_flash_messages %> + + + + <% if User.current.logged? %> + + <% end %> +
<%= l(:label_bidding_project) %>(<%= contesting_project.count%>) +
+ <%= toggle_link l(:button_contesting_as_project), 'put-bid-form' %> +
+
+ +<%= render :partial=> "list_projects",:locals => {:contesting_project => contesting_project,:contest => @contest }%> diff --git a/app/views/contests/_set_join.js.erb b/app/views/contests/_set_join.js.erb new file mode 100644 index 000000000..346e1d846 --- /dev/null +++ b/app/views/contests/_set_join.js.erb @@ -0,0 +1,8 @@ +$("#<%=object_id%>").replaceWith('<%= escape_javascript join_in_competition(@contest, user) %>'); +<% if @state %> + <% if @state == 0 %> + alert("加入成功") + <% else %> + alert("密码错误") + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/contests/add.js.erb b/app/views/contests/add.js.erb new file mode 100644 index 000000000..9c696d8aa --- /dev/null +++ b/app/views/contests/add.js.erb @@ -0,0 +1,4 @@ +$('#contesting_project_list').html('<%= escape_javascript(render(:partial => 'project_list', :locals => {:contesting_project => @contesting_project})) %>'); +$("#project_id").val("请选择项目"); +$("#contest_message").val( "<%= l(:label_bid_reason) %>" ); +$("#put-bid-form").hide(); \ No newline at end of file diff --git a/app/views/contests/back.js.erb b/app/views/contests/back.js.erb new file mode 100644 index 000000000..d806c1481 --- /dev/null +++ b/app/views/contests/back.js.erb @@ -0,0 +1,2 @@ +$('#history').html('<%= escape_javascript(render(:partial => 'history', :locals => {:contest => @contest, :journals => @jour, :state => @state})) %>'); +$('#contest_message_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/contests/create.js.erb b/app/views/contests/create.js.erb new file mode 100644 index 000000000..9246d939c --- /dev/null +++ b/app/views/contests/create.js.erb @@ -0,0 +1,4 @@ +$('#history').html('<%= escape_javascript(render(:partial => 'contests/history', :locals => {:contest => @contest, :journals => @jour, :state => true})) %>'); +$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>'); +$('#contest_message_message').val(""); +$('#contest_message_reference_user_id').val(""); diff --git a/app/views/contests/destroy.js.erb b/app/views/contests/destroy.js.erb new file mode 100644 index 000000000..a2f0fb2da --- /dev/null +++ b/app/views/contests/destroy.js.erb @@ -0,0 +1,2 @@ +$('#history').html('<%= escape_javascript(render(:partial => 'history', :locals => {:contest => @contest, :journals => @jour, :state => false})) %>'); +$('#contest_message_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/contests/index.html.erb b/app/views/contests/index.html.erb new file mode 100644 index 000000000..3a7bde1e5 --- /dev/null +++ b/app/views/contests/index.html.erb @@ -0,0 +1,38 @@ +
+ <%= form_tag({:controller => 'contests', :action => 'index'}, :method => :get) do %> + + + + + + + + + + + +
<%= l(:label_contest_innovate) %><%= l(:label_user_location) %> : + <% if User.current.logged? %> + <% unless User.current.user_extensions.identity == 1 %> + <%= link_to(l(:label_newtype_contest), {:controller => 'contests', :action => 'new_contest'}, :class => 'icon icon-add') %> + <% end %> + <% end %> + + +
<%= link_to request.host()+"/contests", :controller => 'contests', :action => 'index' %> <%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_contest_innovate), :controller => 'contests', :action => 'index' %>
+ <% end %> +
+<% if @contests.size > 0%> +<%= sort_contest(@s_state)%> +
+ <%= render :partial => 'contest_list', :locals => {:contests => @contests, :contest_pages => @contest_pages} %> +
+<% else %> + <%= render :partial => "layouts/no_content"%> +<% end %> + +<% html_title l(:label_contest_list)%> diff --git a/app/views/contests/more.js.erb b/app/views/contests/more.js.erb new file mode 100644 index 000000000..d806c1481 --- /dev/null +++ b/app/views/contests/more.js.erb @@ -0,0 +1,2 @@ +$('#history').html('<%= escape_javascript(render(:partial => 'history', :locals => {:contest => @contest, :journals => @jour, :state => @state})) %>'); +$('#contest_message_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/contests/new.js.erb b/app/views/contests/new.js.erb new file mode 100644 index 000000000..a251b3d69 --- /dev/null +++ b/app/views/contests/new.js.erb @@ -0,0 +1,5 @@ +$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => @content})) %>'); +$('#contest_message_reference_user_id').val("<%= @id%>"); +showAndScrollTo("pre_show", "contest_message_reference_user_id"); + + diff --git a/app/views/contests/new_contest.html.erb b/app/views/contests/new_contest.html.erb new file mode 100644 index 000000000..7366b4203 --- /dev/null +++ b/app/views/contests/new_contest.html.erb @@ -0,0 +1,10 @@ + +

<%=l(:label_newtype_contest)%>

+ +<%= labelled_form_for @contest, :url => {:controller => 'contests', :action => 'create_contest'}, method: :post do |f| %> +
+ <%= render :partial => 'form_contest', :locals => { :f => f } %> + <%= submit_tag l(:button_create) %> + <%= javascript_tag "$('#bid_name').focus();" %> + <% end %> +
\ No newline at end of file diff --git a/app/views/contests/new_join.js.erb b/app/views/contests/new_join.js.erb new file mode 100644 index 000000000..5ec9356d7 --- /dev/null +++ b/app/views/contests/new_join.js.erb @@ -0,0 +1,3 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'contests/new_join', :locals => {:contest => @contest}) %>'); +showModal('ajax-modal', '400px'); +$('#ajax-modal').addClass('new-watcher'); diff --git a/app/views/contests/set_reward.js.erb b/app/views/contests/set_reward.js.erb new file mode 100644 index 000000000..d6d8c4f9f --- /dev/null +++ b/app/views/contests/set_reward.js.erb @@ -0,0 +1,31 @@ +$('#reward_result_<%= @contesting_project_id %>').html('<%= j( + +if get_prize(@b_p).nil? or get_prize(@b_p) == "" + if @contest.deadline < Date.today + puts '未评奖' + end +else + + case get_prize(@b_p) + when '-1' + image_tag("/images/bid/special_reward.png") + when '1' + when '0' + image_tag("/images/bid/first_reward.png") + when '1' + image_tag("/images/bid/second_reward.png") + when '2' + image_tag("/images/bid/third_reward.png") + when '3' + image_tag("/images/bid/forth_reward.png") + when '4' + image_tag("/images/bid/fifth_reward.png") + when '5' + image_tag("/images/bid/qualified.png") + end + +end +) +%>') + +$('#<%= @contesting_project_id %>').hide() diff --git a/app/views/contests/settings.html.erb b/app/views/contests/settings.html.erb new file mode 100644 index 000000000..def1c7f5d --- /dev/null +++ b/app/views/contests/settings.html.erb @@ -0,0 +1,30 @@ + +

<%=l(:label_settings)%>

+ +<%= error_messages_for 'contest' %> + +<%= labelled_form_for @contest, :url => update_contest_contest_path(@contest) do |f| %> +
+ <%= render :partial => 'form_contest', :locals => { :f => f } %> +
+ <%= submit_tag l(:button_create) %> + <%= javascript_tag "$('#bid_name').focus();" %> +<% end %> \ No newline at end of file diff --git a/app/views/contests/show_application.html.erb b/app/views/contests/show_application.html.erb new file mode 100644 index 000000000..da06a7cb0 --- /dev/null +++ b/app/views/contests/show_application.html.erb @@ -0,0 +1,67 @@ + + + + + + <% if User.current.logged? %> + + + + <% end %> +
+ <%= render :partial => 'application_list' %> +
+ diff --git a/app/views/contests/show_contest.html.erb b/app/views/contests/show_contest.html.erb new file mode 100644 index 000000000..9ce40bfcb --- /dev/null +++ b/app/views/contests/show_contest.html.erb @@ -0,0 +1,34 @@ +<% reply_allow = JournalsForMessage.create_by_user? User.current %> +
+ <%= image_tag(url_to_avatar(@contest.author), :class => "avatar")%> + +

<%= link_to(@contest.author.lastname+@contest.author.firstname, user_path(@contest.author))%>:<%= @contest.name %>

+

+ <%= l(:label_bids_reward_method) %><%= @contest.budget%> +

+
+ <%= @contest.description %> + +
+ + <%= render :partial => "/praise_tread/praise_tread", + :locals => {:obj => @contest,:show_flag => true,:user_id =>User.current.id}%> + +
+
+ +
+ +
+ <%= render :partial => 'history', :locals => { :contest => @contest, :journals => @jour, :state => false} %> +
+ + + diff --git a/app/views/contests/show_contest_user.html.erb b/app/views/contests/show_contest_user.html.erb new file mode 100644 index 000000000..43eb896ad --- /dev/null +++ b/app/views/contests/show_contest_user.html.erb @@ -0,0 +1,30 @@ +
+ <% for user in @contest.watcher_users %> +
  • + + + + + +
    <%= image_tag(url_to_avatar(user), :class => "avatar") %> + + + + + + + + + +
    <%= content_tag "div", link_to_user(user), :class => "project_avatar_name" %> +

    + <% unless user.memberships.empty? %> + <%= l(:label_x_contribute_to, :count => user.memberships.count) %> + <% for member in user.memberships %> + <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> + <% end %> + <% end %> +

    <%= l(:label_user_joinin) %><%= format_date(user.created_on) %> +
+<% end %> +
\ No newline at end of file diff --git a/app/views/contests/show_participator.html.erb b/app/views/contests/show_participator.html.erb new file mode 100644 index 000000000..da51aef3a --- /dev/null +++ b/app/views/contests/show_participator.html.erb @@ -0,0 +1,71 @@ + +

<%=link_to l(:label_x_join_in_contest, :count => @contest.join_in_contests.count)+"("+@contest.join_in_contests(@user.id).count.to_s+")", :controller=>"contests", :action=>"show_participator"%>

+
+ <% for temp in @contest.join_in_contests %> + <% user = temp.user %> +
    +
  • + + + + + + +
    + <%= link_to image_tag(url_to_avatar(user), :class => "avatar"), user_path(user), :title => "#{user.show_name}" %> + + + + + + + + + + + + + + + +
    <%= content_tag "div", link_to(user.show_name, user_path(user)), :class => "project_avatar_name" , :title => "#{user.show_name}" %> + + <% if (im_watching_student_id? @contest) && user.user_extensions.identity.to_i.eql?(1) %> + <%= l(:label_bidding_user_studentcode) %> :<%= user.user_extensions.student_id%> + <% end %> +
    +

    + <% unless user.memberships.empty? %> + <% cond = Project.visible_condition(User.current) + "AND projects.project_type <> 1" %> + <% memberships = user.memberships.all(:conditions => cond) %> + <%= l(:label_x_contribute_to, :count => memberships.count) %> + <% + links = Array.new + memberships.collect{|member| links << link_to_project(member.project) } + %> + + <%= raw links.join(" , ") %> + <% end %> +

    + + + +
    + <%= l(:label_user_joinin) %><%= format_date(user.created_on) %> +
    +
    +
  • +
+ <% end %> +
\ No newline at end of file diff --git a/app/views/contests/show_project.html.erb b/app/views/contests/show_project.html.erb new file mode 100644 index 000000000..f43d5048e --- /dev/null +++ b/app/views/contests/show_project.html.erb @@ -0,0 +1,99 @@ + + + + + + <% if User.current.logged? %> + + + + <% end %> +
+ <%= render :partial => 'project_list', :locals => {:contesting_project => @contesting_project,:contest => @contest} %> +
+ diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb new file mode 100644 index 000000000..1b3a99966 --- /dev/null +++ b/app/views/layouts/base_newcontest.html.erb @@ -0,0 +1,264 @@ +<% @nav_dispaly_contest_label = 1 %> + + + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %> + <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= javascript_heads %> + <%= heads_for_theme %> + <%= call_hook :view_layouts_base_html_head %> + + <%= yield :header_tags -%> + + +
+
+
+ <%=render :partial => 'layouts/base_header'%> +
+ +
+ + + + + + + + + + +
创新竞赛社区<%= l(:label_user_location) %> : + +
<%=link_to request.host()+"/contests", :controller=>'contests', :action=>'index' %><%=link_to l(:field_homepage), home_path %> > + <%=link_to l(:label_contest_innovate), :controller=>'contests', :action=>'index' %> > + <%= link_to @contest.name, show_contest_contest_path %> +
+
+ + + +
+ <% if display_main_menu?(@contest) %> +
+ <%= render_menu :contest_menu %> +
+ <% end %> + + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
+
+ <%=render :partial => 'layouts/base_footer'%> +
+
+
+ + + + +
+ <%= call_hook :view_layouts_base_body_bottom %> + + diff --git a/db/migrate/20140327071420_create_contests.rb b/db/migrate/20140327071420_create_contests.rb new file mode 100644 index 000000000..0ec04a6c5 --- /dev/null +++ b/db/migrate/20140327071420_create_contests.rb @@ -0,0 +1,15 @@ +class CreateContests < ActiveRecord::Migration + def change + create_table :contests do |t| + t.string :name + t.integer :budget + t.integer :author_id + t.date :deadline + t.string :description + t.integer :commit + t.string :password + + t.timestamps + end + end +end diff --git a/db/migrate/20140327073052_create_contesting_projects.rb b/db/migrate/20140327073052_create_contesting_projects.rb new file mode 100644 index 000000000..b9dc336b2 --- /dev/null +++ b/db/migrate/20140327073052_create_contesting_projects.rb @@ -0,0 +1,12 @@ +class CreateContestingProjects < ActiveRecord::Migration + def change + create_table :contesting_projects do |t| + t.integer :project_id + t.string :contest_id + t.integer :user_id + t.string :description + + t.timestamps + end + end +end diff --git a/db/migrate/20140327082704_change_created_at_of_contests_to_created_on.rb b/db/migrate/20140327082704_change_created_at_of_contests_to_created_on.rb new file mode 100644 index 000000000..32d52d35a --- /dev/null +++ b/db/migrate/20140327082704_change_created_at_of_contests_to_created_on.rb @@ -0,0 +1,11 @@ +class ChangeCreatedAtOfContestsToCreatedOn < ActiveRecord::Migration + def self.up + rename_column :contests, :created_at, :created_on + rename_column :contests, :updated_at, :updated_on + end + + def self.down + rename_column :contests, :created_on, :created_at + rename_column :contests, :updated_on, :updated_at + end +end diff --git a/db/migrate/20140401121611_add_reward_to_contesting_projects.rb b/db/migrate/20140401121611_add_reward_to_contesting_projects.rb new file mode 100644 index 000000000..8ac71c94b --- /dev/null +++ b/db/migrate/20140401121611_add_reward_to_contesting_projects.rb @@ -0,0 +1,5 @@ +class AddRewardToContestingProjects < ActiveRecord::Migration + def change + add_column :contesting_projects, :reward, :string + end +end diff --git a/db/migrate/20140402023357_create_join_in_competitions.rb b/db/migrate/20140402023357_create_join_in_competitions.rb new file mode 100644 index 000000000..b7fba87f1 --- /dev/null +++ b/db/migrate/20140402023357_create_join_in_competitions.rb @@ -0,0 +1,10 @@ +class CreateJoinInCompetitions < ActiveRecord::Migration + def change + create_table :join_in_competitions do |t| + t.integer :user_id + t.integer :competition_id + + t.timestamps + end + end +end From 8fb185681ab13f0622302c8bfa2525d17bfbc992 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 4 Apr 2014 09:38:31 +0800 Subject: [PATCH 05/43] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2=E8=AF=B4=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/contests/_application_list.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/contests/_application_list.html.erb b/app/views/contests/_application_list.html.erb index 081a9f4de..4d79e1251 100644 --- a/app/views/contests/_application_list.html.erb +++ b/app/views/contests/_application_list.html.erb @@ -6,7 +6,7 @@ <% if User.current.logged? %>
- <%= toggle_link l(:button_contesting_as_project), 'put-bid-form' %> + <%= toggle_link l(:button_contesting_as_application), 'put-bid-form' %>
<% end %> From c86af5f483e66f624ebdeb89f4650f796526a1bb Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 4 Apr 2014 11:17:50 +0800 Subject: [PATCH 06/43] =?UTF-8?q?=E4=B8=8Eshow=5Fapplication=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=9A=84=E6=89=80=E6=9C=89=E5=86=85=E5=AE=B9=E6=94=B9?= =?UTF-8?q?=E4=B8=BAshow=5Fsoftapplication=EF=BC=8C=E4=BB=A5=E9=98=B2?= =?UTF-8?q?=E5=92=8C=E7=B3=BB=E7=BB=9F=E4=B8=AD=E7=9A=84application?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 6 +- app/views/contests/_application_list.html.erb | 15 -- app/views/contests/show_application.html.erb | 67 ------- app/views/layouts/base_newcontest.html.erb | 2 +- app/views/welcome/contest.html.erb | 2 +- config/routes.rb | 5 +- db/schema.rb | 175 +++++++++++------- lib/redmine.rb | 2 +- 8 files changed, 118 insertions(+), 156 deletions(-) delete mode 100644 app/views/contests/_application_list.html.erb delete mode 100644 app/views/contests/show_application.html.erb diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 39e9a2053..f65686628 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -3,8 +3,8 @@ class ContestsController < ApplicationController menu_item :respond menu_item :project, :only => :show_project - menu_item :application, :only => :show_application - before_filter :find_contest, :only => [:show_contest, :show_project, :show_application, :create,:destroy,:more,:back,:add,:new,:show_results, :set_reward, + menu_item :application, :only => :show_softapplication + before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :create,:destroy,:more,:back,:add,:new,:show_results, :set_reward, :show_contest_project, :show_contest_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] # added by fq @@ -218,7 +218,7 @@ class ContestsController < ApplicationController end ############ ##显示参赛的应用 - def show_application + def show_softapplication respond_to do |format| format.html { render :layout => 'base_newcontest' diff --git a/app/views/contests/_application_list.html.erb b/app/views/contests/_application_list.html.erb deleted file mode 100644 index 4d79e1251..000000000 --- a/app/views/contests/_application_list.html.erb +++ /dev/null @@ -1,15 +0,0 @@ - -<%= render_flash_messages %> - - - - <% if User.current.logged? %> - - <% end %> -
<%= l(:label_bidding_project) %> -
- <%= toggle_link l(:button_contesting_as_application), 'put-bid-form' %> -
-
- -<%#= render :partial=> "list_projects" %> diff --git a/app/views/contests/show_application.html.erb b/app/views/contests/show_application.html.erb deleted file mode 100644 index da06a7cb0..000000000 --- a/app/views/contests/show_application.html.erb +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - <% if User.current.logged? %> - - - - <% end %> -
- <%= render :partial => 'application_list' %> -
- diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index 1b3a99966..f41969ea4 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -92,7 +92,7 @@ <%=link_to "#{@contest.projects.where('is_public=1').count}", :controller => 'contests', :action => 'show_project' %> - <%=link_to "#{@contest.projects.where('is_public=1').count}", :controller => 'contests', :action => 'show_application' %> + <%=link_to "#{@contest.projects.where('is_public=1').count}", :controller => 'contests', :action => 'show_softapplication' %> <%= l(:label_participate) %> diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 222ff7dc6..cbc035b42 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -112,7 +112,7 @@
-

热门项目

+

热门项目

<%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}, :target => "_blank" %>
    diff --git a/config/routes.rb b/config/routes.rb index 7a782449b..181ecb0e0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do + resources :softapplications + + ## new added by linchun #新竞赛相关 resources :contests, only: [:index] do collection do @@ -30,7 +33,7 @@ RedmineApp::Application.routes.draw do match 'update_contest' , via: [:put] match 'show_contest' , via: :get match 'show_project' , via: :get - match 'show_application' , via: :get + match 'show_softapplication' , via: :get match 'show_participator' , via: :get match 'add' , via: [:get, :post] match 'create' , via: :post diff --git a/db/schema.rb b/db/schema.rb index 8c6085547..dab01aede 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,15 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140320022724) do - - create_table "a_user_watchers", :force => true do |t| - t.string "name" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "member_id" - end +ActiveRecord::Schema.define(:version => 20140404030103) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -31,6 +23,11 @@ ActiveRecord::Schema.define(:version => 20140320022724) 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 "andoidcontests", :force => true do |t| + 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 @@ -165,6 +162,28 @@ ActiveRecord::Schema.define(:version => 20140320022724) do add_index "comments", ["author_id"], :name => "index_comments_on_author_id" add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" + create_table "contesting_projects", :force => true do |t| + t.integer "project_id" + t.string "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contests", :force => true do |t| + t.string "name" + t.integer "budget" + 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 + end + create_table "courses", :force => true do |t| t.integer "tea_id" t.string "name" @@ -303,9 +322,9 @@ ActiveRecord::Schema.define(:version => 20140320022724) do add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" create_table "issue_relations", :force => true do |t| - t.integer "issue_from_id", :null => false - t.integer "issue_to_id", :null => false - t.string "relation_type", :null => false + t.integer "issue_from_id", :null => false + t.integer "issue_to_id", :null => false + t.string "relation_type", :default => "", :null => false t.integer "delay" end @@ -362,6 +381,13 @@ ActiveRecord::Schema.define(:version => 20140320022724) do add_index "issues", ["status_id"], :name => "index_issues_on_status_id" add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" + create_table "join_in_competitions", :force => true do |t| + t.integer "user_id" + t.integer "competition_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "join_in_contests", :force => true do |t| t.integer "user_id" t.integer "bid_id" @@ -473,22 +499,6 @@ ActiveRecord::Schema.define(:version => 20140320022724) do add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" add_index "messages", ["parent_id"], :name => "messages_parent_id" - create_table "messages_for_bids", :force => true do |t| - t.string "message" - t.integer "user_id" - t.integer "bid_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "messages_for_users", :force => true do |t| - t.integer "messager_id" - t.integer "user_id" - t.string "message" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "news", :force => true do |t| t.integer "project_id" t.string "title", :limit => 60, :default => "", :null => false @@ -518,6 +528,19 @@ ActiveRecord::Schema.define(:version => 20140320022724) do t.string "salt", :null => false end + create_table "open_source_projects", :force => true do |t| + t.string "name" + t.string "description", :default => "" + 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" @@ -548,23 +571,11 @@ ActiveRecord::Schema.define(:version => 20140320022724) do t.integer "watchers_count" t.integer "project_id" t.integer "project_type" - t.integer "gitlab_group_id", :limit => 8 - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 end - add_index "project_statuses", ["changesets_count"], :name => "index_project_statuses_on_changesets_count" add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" - add_index "project_statuses", ["watchers_count"], :name => "index_project_statuses_on_watchers_count" - - create_table "project_tags", :force => true do |t| - t.integer "project_id" - t.integer "tag_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "user_id" - end create_table "projects", :force => true do |t| t.string "name", :default => "", :null => false @@ -609,19 +620,33 @@ ActiveRecord::Schema.define(:version => 20140320022724) 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 + end + create_table "repositories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "url", :default => "", :null => false - t.string "login", :limit => 60, :default => "" - t.string "password", :default => "" - t.string "root_url", :default => "" + t.integer "project_id", :default => 0, :null => false + t.string "url", :default => "", :null => false + t.string "login", :limit => 60, :default => "" + t.string "password", :default => "" + t.string "root_url", :default => "" t.string "type" - t.string "path_encoding", :limit => 64 - t.string "log_encoding", :limit => 64 + t.string "path_encoding", :limit => 64 + t.string "log_encoding", :limit => 64 t.text "extra_info" t.string "identifier" - t.boolean "is_default", :default => false - t.string "git_project_id" + t.boolean "is_default", :default => false end add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" @@ -642,6 +667,26 @@ ActiveRecord::Schema.define(:version => 20140320022724) do t.datetime "updated_at", :null => false end + create_table "seems_rateable_cached_ratings", :force => true do |t| + t.integer "cacheable_id", :limit => 8 + t.string "cacheable_type" + t.float "avg", :null => false + t.integer "cnt", :null => false + t.string "dimension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "seems_rateable_rates", :force => true do |t| + t.integer "rater_id", :limit => 8 + t.integer "rateable_id" + t.string "rateable_type" + t.float "stars", :null => false + t.string "dimension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "settings", :force => true do |t| t.string "name", :default => "", :null => false t.text "value" @@ -652,9 +697,9 @@ ActiveRecord::Schema.define(:version => 20140320022724) do create_table "shares", :force => true do |t| t.date "created_on" - t.string "title" - t.string "share_type" t.string "url" + t.string "title" + t.integer "share_type" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.integer "project_id" @@ -662,10 +707,15 @@ ActiveRecord::Schema.define(:version => 20140320022724) do t.string "description" end - create_table "students", :force => true do |t| + create_table "softapplications", :force => true do |t| t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.string "description" + t.integer "app_type_id" + t.string "app_type_name" + t.string "android_min_version_available" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "students_for_courses", :force => true do |t| @@ -726,7 +776,7 @@ ActiveRecord::Schema.define(:version => 20140320022724) do create_table "tokens", :force => true do |t| t.integer "user_id", :default => 0, :null => false t.string "action", :limit => 30, :default => "", :null => false - t.string "value", :limit => 40 + t.string "value", :limit => 40, :default => "", :null => false t.datetime "created_on", :null => false end @@ -752,13 +802,12 @@ ActiveRecord::Schema.define(:version => 20140320022724) do t.integer "zip_code" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.integer "identity" t.string "technical_title" + t.integer "identity" t.string "student_id" t.string "teacher_realname" t.string "student_realname" t.string "location_city" - t.string "git_token" end create_table "user_grades", :force => true do |t| @@ -795,14 +844,6 @@ ActiveRecord::Schema.define(:version => 20140320022724) do add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" - create_table "user_tags", :force => true do |t| - t.integer "user_id" - t.integer "tag_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "users", :force => true do |t| t.string "login", :default => "", :null => false t.string "hashed_password", :limit => 40, :default => "", :null => false diff --git a/lib/redmine.rb b/lib/redmine.rb index cce178a55..88d6f73ee 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -280,7 +280,7 @@ end Redmine::MenuManager.map :contest_menu do |menu| menu.push :respond, :show_contest_contest_path, :caption => :label_user_response menu.push :project, :show_project_contest_path, :caption => :label_contest_project - menu.push :application, :show_application_contest_path, :caption => :label_contest_application + menu.push :application, :show_softapplication_contest_path, :caption => :label_contest_application # menu.push :result, { :controller => 'bids', :action => 'show_results' }, # :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p } end From a9e917144145d1a0d7c3e4b19cf0ef780552851c Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 4 Apr 2014 17:54:20 +0800 Subject: [PATCH 07/43] =?UTF-8?q?=E9=80=9A=E8=BF=87=E8=84=9A=E6=89=8B?= =?UTF-8?q?=E6=9E=B6=E6=96=B0=E5=BB=BA=E4=BA=86=E4=B8=80=E5=A5=97=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E4=B8=9C=E8=A5=BF=EF=BC=8C=E5=8C=85=E6=8B=AC?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84=E7=9B=B8=E5=BA=94=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=BB=BA=E4=BA=86=E5=8F=91=E5=B8=83=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E9=A1=B5=E9=9D=A2=EF=BC=8C=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=8A=9F=E8=83=BD=E6=9C=AA=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=EF=BC=8C=E7=95=8C=E9=9D=A2=E6=A0=BC=E5=BC=8F=E8=BF=98=E9=9C=80?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/softapplications.js | 2 + app/assets/stylesheets/softapplications.css | 4 + .../softapplications_controller.rb | 83 +++++++++++++++++++ app/helpers/softapplications_helper.rb | 2 + app/models/softapplication.rb | 3 + .../contests/_softapplication_list.html.erb | 16 ++++ .../contests/show_softapplication.html.erb | 63 ++++++++++++++ app/views/softapplications/_form.html.erb | 64 ++++++++++++++ app/views/softapplications/edit.html.erb | 6 ++ app/views/softapplications/index.html.erb | 33 ++++++++ app/views/softapplications/new.html.erb | 12 +++ app/views/softapplications/show.html.erb | 35 ++++++++ config/locales/zh.yml | 11 ++- .../20140404030103_create_softapplications.rb | 14 ++++ public/stylesheets/application.css | 10 ++- test/fixtures/softapplications.yml | 17 ++++ .../softapplications_controller_test.rb | 49 +++++++++++ .../helpers/softapplications_helper_test.rb | 4 + test/unit/softapplication_test.rb | 7 ++ 19 files changed, 433 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/softapplications.js create mode 100644 app/assets/stylesheets/softapplications.css create mode 100644 app/controllers/softapplications_controller.rb create mode 100644 app/helpers/softapplications_helper.rb create mode 100644 app/models/softapplication.rb create mode 100644 app/views/contests/_softapplication_list.html.erb create mode 100644 app/views/contests/show_softapplication.html.erb create mode 100644 app/views/softapplications/_form.html.erb create mode 100644 app/views/softapplications/edit.html.erb create mode 100644 app/views/softapplications/index.html.erb create mode 100644 app/views/softapplications/new.html.erb create mode 100644 app/views/softapplications/show.html.erb create mode 100644 db/migrate/20140404030103_create_softapplications.rb create mode 100644 test/fixtures/softapplications.yml create mode 100644 test/functional/softapplications_controller_test.rb create mode 100644 test/unit/helpers/softapplications_helper_test.rb create mode 100644 test/unit/softapplication_test.rb diff --git a/app/assets/javascripts/softapplications.js b/app/assets/javascripts/softapplications.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/softapplications.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/softapplications.css b/app/assets/stylesheets/softapplications.css new file mode 100644 index 000000000..afad32db0 --- /dev/null +++ b/app/assets/stylesheets/softapplications.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb new file mode 100644 index 000000000..3bddec62c --- /dev/null +++ b/app/controllers/softapplications_controller.rb @@ -0,0 +1,83 @@ +class SoftapplicationsController < ApplicationController + # GET /softapplications + # GET /softapplications.json + def index + @softapplications = Softapplication.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @softapplications } + end + end + + # GET /softapplications/1 + # GET /softapplications/1.json + def show + @softapplication = Softapplication.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @softapplication } + end + end + + # GET /softapplications/new + # GET /softapplications/new.json + def new + @softapplication = Softapplication.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @softapplication } + end + end + + # GET /softapplications/1/edit + def edit + @softapplication = Softapplication.find(params[:id]) + end + + # POST /softapplications + # POST /softapplications.json + def create + @softapplication = Softapplication.new(params[:softapplication]) + + respond_to do |format| + if @softapplication.save + format.html { redirect_to @softapplication, notice: 'Softapplication was successfully created.' } + format.json { render json: @softapplication, status: :created, location: @softapplication } + else + format.html { render action: "new" } + format.json { render json: @softapplication.errors, status: :unprocessable_entity } + end + end + end + + # PUT /softapplications/1 + # PUT /softapplications/1.json + def update + @softapplication = Softapplication.find(params[:id]) + + respond_to do |format| + if @softapplication.update_attributes(params[:softapplication]) + format.html { redirect_to @softapplication, notice: 'Softapplication was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @softapplication.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /softapplications/1 + # DELETE /softapplications/1.json + def destroy + @softapplication = Softapplication.find(params[:id]) + @softapplication.destroy + + respond_to do |format| + format.html { redirect_to softapplications_url } + format.json { head :no_content } + end + end +end diff --git a/app/helpers/softapplications_helper.rb b/app/helpers/softapplications_helper.rb new file mode 100644 index 000000000..e3cb6410d --- /dev/null +++ b/app/helpers/softapplications_helper.rb @@ -0,0 +1,2 @@ +module SoftapplicationsHelper +end diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb new file mode 100644 index 000000000..53440be81 --- /dev/null +++ b/app/models/softapplication.rb @@ -0,0 +1,3 @@ +class Softapplication < ActiveRecord::Base + attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id +end diff --git a/app/views/contests/_softapplication_list.html.erb b/app/views/contests/_softapplication_list.html.erb new file mode 100644 index 000000000..9a2576835 --- /dev/null +++ b/app/views/contests/_softapplication_list.html.erb @@ -0,0 +1,16 @@ + +<%= render_flash_messages %> + + + + <% if User.current.logged? %> + + <% end %> +
    <%= l(:label_bidding_project) %> +
    + + <%= link_to(l(:button_contesting_as_application), {:controller => 'softapplications', :action => 'new'}) %> +
    +
    + +<%#= render :partial=> "list_projects" %> diff --git a/app/views/contests/show_softapplication.html.erb b/app/views/contests/show_softapplication.html.erb new file mode 100644 index 000000000..b3e38d5f0 --- /dev/null +++ b/app/views/contests/show_softapplication.html.erb @@ -0,0 +1,63 @@ + + + + + + +
    + <%= render :partial => 'softapplication_list' %> +
    + diff --git a/app/views/softapplications/_form.html.erb b/app/views/softapplications/_form.html.erb new file mode 100644 index 000000000..5a046801f --- /dev/null +++ b/app/views/softapplications/_form.html.erb @@ -0,0 +1,64 @@ +<%= form_for(@softapplication) do |f| %> + + <% if @softapplication.errors.any? %> +
    +

    <%= pluralize(@softapplication.errors.count, "error") %> prohibited this softapplication from being saved:

    + +
      + <% @softapplication.errors.full_messages.each do |msg| %> +
    • <%= msg %>
    • + <% end %> +
    +
    + <% end %> + + + <%= l(:label_softapplication_name) %> + * : + <%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %> + <%= l(:label_softapplication_name_condition)%> +

    + + + <%= l(:label_softapplication_version_available) %> + * : + <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %> + +

    + + + <%= l(:label_softapplication_type) %> + * : + <%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %> + +

    + + + + <%= l(:label_softapplication_description) %> + * : + <%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %> + +

    + + +
    +
    + <%=l(:label_upload_softapplication_packets)%> :
    +

    + <%= render :partial => 'attachments/form' %> +

    +
    +
    + +
    +
    + <%=l(:label_upload_softapplication_photo)%> :(<%=l(:label_upload_softapplication_photo_condition)%>)
    +

    + <%= render :partial => 'attachments/form' %> +

    +
    +
    + +<% end %> + diff --git a/app/views/softapplications/edit.html.erb b/app/views/softapplications/edit.html.erb new file mode 100644 index 000000000..f93e091d2 --- /dev/null +++ b/app/views/softapplications/edit.html.erb @@ -0,0 +1,6 @@ +

    Editing softapplication

    + +<%= render 'form' %> + +<%= link_to 'Show', @softapplication %> | +<%= link_to 'Back', softapplications_path %> diff --git a/app/views/softapplications/index.html.erb b/app/views/softapplications/index.html.erb new file mode 100644 index 000000000..be9245876 --- /dev/null +++ b/app/views/softapplications/index.html.erb @@ -0,0 +1,33 @@ +

    Listing softapplications

    + + + + + + + + + + + + + + +<% @softapplications.each do |softapplication| %> + + + + + + + + + + + +<% end %> +
    NameDescriptionApp typeApp type nameAndroid min version availableUser
    <%= softapplication.name %><%= softapplication.description %><%= softapplication.app_type_id %><%= softapplication.app_type_name %><%= softapplication.android_min_version_available %><%= softapplication.user_id %><%= link_to 'Show', softapplication %><%= link_to 'Edit', edit_softapplication_path(softapplication) %><%= link_to 'Destroy', softapplication, method: :delete, data: { confirm: 'Are you sure?' } %>
    + +
    + +<%= link_to 'New Softapplication', new_softapplication_path %> diff --git a/app/views/softapplications/new.html.erb b/app/views/softapplications/new.html.erb new file mode 100644 index 000000000..40c6a4059 --- /dev/null +++ b/app/views/softapplications/new.html.erb @@ -0,0 +1,12 @@ +

    <%=l(:label_release_softapplication)%>

    + + +<%= labelled_form_for @softapplication, :url => {:controller => 'softapplications', :action => 'create'}, method: :post do |f| %> +
    + <%= render :partial => 'form', :locals => { :f => f } %> + <%= submit_tag l(:button_create) %> + + <% end %> +
    \ No newline at end of file diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb new file mode 100644 index 000000000..faf8a93eb --- /dev/null +++ b/app/views/softapplications/show.html.erb @@ -0,0 +1,35 @@ +

    <%= notice %>

    + +

    + Name: + <%= @softapplication.name %> +

    + +

    + Description: + <%= @softapplication.description %> +

    + +

    + App type: + <%= @softapplication.app_type_id %> +

    + +

    + App type name: + <%= @softapplication.app_type_name %> +

    + +

    + Android min version available: + <%= @softapplication.android_min_version_available %> +

    + +

    + User: + <%= @softapplication.user_id %> +

    + + +<%= link_to 'Edit', edit_softapplication_path(@softapplication) %> | +<%= link_to 'Back', softapplications_path %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 448690b46..ffcfd1296 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1826,4 +1826,13 @@ zh: label_contest_application: 参赛应用 button_contesting_as_project: 我要参赛(新建项目) button_contesting_as_application: 我要参赛(发布应用) - + 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_softapplication_name: 应用名称 + label_softapplication_description: 应用简介 + label_softapplication_type: 应用分类 + label_softapplication_version_available: 适配版本 + label_softapplication_developer: 开发者 + label_softapplication_name_condition: 25个汉字以内(50个字符) diff --git a/db/migrate/20140404030103_create_softapplications.rb b/db/migrate/20140404030103_create_softapplications.rb new file mode 100644 index 000000000..f9094d9c9 --- /dev/null +++ b/db/migrate/20140404030103_create_softapplications.rb @@ -0,0 +1,14 @@ +class CreateSoftapplications < ActiveRecord::Migration + def change + create_table :softapplications do |t| + t.string :name + t.string :description + t.integer :app_type_id + t.string :app_type_name + t.string :android_min_version_available + t.integer :user_id + + t.timestamps + end + end +end diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index e60316841..514cb7685 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -2693,4 +2693,12 @@ div.repos_explain{ margin-left: -220px; } - +/* new linchun compitition */ +.contest_underline{ + margin:1; + padding:1; + width:900px; + height:0.5px; + background-color:#aaa; + overflow:hidden +} diff --git a/test/fixtures/softapplications.yml b/test/fixtures/softapplications.yml new file mode 100644 index 000000000..0ab48299f --- /dev/null +++ b/test/fixtures/softapplications.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + name: MyString + description: MyString + app_type_id: 1 + app_type_name: MyString + android_min_version_available: MyString + user_id: 1 + +two: + name: MyString + description: MyString + app_type_id: 1 + app_type_name: MyString + android_min_version_available: MyString + user_id: 1 diff --git a/test/functional/softapplications_controller_test.rb b/test/functional/softapplications_controller_test.rb new file mode 100644 index 000000000..8c5611cb9 --- /dev/null +++ b/test/functional/softapplications_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class SoftapplicationsControllerTest < ActionController::TestCase + setup do + @softapplication = softapplications(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:softapplications) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create softapplication" do + assert_difference('Softapplication.count') do + post :create, softapplication: { android_min_version_available: @softapplication.android_min_version_available, app_type_id: @softapplication.app_type_id, app_type_name: @softapplication.app_type_name, description: @softapplication.description, name: @softapplication.name, user_id: @softapplication.user_id } + end + + assert_redirected_to softapplication_path(assigns(:softapplication)) + end + + test "should show softapplication" do + get :show, id: @softapplication + assert_response :success + end + + test "should get edit" do + get :edit, id: @softapplication + assert_response :success + end + + test "should update softapplication" do + put :update, id: @softapplication, softapplication: { android_min_version_available: @softapplication.android_min_version_available, app_type_id: @softapplication.app_type_id, app_type_name: @softapplication.app_type_name, description: @softapplication.description, name: @softapplication.name, user_id: @softapplication.user_id } + assert_redirected_to softapplication_path(assigns(:softapplication)) + end + + test "should destroy softapplication" do + assert_difference('Softapplication.count', -1) do + delete :destroy, id: @softapplication + end + + assert_redirected_to softapplications_path + end +end diff --git a/test/unit/helpers/softapplications_helper_test.rb b/test/unit/helpers/softapplications_helper_test.rb new file mode 100644 index 000000000..ad8173602 --- /dev/null +++ b/test/unit/helpers/softapplications_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class SoftapplicationsHelperTest < ActionView::TestCase +end diff --git a/test/unit/softapplication_test.rb b/test/unit/softapplication_test.rb new file mode 100644 index 000000000..b3872eec5 --- /dev/null +++ b/test/unit/softapplication_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SoftapplicationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From bad170fdb2070f47ae3f571a4a4f4e1580356d5c Mon Sep 17 00:00:00 2001 From: nieguanghui Date: Wed, 9 Apr 2014 09:25:24 +0800 Subject: [PATCH 08/43] =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../softapplications_controller.rb | 10 ++- app/models/attachment.rb | 3 +- app/models/homework_attach.rb | 2 +- app/models/softapplication.rb | 1 + app/views/softapplications/new.html.erb | 64 +++++++++++++++++-- config/routes.rb | 4 +- 6 files changed, 71 insertions(+), 13 deletions(-) diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index 3bddec62c..e6fbd2e0e 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -14,7 +14,7 @@ class SoftapplicationsController < ApplicationController # GET /softapplications/1.json def show @softapplication = Softapplication.find(params[:id]) - + respond_to do |format| format.html # show.html.erb format.json { render json: @softapplication } @@ -41,7 +41,7 @@ class SoftapplicationsController < ApplicationController # POST /softapplications.json def create @softapplication = Softapplication.new(params[:softapplication]) - + @softapplication.save_attachments(params[:attachments]) respond_to do |format| if @softapplication.save format.html { redirect_to @softapplication, notice: 'Softapplication was successfully created.' } @@ -68,6 +68,12 @@ class SoftapplicationsController < ApplicationController end end end + + + def add_attach + @softapplication = Softapplication.find(params[:id]) + @softapplication.save_attachments(params[:attachments]) + end # DELETE /softapplications/1 # DELETE /softapplications/1.json diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 768be578f..8e607a685 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -21,6 +21,7 @@ require "fileutils" class Attachment < ActiveRecord::Base belongs_to :container, :polymorphic => true belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" + belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'" belongs_to :author, :class_name => "User", :foreign_key => "author_id" validates_presence_of :filename, :author @@ -33,7 +34,7 @@ class Attachment < ActiveRecord::Base acts_as_event :title => :filename, :url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id, :filename => o.filename}} - acts_as_activity_provider :type => 'files', + acts_as_activity_provider :type => 'files', :permission => :view_files, :author_key => :author_id, :find_options => {:select => "#{Attachment.table_name}.*", diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index 5ce08a0a8..fb743ab5c 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -1,5 +1,5 @@ class HomeworkAttach < ActiveRecord::Base - include Redmine::SafeAttributes + include Redmine::SafeAttributes belongs_to :user belongs_to :bid diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb index 53440be81..f661ea74b 100644 --- a/app/models/softapplication.rb +++ b/app/models/softapplication.rb @@ -1,3 +1,4 @@ class Softapplication < ActiveRecord::Base attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id + acts_as_attachable end diff --git a/app/views/softapplications/new.html.erb b/app/views/softapplications/new.html.erb index 40c6a4059..820165819 100644 --- a/app/views/softapplications/new.html.erb +++ b/app/views/softapplications/new.html.erb @@ -1,12 +1,64 @@ -

    <%=l(:label_release_softapplication)%>

    - -<%= labelled_form_for @softapplication, :url => {:controller => 'softapplications', :action => 'create'}, method: :post do |f| %> -
    - <%= render :partial => 'form', :locals => { :f => f } %> - <%= submit_tag l(:button_create) %> +
    + <%= 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| %> +
    + + <%= l(:label_attachment_plural) %> + + + <%= l(:label_softapplication_name) %> + * : <%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %> + <%= l(:label_softapplication_name_condition)%> + +
    +
    + + + <%= l(:label_softapplication_version_available) %> + * : <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %> + + +
    +
    + + + <%= l(:label_softapplication_type) %> + + * : <%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %> + + +
    +
    + + + <%= l(:label_softapplication_description) %> + * : <%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %> + + +
    +
    + <%= render_flash_messages %> +

    + <%= render :partial => 'attachments/form' %> +

    +
    + <%= submit_tag l(:button_create), :onclick => "return true" %> + +
    + <% end %>
    \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 181ecb0e0..c4ad9cdff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,9 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do - resources :softapplications - - + resources :softapplications ## new added by linchun #新竞赛相关 resources :contests, only: [:index] do collection do From 92078e6ac832ae908999cf42d42015f4fd66880a Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 9 Apr 2014 10:24:44 +0800 Subject: [PATCH 09/43] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/contest.html.erb | 73 ++++++++++++++++++------------ 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index cbc035b42..5b00d4d17 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -100,45 +100,62 @@
    <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %>
    -
    - + +
    + + 竞赛总量: + +
    + + 竞赛总人数: + +
    + + 竞赛项目或应用总数: + +
- +
+

最新参赛应用

+ <%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1, :host => Setting.contest_domain}, :target => "_blank" %> +
+
    + <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[10]) %> +
  • +

    + <%= link_to( contest.name, respond_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", + :style => "margin-left: 28px;", :target => "_blank") %> +

    +

    + <%= content_tag "span", contest.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => contest.description %> +

    +
  • + <% end %> +
+
+
    @@ -210,48 +225,6 @@
- - - - - -
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 78f5e9726..352afe2a0 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1837,3 +1837,4 @@ zh: label_softapplication_developer: 开发者 label_softapplication_name_condition: 25个汉字以内(50个字符) label_user_login_softapplication_board: 您还没有登录,请登录后参与应用评价。 + label_contest_description_no: 暂无描述。 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 41524a5de..c5397187b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do - + ##new added by linchun #以发布应用的形式参与竞赛 resources :softapplications do collection do @@ -38,6 +38,7 @@ RedmineApp::Application.routes.draw do match 'new' , via: :post end member do + match 'add_softapplication' match 'update_contest' , via: [:put] match 'show_contest' , via: :get match 'show_project' , via: :get diff --git a/db/schema.rb b/db/schema.rb index dab01aede..8b443264f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140404030103) do +ActiveRecord::Schema.define(:version => 20140411005214) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -23,11 +23,6 @@ ActiveRecord::Schema.define(:version => 20140404030103) 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 "andoidcontests", :force => true do |t| - 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 @@ -172,6 +167,16 @@ ActiveRecord::Schema.define(:version => 20140404030103) do t.string "reward" end + create_table "contesting_softapplications", :force => true do |t| + t.integer "softapplication_id" + t.integer "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + create_table "contests", :force => true do |t| t.string "name" t.integer "budget" @@ -528,19 +533,6 @@ ActiveRecord::Schema.define(:version => 20140404030103) do t.string "salt", :null => false end - create_table "open_source_projects", :force => true do |t| - t.string "name" - t.string "description", :default => "" - 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" @@ -620,21 +612,6 @@ ActiveRecord::Schema.define(:version => 20140404030103) 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 - end - create_table "repositories", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.string "url", :default => "", :null => false @@ -716,6 +693,9 @@ ActiveRecord::Schema.define(:version => 20140404030103) do t.integer "user_id" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.integer "contest_id" + t.integer "softapplication_id" + t.integer "is_public" end create_table "students_for_courses", :force => true do |t| From a4df4cf893d246796491069a0c2728c5db99bd7c Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 11 Apr 2014 16:40:09 +0800 Subject: [PATCH 13/43] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E5=92=8C=E5=8F=82=E4=B8=8E=E7=AB=9E=E8=B5=9B=E7=9A=84=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E5=BA=94=E7=94=A8=E4=B9=8B=E9=97=B4=E7=9A=84=E5=85=B3?= =?UTF-8?q?=E8=81=94=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 9 +++++---- app/helpers/contests_helper.rb | 16 +++++++++++++--- app/models/contest.rb | 4 ++-- app/models/contesting_project.rb | 5 +++++ app/models/softapplication.rb | 1 + app/models/user.rb | 1 + app/views/contests/_contest_list.html.erb | 7 ++++--- .../contests/_softapplication_list.html.erb | 3 +-- app/views/contests/show_softapplication.html.erb | 4 ++-- app/views/softapplications/show.html.erb | 5 +---- config/locales/zh.yml | 3 +++ config/routes.rb | 1 + 12 files changed, 39 insertions(+), 20 deletions(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index acc874752..4ca1c1933 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -157,7 +157,7 @@ class ContestsController < ApplicationController contests = Contest.where('parent_id = ?', @contest.id) @softapplications = [] for contest in contests - @softapplications += contest.softapplications + @softapplications += contest.contesting_softapplications end respond_to do |format| @@ -240,6 +240,7 @@ class ContestsController < ApplicationController # @user = @contest.user @softapplication = Softapplication.all + @contesting_softapplication = @contest.contesting_softapplications # @temp = [] # @softapplicationt.each do |pro| @@ -292,15 +293,15 @@ class ContestsController < ApplicationController def add_softapplication softapplication = Softapplication.find(params[:contest]) contest_message = params[:contest_for_save][:contest_message] - if Softapplication.where("softapplication_id = ? and contest_id = ?", softapplication.id, @contest.id).size == 0 - if Softapplication.create_contesting(@contest.id, softapplication.id, contest_message) + if ContestingSoftapplication.where("softapplication_id = ? and contest_id = ?", softapplication.id, @contest.id).size == 0 + if ContestingSoftapplication.create_contesting(@contest.id, softapplication.id, contest_message) flash.now[:notice] = l(:label_bidding_contest_succeed) end else flash.now[:error] = l(:label_bidding_fail) end - @softapplication = @contest.softapplications + @contesting_softapplication = @contest.contesting_softapplications render :text => params.to_json # respond_to do |format| diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb index d48342b59..00fb5b77c 100644 --- a/app/helpers/contests_helper.rb +++ b/app/helpers/contests_helper.rb @@ -105,7 +105,7 @@ module ContestsHelper contests = Contest.find(:id) @softapplications = [] for contest in contests - @softapplications += contest.contesting_projects + @softapplications += contest.contesting_softapplications end @projects.count end @@ -122,6 +122,16 @@ module ContestsHelper @users.count end + def count_contest_softapplication_user + contests = Contest.find(:id) + @users = [] + for contest in contests + for project in contest.softapplications + @users += softapplication.users + end + end + @users.count + end def im_watching_student_id? contest people = [] people << contest.author @@ -152,8 +162,8 @@ module ContestsHelper end def select_option_app_helper options tmp = Hash.new - options.each do |project| - tmp[project.name] = project.id + options.each do |option| + tmp[option.name] = option.id end tmp end diff --git a/app/models/contest.rb b/app/models/contest.rb index b3e6c4f77..edc252574 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -5,8 +5,8 @@ class Contest < ActiveRecord::Base belongs_to :author, :class_name => 'User', :foreign_key => :author_id has_many :contesting_projects, :dependent => :destroy has_many :projects, :through => :contesting_projects - has_many :softapplications, :dependent => :destroy - # has_many :softapplications, :through => :softapplications + has_many :contesting_softapplications, :dependent => :destroy + has_many :softapplications, :through => :contesting_softapplications has_many :projects_member, :class_name => 'User', :through => :projects has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy diff --git a/app/models/contesting_project.rb b/app/models/contesting_project.rb index 773c04c68..c0c360548 100644 --- a/app/models/contesting_project.rb +++ b/app/models/contesting_project.rb @@ -19,6 +19,11 @@ class ContestingProject < ActiveRecord::Base :project_id => project_id, :description => description) end + def self.cerate_softapplication_contesting(contest_id, softapplication_id, description = nil) + self.create_softapplication(:user_id => User.current.id, :contest_id => contest_id, + :softapplication_id => softapplication_id, :description => description) + end + def update_reward(which) self.update_attribute(:reward,which) end diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb index 4cf76001a..e63eb428d 100644 --- a/app/models/softapplication.rb +++ b/app/models/softapplication.rb @@ -2,6 +2,7 @@ class Softapplication < ActiveRecord::Base attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id acts_as_attachable has_many :journals_for_messages, :as => :jour, :dependent => :destroy + has_many :contesting_softapplications, :dependent => :destroy belongs_to :user belongs_to :contest diff --git a/app/models/user.rb b/app/models/user.rb index 1aa1e0382..0255b0da6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -79,6 +79,7 @@ class User < Principal ## added by xianbo for delete has_many :biding_projects, :dependent => :destroy has_many :contesting_projects, :dependent => :destroy + has_many :contesting_softapplications, :dependent => :destroy belongs_to :softapplication, :foreign_key => 'id', :dependent => :destroy ##ended by xianbo diff --git a/app/views/contests/_contest_list.html.erb b/app/views/contests/_contest_list.html.erb index cdc390410..5a8bf6890 100644 --- a/app/views/contests/_contest_list.html.erb +++ b/app/views/contests/_contest_list.html.erb @@ -18,9 +18,10 @@ - <%= l(:label_x_biding_project, :count => contest.contesting_projects.count) %>(<%= link_to contest.contesting_projects.count %>) - <%= l(:label_x_bids_responses, :count => contest.commit) %>(<%= link_to contest.commit, respond_path(contest) %>) - <%= l(:label_x_followers, :count => contest.watcher_users.count) %>(<%= link_to contest.watcher_users.count, respond_path(contest) %>) + <%= l(:label_contest_project, :count => contest.contesting_projects.count) %>(<%= link_to contest.contesting_projects.count %>) + <%= l(:label_contest_softapplication, :count => contest.contesting_softapplications.count) %>(<%= link_to contest.contesting_softapplications.count %>) + <%= l(:label_contest_response, :count => contest.commit) %>(<%= link_to contest.commit, respond_path(contest) %>) + <%= l(:label_contest_watchers, :count => contest.watcher_users.count) %>(<%= link_to contest.watcher_users.count, respond_path(contest) %>) diff --git a/app/views/contests/_softapplication_list.html.erb b/app/views/contests/_softapplication_list.html.erb index 895926e38..221dc9dcf 100644 --- a/app/views/contests/_softapplication_list.html.erb +++ b/app/views/contests/_softapplication_list.html.erb @@ -12,5 +12,4 @@ <% end %> - -<%= render :partial=> "list_softapplications",:locals => {:softapplication => softapplication,:contest => @contest }%> +<%= render :partial=> "list_softapplications",:locals => {:contesting_softapplication => contesting_softapplication,:contest => @contest }%> diff --git a/app/views/contests/show_softapplication.html.erb b/app/views/contests/show_softapplication.html.erb index 725992062..fd643a0bd 100644 --- a/app/views/contests/show_softapplication.html.erb +++ b/app/views/contests/show_softapplication.html.erb @@ -60,7 +60,7 @@
- <%= form_for "contest_for_save", :remote=>true, :url => {:controller => 'contests', :action => 'add_softapplication'}, :update => "softapplication_list", :complete => '$("#put-bid-form").hide();' do |f| %> + <%= form_for "contest_for_save", :remote=>true, :url => {:controller => 'contests', :action => 'add_softapplication'}, :update => "contesting_softapplication_list", :complete => '$("#put-bid-form").hide();' do |f| %> @@ -97,6 +97,6 @@
- <%#= render :partial => 'softapplication_list', :locals => {:softapplication => @softapplication,:contest => @contest} %> + <%= render :partial => 'softapplication_list', :locals => {:contesting_softapplication => @contesting_softapplication,:contest => @contest} %>
diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index d0043564a..e3e64900c 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -16,10 +16,7 @@ - - - - +
<%= select_tag 'contest', options_for_select(select_option_app_helper(@softapplication)), :name => 'contest', :class => 'grayline' %>开发者:<%= @softapplication.user.name %> 系统支持:<%= @softapplication.android_min_version_available %>
已提交竞赛: <%= @softapplication.contest.name%>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 352afe2a0..f5f120925 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1823,6 +1823,9 @@ zh: label_nextstep: 下一步 label_participate: 参赛者 label_contest_project: 参赛项目 + label_contest_softapplication: 参赛应用 + label_contest_response: 用户反馈 + label_contest_watchers: 关注人员 label_contest_application: 参赛应用 button_contesting_as_project: 我要参赛(新建项目) button_contesting_as_application: 我要参赛(发布应用) diff --git a/config/routes.rb b/config/routes.rb index c5397187b..360c9399e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -45,6 +45,7 @@ RedmineApp::Application.routes.draw do match 'show_softapplication', via: :get match 'show_participator' , via: :get match 'add' , via: [:get, :post] + match 'add_softapplication' , via: [:get, :post] match 'create' , via: :post match 'settings' , via: [:get, :post] end From 64895a75ed2013ef7812e58412a1f8b812126102 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 11 Apr 2014 17:16:22 +0800 Subject: [PATCH 14/43] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=88=AA=E5=9B=BE+=E5=BA=94=E7=94=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 2 +- app/controllers/contests_controller.rb | 11 +++++------ app/controllers/softapplications_controller.rb | 4 ++++ app/helpers/application_helper.rb | 8 ++++++++ app/models/contesting_project.rb | 6 +----- .../contests/show_softapplication.html.erb | 2 +- app/views/softapplications/show.html.erb | 17 ++++++++++++++++- 7 files changed, 36 insertions(+), 14 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 01d2ea890..0c42c405d 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -172,7 +172,7 @@ private @attachment = Attachment.find(params[:id]) # Show 404 if the filename in the url is wrong raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename - unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' + unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' @project = @attachment.project end rescue ActiveRecord::RecordNotFound diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 4ca1c1933..ccc5c51ab 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -294,7 +294,7 @@ class ContestsController < ApplicationController softapplication = Softapplication.find(params[:contest]) contest_message = params[:contest_for_save][:contest_message] if ContestingSoftapplication.where("softapplication_id = ? and contest_id = ?", softapplication.id, @contest.id).size == 0 - if ContestingSoftapplication.create_contesting(@contest.id, softapplication.id, contest_message) + if ContestingSoftapplication.create_softapplication_contesting(@contest.id, softapplication.id, contest_message) flash.now[:notice] = l(:label_bidding_contest_succeed) end else @@ -303,12 +303,11 @@ class ContestsController < ApplicationController @contesting_softapplication = @contest.contesting_softapplications - render :text => params.to_json - # respond_to do |format| + respond_to do |format| - # format.html { redirect_to :back } - # format.js - # end + format.html { redirect_to :back } + format.js + end end ## 新建留言 def create diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index 0a0f25419..a1410722f 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -15,6 +15,10 @@ class SoftapplicationsController < ApplicationController def show @softapplication = Softapplication.find(params[:id]) @jours = @softapplication.journals_for_messages.order('created_on DESC') + @image_results = [] + @softapplication.attachments.each do |f| + f.image? ? @image_results << f : @image_results + end @limit = 10 @feedback_count = @jours.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 344238e8b..8533c4012 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -111,6 +111,14 @@ module ApplicationHelper link_to text, url, html_options end + def link_to_attachment_img(attachment, options={}) + text = options.delete(:text) || attachment.filename + route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path + html_options = options.slice!(:only_path) + url = send(route_method, attachment, attachment.filename, options) + image_tag url, html_options + end + # Generates a link to a SCM revision # Options: # * :text - Link text (default to the formatted revision) diff --git a/app/models/contesting_project.rb b/app/models/contesting_project.rb index c0c360548..cb2a7fe39 100644 --- a/app/models/contesting_project.rb +++ b/app/models/contesting_project.rb @@ -18,11 +18,7 @@ class ContestingProject < ActiveRecord::Base self.create(:user_id => User.current.id, :contest_id => contest_id, :project_id => project_id, :description => description) end - - def self.cerate_softapplication_contesting(contest_id, softapplication_id, description = nil) - self.create_softapplication(:user_id => User.current.id, :contest_id => contest_id, - :softapplication_id => softapplication_id, :description => description) - end + def update_reward(which) self.update_attribute(:reward,which) diff --git a/app/views/contests/show_softapplication.html.erb b/app/views/contests/show_softapplication.html.erb index fd643a0bd..3d6a1d735 100644 --- a/app/views/contests/show_softapplication.html.erb +++ b/app/views/contests/show_softapplication.html.erb @@ -96,7 +96,7 @@ -
+
<%= render :partial => 'softapplication_list', :locals => {:contesting_softapplication => @contesting_softapplication,:contest => @contest} %>
diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index e3e64900c..03e499250 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -1,3 +1,12 @@ + + +

<%= notice %>

@@ -32,8 +41,14 @@
软件截图:
-
+
+ <% @image_results.take(4).each do |attachment| %> + <%= link_to_attachment_img attachment, :class => "soft-application", :download => "true" %> + <% end %> +
+
+
From 4ccc4548a1e1817ddcf0d8574cd74b5eaee4cc46 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 11 Apr 2014 18:02:26 +0800 Subject: [PATCH 15/43] xiug --- app/views/softapplications/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index 03e499250..d82a130e1 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -39,7 +39,7 @@
-
+
软件截图:
<% @image_results.take(4).each do |attachment| %> From f9e5dd47f6f2e29f7036712729ee02fec5c808f7 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 11 Apr 2014 21:56:35 +0800 Subject: [PATCH 16/43] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=AB=9E?= =?UTF-8?q?=E8=B5=9B=E5=88=97=E8=A1=A8=E7=9A=84=E6=8E=92=E5=BA=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/contests_helper.rb | 8 ++++---- app/views/layouts/base_newcontest.html.erb | 2 +- app/views/layouts/base_projects.html.erb | 2 +- app/views/softapplications/show.html.erb | 4 +++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb index 00fb5b77c..93af48b4c 100644 --- a/app/helpers/contests_helper.rb +++ b/app/helpers/contests_helper.rb @@ -62,12 +62,12 @@ module ContestsHelper content = ''.html_safe case state when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'))) - content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'})) + content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'}, :class=>"selected"), :class=>"selected") when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), contest_path(:contest_sort_type => '1'), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), contest_path(:contest_sort_type => '0'))) + content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'}, :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'})) end content = content_tag('ul', content) content_tag('div', content, :class => "tabs") diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index f41969ea4..14598db31 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -92,7 +92,7 @@ <%=link_to "#{@contest.projects.where('is_public=1').count}", :controller => 'contests', :action => 'show_project' %> - <%=link_to "#{@contest.projects.where('is_public=1').count}", :controller => 'contests', :action => 'show_softapplication' %> + <%=link_to "#{@contest.contesting_softapplications.count}", :controller => 'contests', :action => 'show_softapplication' %> <%= l(:label_participate) %> diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 1a4ed1b47..af9ad87eb 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -53,7 +53,7 @@ <% @project = Project.find_by_id(@project.id)%> - + - +

- + + + + : + + +
+
上传应用软件包或应用截图 <%= render_flash_messages %> diff --git a/app/views/softapplications/new.html.erb.BASE.erb b/app/views/softapplications/new.html.erb.BASE.erb new file mode 100644 index 000000000..40c6a4059 --- /dev/null +++ b/app/views/softapplications/new.html.erb.BASE.erb @@ -0,0 +1,12 @@ +

<%=l(:label_release_softapplication)%>

+ + +<%= labelled_form_for @softapplication, :url => {:controller => 'softapplications', :action => 'create'}, method: :post do |f| %> +
+ <%= render :partial => 'form', :locals => { :f => f } %> + <%= submit_tag l(:button_create) %> + + <% end %> +
\ No newline at end of file diff --git a/app/views/softapplications/new.html.erb.LOCAL.erb b/app/views/softapplications/new.html.erb.LOCAL.erb new file mode 100644 index 000000000..bf4e19f3f --- /dev/null +++ b/app/views/softapplications/new.html.erb.LOCAL.erb @@ -0,0 +1,12 @@ +

<%=l(:label_release_softapplication)%>

+ + +<%= labelled_form_for @softapplication, :url => {:controller => 'softapplications', :action => 'create'}, method: :post do |f| %> +
+ <%= render :partial => 'form', :locals => { :f => f } %> + <%= submit_tag l(:button_create) %> + + <% end %> +
\ No newline at end of file diff --git a/app/views/softapplications/new.html.erb.REMOTE.erb b/app/views/softapplications/new.html.erb.REMOTE.erb new file mode 100644 index 000000000..820165819 --- /dev/null +++ b/app/views/softapplications/new.html.erb.REMOTE.erb @@ -0,0 +1,64 @@ +

<%= l(:label_release_softapplication)%>

+ + +
+ <%= 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| %> +
+ + <%= l(:label_attachment_plural) %> + +
+ + : + + +
+
+ + + + : + + +
+
+ + + + + : + + +
+
+ + + + : + + +
+
+ <%= render_flash_messages %> +

+ <%= render :partial => 'attachments/form' %> +

+ + <%= submit_tag l(:button_create), :onclick => "return true" %> + + + + <% end %> + \ No newline at end of file diff --git a/app/views/softapplications/new_message.js.erb b/app/views/softapplications/new_message.js.erb new file mode 100644 index 000000000..ea1d02a33 --- /dev/null +++ b/app/views/softapplications/new_message.js.erb @@ -0,0 +1,5 @@ +$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => @content})) %>'); +$('#softapplication_message_reference_user_id').val("<%= @id%>"); +showAndScrollTo("pre_show", "softapplication_message_reference_user_id"); + + diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index a01006cbb..c5ecac2c1 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -9,7 +9,7 @@

<%= notice %>

- <%= image_tag(url_to_avatar(@user), :class => "avatar2") %> +
- + - + + + +
<%= image_tag(url_to_avatar(@project), :class => 'avatar2') %>
<%= @project.name %> diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index d82a130e1..a01006cbb 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -9,9 +9,11 @@

<%= notice %>

+ <%= image_tag(url_to_avatar(@user), :class => "avatar2") %>
<%= image_tag(url_to_avatar(@softapplication), :class => "avatar2") %> + From 77812034740e208fa2e88eb3b6ef3b4de72dee44 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Sat, 12 Apr 2014 19:01:48 +0800 Subject: [PATCH 17/43] =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=8C=89tag=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=97=B6=EF=BC=8C=E5=8F=AA=E6=9F=A5=E9=80=89=E5=AE=9A?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=B8=AD=E7=9A=84=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/tags_controller.rb | 9 +++++++-- app/helpers/attachments_helper.rb | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 71c9b0e7e..3a7e0f635 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -178,7 +178,8 @@ private attachments_results = nil @obj_pages = nil @obj = nil - + @result = nil + # 这里为了提高系统的响应速度 把搜索结果放到case中去了 case obj_flag when '1' then @@ -198,7 +199,11 @@ private @obj_pages,@forums_results,@results_count = for_pagination(get_forums_by_tag(selected_tags)) when '6' @obj = Attachment.find_by_id(obj_id) - @obj_pages, attachments_results, @results_count = for_pagination(get_attachments_by_tag(selected_tags)) + + # modifed by Long Jun + # this is used to find the attachments that came from the same project and tagged with the same tag. + @result = get_attachments_by_project_tag(selected_tags, @obj) + @obj_pages, attachments_results, @results_count = for_pagination(@result) else @obj = nil end diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 7d5db3012..4d51a84ce 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -85,6 +85,22 @@ module AttachmentsHelper Attachment.tagged_with(tag_name).order('created_on desc') end + # this method is used to get all attachments that from one project and tagged one tag + # added by Long Jun + def get_attachments_by_project_tag(tag_name, obj) + @project_id =nil + if obj.container_type == 'Version' + @project_id = Version.find(obj.container_id).project_id + + elsif obj.container_type == 'Project' + @project_id = obj.container_id + + end + Attachment.tagged_with(tag_name).order('created_on desc').where("(container_id = :project_id and container_type = 'Project') or + (container_id in (select id from versions where project_id =:project_id) and container_type = 'Version')", {:project_id => @project_id}) + end + + def render_attachments_for_new_project(project, limit=nil) # 查询条件 params[:q] ||= "" From 98b6493b9185fd5773f72de81fee7a6a672a52db Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Mon, 14 Apr 2014 09:50:36 +0800 Subject: [PATCH 18/43] =?UTF-8?q?=E7=BB=99=E5=BA=94=E7=94=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BC=80=E5=8F=91=E4=BA=BA=E5=91=98=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=8F=8A=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/contesting_softapplication.rb | 15 +++++ app/models/softapplication.rb | 2 +- .../contests/_list_softapplications.html.erb | 40 ++++++++++++ app/views/contests/add_softapplication.js.erb | 4 ++ .../softapplications/_message_history.erb | 32 ++++++++++ app/views/softapplications/_new_message.erb | 53 +++++++++++++++ app/views/softapplications/_pre_show.html.erb | 13 ++++ app/views/softapplications/back.js.erb | 2 + .../softapplications/create_message.js.erb | 4 ++ app/views/softapplications/more.js.erb | 2 + app/views/softapplications/new.html.erb | 9 ++- .../softapplications/new.html.erb.BASE.erb | 12 ++++ .../softapplications/new.html.erb.LOCAL.erb | 12 ++++ .../softapplications/new.html.erb.REMOTE.erb | 64 +++++++++++++++++++ app/views/softapplications/new_message.js.erb | 5 ++ app/views/softapplications/show.html.erb | 9 ++- config/locales/zh.yml | 6 +- ...5850_add_contest_id_to_softapplications.rb | 5 ++ ..._softapplication_id_to_softapplications.rb | 5 ++ ...3234_create_contesting_softapplications.rb | 12 ++++ ...d_reward_to_contesting_softapplications.rb | 5 ++ ...05214_add_is_public_to_softapplications.rb | 5 ++ ...plicationdevelopers_to_softapplications.rb | 5 ++ db/schema.rb | 13 +++- test/fixtures/contesting_softapplications.yml | 13 ++++ test/unit/contesting_softapplication_test.rb | 7 ++ 26 files changed, 346 insertions(+), 8 deletions(-) create mode 100644 app/models/contesting_softapplication.rb create mode 100644 app/views/contests/_list_softapplications.html.erb create mode 100644 app/views/contests/add_softapplication.js.erb create mode 100644 app/views/softapplications/_message_history.erb create mode 100644 app/views/softapplications/_new_message.erb create mode 100644 app/views/softapplications/_pre_show.html.erb create mode 100644 app/views/softapplications/back.js.erb create mode 100644 app/views/softapplications/create_message.js.erb create mode 100644 app/views/softapplications/more.js.erb create mode 100644 app/views/softapplications/new.html.erb.BASE.erb create mode 100644 app/views/softapplications/new.html.erb.LOCAL.erb create mode 100644 app/views/softapplications/new.html.erb.REMOTE.erb create mode 100644 app/views/softapplications/new_message.js.erb create mode 100644 db/migrate/20140410015850_add_contest_id_to_softapplications.rb create mode 100644 db/migrate/20140410020848_add_softapplication_id_to_softapplications.rb create mode 100644 db/migrate/20140411003234_create_contesting_softapplications.rb create mode 100644 db/migrate/20140411004155_add_reward_to_contesting_softapplications.rb create mode 100644 db/migrate/20140411005214_add_is_public_to_softapplications.rb create mode 100644 db/migrate/20140414012423_add_applicationdevelopers_to_softapplications.rb create mode 100644 test/fixtures/contesting_softapplications.yml create mode 100644 test/unit/contesting_softapplication_test.rb diff --git a/app/models/contesting_softapplication.rb b/app/models/contesting_softapplication.rb new file mode 100644 index 000000000..93aea2658 --- /dev/null +++ b/app/models/contesting_softapplication.rb @@ -0,0 +1,15 @@ + +class ContestingSoftapplication < ActiveRecord::Base + attr_accessible :contest_id, :description, :softapplication_id, :user_id + + belongs_to :contest + belongs_to :softapplication + belongs_to :user + + + def self.create_softapplication_contesting(contest_id, softapplication_id, description = nil) + self.create(:user_id => User.current.id, :contest_id => contest_id, + :softapplication_id => softapplication_id, :description => description) + end + +end diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb index e63eb428d..fa90881bf 100644 --- a/app/models/softapplication.rb +++ b/app/models/softapplication.rb @@ -1,5 +1,5 @@ class Softapplication < ActiveRecord::Base - attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id + attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers acts_as_attachable has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :contesting_softapplications, :dependent => :destroy diff --git a/app/views/contests/_list_softapplications.html.erb b/app/views/contests/_list_softapplications.html.erb new file mode 100644 index 000000000..a0099c727 --- /dev/null +++ b/app/views/contests/_list_softapplications.html.erb @@ -0,0 +1,40 @@ + +<% contesting_softapplication.each do |c_softapplication|%> + <% if c_softapplication.softapplication %> +
+ + + +
+ + + + + + +
+ + + + + + + + + + + + +
+ + <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication)) %> + + <%= l(:label_joined_contest)%> +
<%= c_softapplication.softapplication.description %>
+ <%=format_time c_softapplication.created_at %> +
+
+
+ <% end %> +<% end %> + diff --git a/app/views/contests/add_softapplication.js.erb b/app/views/contests/add_softapplication.js.erb new file mode 100644 index 000000000..6071c7070 --- /dev/null +++ b/app/views/contests/add_softapplication.js.erb @@ -0,0 +1,4 @@ +$('#contesting_softapplication_list').html('<%= escape_javascript(render(:partial => 'softapplication_list', :locals => {:contesting_softapplication => @contesting_softapplication})) %>'); +$("#softapplication_id").val("请选择参赛应用"); +$("#contest_message").val( "<%= l(:label_bid_reason) %>" ); +$("#put-bid-form").hide(); \ No newline at end of file diff --git a/app/views/softapplications/_message_history.erb b/app/views/softapplications/_message_history.erb new file mode 100644 index 000000000..4190e899d --- /dev/null +++ b/app/views/softapplications/_message_history.erb @@ -0,0 +1,32 @@ +<% reply_allow = JournalsForMessage.create_by_user? User.current %> + + +
+ <%= render :partial => 'new_message', :locals => {:softapplication => @softapplication, :sta => @state} %> +
+ + +<% if journals.size >0 %> +
    + <% for journal in journals%> +
  • + <%= image_tag(url_to_avatar(journal.user), :class => "avatar") %> + + <%= link_to journal.user, user_path(journal.user)%> + <% label = l(:label_contest_requirement) %> +
    <%= textilizable journal.notes%>
    + <%= l(:label_bids_published) %> <%= time_tag(journal.created_on).html_safe %> <%= l(:label_bids_published_ago) %> + + <% ids = 'project_respond_form_'+ journal.id.to_s%> + + + <% if @user==User.current|| User.current.admin? %> + <%= link_to(l(:label_bid_respond_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => @user}, :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %> + <% end %> + +
    +
    +
  • + <% end %> +
+<% end %> diff --git a/app/views/softapplications/_new_message.erb b/app/views/softapplications/_new_message.erb new file mode 100644 index 000000000..e46fb2997 --- /dev/null +++ b/app/views/softapplications/_new_message.erb @@ -0,0 +1,53 @@ + + + +<%= form_for('softapplication_message', + :remote => true, :method => :post, + :url => {:controller => 'softapplications', + :action => 'create_message', + :id => softapplication, + :sta => sta} + ) do |f|%> + +
+ <%= render :partial => 'pre_show', :locals => {:content => @content} %> +
+ + <% if User.current.logged? %> + + + + +
<%= f.text_area 'message', :rows => 3, :cols => 65, :placeholder => l(:label_my_respond), :style => "resize: none;", :class => 'noline'%>
+ + <%= f.text_field :reference_user_id, :style=>"display:none"%> + + + + + + +
<%= submit_tag l(:button_leave_meassge), :name => nil , :class => "softapplication_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> + <%= submit_tag l(:button_clear), :name => nil, :onclick => "clearMessage('softapplication_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
+ + <% else %> +
+ <%= l(:label_user_login_tips) %> + <%= link_to l(:label_user_login_new), signin_path %> +
+ <% end %> +<% end %> diff --git a/app/views/softapplications/_pre_show.html.erb b/app/views/softapplications/_pre_show.html.erb new file mode 100644 index 000000000..fef1f16e4 --- /dev/null +++ b/app/views/softapplications/_pre_show.html.erb @@ -0,0 +1,13 @@ + +<% unless content.nil?%> + + + + + + + +
<%= textilizable content %>
<%= hidden_field_tag 'reference_content', params[:reference_content], :value => content%>
+<% end %> + + diff --git a/app/views/softapplications/back.js.erb b/app/views/softapplications/back.js.erb new file mode 100644 index 000000000..acd52a63e --- /dev/null +++ b/app/views/softapplications/back.js.erb @@ -0,0 +1,2 @@ +$('#message_history').html('<%= escape_javascript(render(:partial => 'history_message', :locals => {:softapplication => @softapplication, :journals => @jour, :state => @state})) %>'); +$('#softapplication_message_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/softapplications/create_message.js.erb b/app/views/softapplications/create_message.js.erb new file mode 100644 index 000000000..bd0b13369 --- /dev/null +++ b/app/views/softapplications/create_message.js.erb @@ -0,0 +1,4 @@ +$('#history').html('<%= escape_javascript(render(:partial => 'softapplications/message_history', :locals => {:contest => @softapplication, :journals => @jour, :state => true})) %>'); +$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>'); +$('#softapplication_message_message').val(""); +$('#softapplication_message_reference_user_id').val(""); diff --git a/app/views/softapplications/more.js.erb b/app/views/softapplications/more.js.erb new file mode 100644 index 000000000..fc67a9fed --- /dev/null +++ b/app/views/softapplications/more.js.erb @@ -0,0 +1,2 @@ +$('#message_history').html('<%= escape_javascript(render(:partial => 'message_history', :locals => {:softapplication => @softapplication, :journals => @jour, :state => @state})) %>'); +$('#softapplication_message_reference_user_id').val(""); \ No newline at end of file diff --git a/app/views/softapplications/new.html.erb b/app/views/softapplications/new.html.erb index cd46c7572..b47930d60 100644 --- a/app/views/softapplications/new.html.erb +++ b/app/views/softapplications/new.html.erb @@ -41,7 +41,14 @@
<%= l(:label_softapplication_developers) %> * <%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:400px;" %>
<%= l(:label_softapplication_name) %> * <%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %><%= l(:label_softapplication_name_condition)%>
<%= l(:label_softapplication_version_available) %> * <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %>
<%= l(:label_softapplication_type) %> * <%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %>
<%= l(:label_softapplication_description) %> * <%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %>
@@ -24,10 +24,13 @@ 发布时间:<%=format_time @softapplication.created_at %>
开发者:<%= @softapplication.user.name %>发布人员:<%= @softapplication.user.name %> 系统支持:<%= @softapplication.android_min_version_available %>
应用下载: 开发人员:<%= @softapplication.application_developers %>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index f5f120925..7db6f8908 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1837,7 +1837,9 @@ zh: label_softapplication_description: 应用简介 label_softapplication_type: 应用分类 label_softapplication_version_available: 适配版本 - label_softapplication_developer: 开发者 + label_softapplication_developer: 上传人员 + label_softapplication_developers: 开发人员 label_softapplication_name_condition: 25个汉字以内(50个字符) label_user_login_softapplication_board: 您还没有登录,请登录后参与应用评价。 - label_contest_description_no: 暂无描述。 \ No newline at end of file + label_contest_description_no: 暂无描述。 + \ No newline at end of file diff --git a/db/migrate/20140410015850_add_contest_id_to_softapplications.rb b/db/migrate/20140410015850_add_contest_id_to_softapplications.rb new file mode 100644 index 000000000..b7b73a4aa --- /dev/null +++ b/db/migrate/20140410015850_add_contest_id_to_softapplications.rb @@ -0,0 +1,5 @@ +class AddContestIdToSoftapplications < ActiveRecord::Migration + def change + add_column :softapplications, :contest_id, :integer + end +end diff --git a/db/migrate/20140410020848_add_softapplication_id_to_softapplications.rb b/db/migrate/20140410020848_add_softapplication_id_to_softapplications.rb new file mode 100644 index 000000000..e4a51f535 --- /dev/null +++ b/db/migrate/20140410020848_add_softapplication_id_to_softapplications.rb @@ -0,0 +1,5 @@ +class AddSoftapplicationIdToSoftapplications < ActiveRecord::Migration + def change + add_column :softapplications, :softapplication_id, :integer + end +end diff --git a/db/migrate/20140411003234_create_contesting_softapplications.rb b/db/migrate/20140411003234_create_contesting_softapplications.rb new file mode 100644 index 000000000..118b518f5 --- /dev/null +++ b/db/migrate/20140411003234_create_contesting_softapplications.rb @@ -0,0 +1,12 @@ +class CreateContestingSoftapplications < ActiveRecord::Migration + def change + create_table :contesting_softapplications do |t| + t.integer :softapplication_id + t.integer :contest_id + t.integer :user_id + t.string :description + + t.timestamps + end + end +end diff --git a/db/migrate/20140411004155_add_reward_to_contesting_softapplications.rb b/db/migrate/20140411004155_add_reward_to_contesting_softapplications.rb new file mode 100644 index 000000000..e5e3db183 --- /dev/null +++ b/db/migrate/20140411004155_add_reward_to_contesting_softapplications.rb @@ -0,0 +1,5 @@ +class AddRewardToContestingSoftapplications < ActiveRecord::Migration + def change + add_column :contesting_softapplications, :reward, :string + end +end diff --git a/db/migrate/20140411005214_add_is_public_to_softapplications.rb b/db/migrate/20140411005214_add_is_public_to_softapplications.rb new file mode 100644 index 000000000..15d81699e --- /dev/null +++ b/db/migrate/20140411005214_add_is_public_to_softapplications.rb @@ -0,0 +1,5 @@ +class AddIsPublicToSoftapplications < ActiveRecord::Migration + def change + add_column :softapplications, :is_public, :integer + end +end diff --git a/db/migrate/20140414012423_add_applicationdevelopers_to_softapplications.rb b/db/migrate/20140414012423_add_applicationdevelopers_to_softapplications.rb new file mode 100644 index 000000000..2a4ad1081 --- /dev/null +++ b/db/migrate/20140414012423_add_applicationdevelopers_to_softapplications.rb @@ -0,0 +1,5 @@ +class AddApplicationdevelopersToSoftapplications < ActiveRecord::Migration + def change + add_column :softapplications, :application_developers, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 8b443264f..54947fe75 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140411005214) do +ActiveRecord::Schema.define(:version => 20140414012423) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -696,6 +696,7 @@ ActiveRecord::Schema.define(:version => 20140411005214) do t.integer "contest_id" t.integer "softapplication_id" t.integer "is_public" + t.string "application_developers" end create_table "students_for_courses", :force => true do |t| @@ -811,6 +812,16 @@ ActiveRecord::Schema.define(:version => 20140411005214) 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 + end + create_table "user_statuses", :force => true do |t| t.integer "changesets_count" t.integer "watchers_count" diff --git a/test/fixtures/contesting_softapplications.yml b/test/fixtures/contesting_softapplications.yml new file mode 100644 index 000000000..4b64c8b03 --- /dev/null +++ b/test/fixtures/contesting_softapplications.yml @@ -0,0 +1,13 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + softapplication_id: 1 + contest_id: 1 + user_id: 1 + description: MyString + +two: + softapplication_id: 1 + contest_id: 1 + user_id: 1 + description: MyString diff --git a/test/unit/contesting_softapplication_test.rb b/test/unit/contesting_softapplication_test.rb new file mode 100644 index 000000000..0c1364caa --- /dev/null +++ b/test/unit/contesting_softapplication_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ContestingSoftapplicationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 589a21204cbbfe96c65a526b9c40bdd5a8f78ef9 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Mon, 14 Apr 2014 15:54:10 +0800 Subject: [PATCH 19/43] =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/softapplications_controller.rb | 4 ++++ app/models/attachment.rb | 4 ++++ app/views/softapplications/show.html.erb | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index a1410722f..9ac62f928 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -19,6 +19,10 @@ class SoftapplicationsController < ApplicationController @softapplication.attachments.each do |f| f.image? ? @image_results << f : @image_results end + @app_items = [] + @softapplication.attachments.each do |f| + f.pack? ? @app_items << f : @app_items + end @limit = 10 @feedback_count = @jours.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 8e607a685..919760ee3 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -180,6 +180,10 @@ class Attachment < ActiveRecord::Base !!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png)$/i) end + def pack? + !!(self.filename =~ /\.(zip|rar|tar|gz)$/i) + end + def thumbnailable? image? end diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index c5ecac2c1..053de150e 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -28,7 +28,12 @@ 系统支持:<%= @softapplication.android_min_version_available %> - 应用下载: + 应用下载: + <% options = {:author => true, :deletable => @softapplication.user.eql?(User.current) } %> + <%= render :partial => 'attachments/app_link', :locals => {:attachments => @app_items, :options => options} %> + + + 开发人员:<%= @softapplication.application_developers %> From 733497fef891564d59c77911e3e889f713306aaf Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Mon, 14 Apr 2014 17:29:38 +0800 Subject: [PATCH 20/43] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2=E4=B8=AD=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=95=B0=E5=AD=97=E7=9A=84=E8=B6=85=E9=93=BE?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 13 +++++++++++++ app/views/contests/_contest_list.html.erb | 7 +++---- app/views/contests/_softapplication_list.html.erb | 2 +- app/views/layouts/base_newcontest.html.erb | 6 +++--- app/views/softapplications/new.html.erb | 2 +- app/views/softapplications/show.html.erb | 8 +++----- config/locales/zh.yml | 1 + 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8533c4012..9b3a672c3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1459,6 +1459,19 @@ module ApplicationHelper end html.html_safe end + + def show_contest_softapplication(contest) + html = '' + if contest.softapplications.where('is_public = 1').count == 0 + html << (content_tag "p", l(:label_no_contest_softapplication), :class => "font_lighter") + else + contest.softapplications.where('is_public = 1').take(12).each do |softapplication| + html << (link_to image_tag(url_to_avatar(project), :class => "avatar", :title => project.name), project_path(project), :class => "avatar") + end + end + html.html_safe + end + def show_contest_fans_picture(obj) html = '' if obj.watcher_users.count == 0 diff --git a/app/views/contests/_contest_list.html.erb b/app/views/contests/_contest_list.html.erb index 5a8bf6890..4fb2865c8 100644 --- a/app/views/contests/_contest_list.html.erb +++ b/app/views/contests/_contest_list.html.erb @@ -18,10 +18,9 @@ - <%= l(:label_contest_project, :count => contest.contesting_projects.count) %>(<%= link_to contest.contesting_projects.count %>) - <%= l(:label_contest_softapplication, :count => contest.contesting_softapplications.count) %>(<%= link_to contest.contesting_softapplications.count %>) - <%= l(:label_contest_response, :count => contest.commit) %>(<%= link_to contest.commit, respond_path(contest) %>) - <%= l(:label_contest_watchers, :count => contest.watcher_users.count) %>(<%= link_to contest.watcher_users.count, respond_path(contest) %>) + <%= l(:label_contest_project, :count => contest.contesting_projects.count) %>(<%= link_to(contest.contesting_projects.count, show_project_contest_path(contest)) %>) + <%= l(:label_contest_softapplication, :count => contest.contesting_softapplications.count) %>(<%= link_to(contest.contesting_softapplications.count, show_softapplication_contest_path(contest)) %>) + diff --git a/app/views/contests/_softapplication_list.html.erb b/app/views/contests/_softapplication_list.html.erb index 221dc9dcf..570a40674 100644 --- a/app/views/contests/_softapplication_list.html.erb +++ b/app/views/contests/_softapplication_list.html.erb @@ -2,7 +2,7 @@ <%= render_flash_messages %> - + <% if User.current.logged? %> @@ -28,11 +28,9 @@ - @@ -49,7 +47,7 @@
-
+
软件截图:
<% @image_results.take(4).each do |attachment| %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 7db6f8908..479bfe401 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1842,4 +1842,5 @@ zh: label_softapplication_name_condition: 25个汉字以内(50个字符) label_user_login_softapplication_board: 您还没有登录,请登录后参与应用评价。 label_contest_description_no: 暂无描述。 + label_no_contest_softapplication: 暂无参赛应用 \ No newline at end of file From f2ed529b922d3370a97e220dd1f54103b7b44e29 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Mon, 14 Apr 2014 17:30:05 +0800 Subject: [PATCH 21/43] df --- app/views/attachments/_app_link.html.erb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 app/views/attachments/_app_link.html.erb diff --git a/app/views/attachments/_app_link.html.erb b/app/views/attachments/_app_link.html.erb new file mode 100644 index 000000000..9b27a9570 --- /dev/null +++ b/app/views/attachments/_app_link.html.erb @@ -0,0 +1,12 @@ +
+<% for attachment in attachments %> +

<%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> + <% if attachment.is_text? %> + <%= link_to image_tag('magnifier.png'), + :controller => 'attachments', :action => 'show', + :id => attachment, :filename => attachment.filename %> + <% end %> + <%= h(" - #{attachment.description}") unless attachment.description.blank? %> + (<%= number_to_human_size attachment.filesize %>) + <% end -%> +

\ No newline at end of file From b4b61a3422d927da5c20aebaee40e2f45a608fa0 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Mon, 14 Apr 2014 21:54:54 +0800 Subject: [PATCH 22/43] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B0=8Fbug=EF=BC=9B?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E6=89=93=E5=88=86=E5=92=8C=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=94=AF=E4=B8=80=E6=80=A7=E5=89=8D=E6=8F=90=E4=BA=A4=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/_app_link.html.erb | 6 +-- .../contests/show_softapplication.html.erb | 2 +- app/views/layouts/base_newcontest.html.erb | 38 +------------------ app/views/projects/new.html.erb | 2 +- app/views/softapplications/_new_message.erb | 6 +-- app/views/softapplications/new.html.erb | 22 +++++------ app/views/softapplications/show.html.erb | 22 +++++------ app/views/welcome/contest.html.erb | 2 +- config/locales/zh.yml | 1 + public/stylesheets/application.css | 21 +++++++++- 10 files changed, 53 insertions(+), 69 deletions(-) diff --git a/app/views/attachments/_app_link.html.erb b/app/views/attachments/_app_link.html.erb index 9b27a9570..ecef4dda3 100644 --- a/app/views/attachments/_app_link.html.erb +++ b/app/views/attachments/_app_link.html.erb @@ -1,6 +1,5 @@ -
-<% for attachment in attachments %> -

<%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> + +<% for attachment in attachments %><%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> <% if attachment.is_text? %> <%= link_to image_tag('magnifier.png'), :controller => 'attachments', :action => 'show', @@ -9,4 +8,3 @@ <%= h(" - #{attachment.description}") unless attachment.description.blank? %> (<%= number_to_human_size attachment.filesize %>) <% end -%> -

\ No newline at end of file diff --git a/app/views/contests/show_softapplication.html.erb b/app/views/contests/show_softapplication.html.erb index 3d6a1d735..068ac79cd 100644 --- a/app/views/contests/show_softapplication.html.erb +++ b/app/views/contests/show_softapplication.html.erb @@ -68,7 +68,7 @@
diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index 2f786008c..3c37cfe5a 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -173,44 +173,10 @@ -
-
-
- <%= l(:label_contest_project) %> - <% if show_more_contest_project?(@contest) %> - <%= link_to l(:label_more), :controller => 'contests', :action => 'show_project'%> - <% end %> -
-
-
<%= l(:label_bidding_project) %> <%= l(:label_contest_softapplication) %>(<%= contesting_softapplication.count%>)
diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index 14598db31..2f786008c 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -197,15 +197,15 @@
<%= l(:label_contest_application) %> - <% if show_more_contest_project?(@contest) %> - <%= link_to l(:label_more), :controller => 'contests', :action => 'show_project'%> + <% if show_more_contest_softapplication?(@contest) %> + <%= link_to l(:label_more), :controller => 'contests', :action => 'show_softapplication'%> <% end %>
- <%= show_contest_project(@contest) %> + <%= show_contest_softapplication(@contest) %>
diff --git a/app/views/softapplications/new.html.erb b/app/views/softapplications/new.html.erb index b47930d60..a300512cd 100644 --- a/app/views/softapplications/new.html.erb +++ b/app/views/softapplications/new.html.erb @@ -50,7 +50,7 @@

- 上传应用软件包或应用截图 + 上传应用软件包和应用截图 <%= render_flash_messages %>

<%= render :partial => 'attachments/form' %> diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index 053de150e..3728af02d 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -10,7 +10,7 @@

<%= notice %>

-
+
系统支持:<%= @softapplication.android_min_version_available %>
应用下载: + 应用下载: <% options = {:author => true, :deletable => @softapplication.user.eql?(User.current) } %> <%= render :partial => 'attachments/app_link', :locals => {:attachments => @app_items, :options => options} %> - - 开发人员:<%= @softapplication.application_developers %>

- <%= link_to '创建应用', new_softapplication_path(:target=>'_blank') %> + <%= link_to '发布应用', new_softapplication_path(:target=>'_blank') %>

- - - -
- <%= show_contest_project(@contest) %> -
-
-
+ -
-
-
- <%= l(:label_contest_application) %> - <% if show_more_contest_softapplication?(@contest) %> - <%= link_to l(:label_more), :controller => 'contests', :action => 'show_softapplication'%> - <% end %> -
-
- - - - -
- <%= show_contest_softapplication(@contest) %> -
-
-
+
diff --git a/app/views/projects/new.html.erb b/app/views/projects/new.html.erb index 7044d69dd..aa03a1cc1 100644 --- a/app/views/projects/new.html.erb +++ b/app/views/projects/new.html.erb @@ -3,7 +3,7 @@ <% if @course_tag == '1' %>

<%=l(:label_course_new)%>

-

<%=raw l(:label_course_news_description)%>

+ <%= render :partial => 'course_form', :locals => { :f => f } %> <%= submit_tag l(:button_create), :class => "enterprise"%> diff --git a/app/views/softapplications/_new_message.erb b/app/views/softapplications/_new_message.erb index e46fb2997..321c7911f 100644 --- a/app/views/softapplications/_new_message.erb +++ b/app/views/softapplications/_new_message.erb @@ -37,10 +37,10 @@ <%= f.text_field :reference_user_id, :style=>"display:none"%> - +
- +
<%= submit_tag l(:button_leave_meassge), :name => nil , :class => "softapplication_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> - <%= submit_tag l(:button_clear), :name => nil, :onclick => "clearMessage('softapplication_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %> <%= submit_tag l(:label_button_ok), :name => nil , :class => "softapplication_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'"%> + <%= submit_tag l(:button_clear_requirement), :name => nil, :onclick => "clearMessage('softapplication_message_message');", :type => 'button', :class => "bid_btn", :onmouseout => "this.style.backgroundPosition = 'left top'", :onmouseover => "this.style.backgroundPosition = 'left -31px'" %>
diff --git a/app/views/softapplications/new.html.erb b/app/views/softapplications/new.html.erb index a300512cd..444a217f6 100644 --- a/app/views/softapplications/new.html.erb +++ b/app/views/softapplications/new.html.erb @@ -3,32 +3,32 @@ <%= link_to 'Back', softapplications_path %> --> -
+
<%= 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| %> -
- +
+ - <%= l(:label_softapplication_name) %> - * : <%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %> - <%= l(:label_softapplication_name_condition)%> + <%= l(:label_softapplication_name) %> + * : <%= f.text_field :name, :required => true, :size => 60, :style => "width:400px;" %> + <%= l(:label_softapplication_name_condition)%>

- <%= l(:label_softapplication_version_available) %> - * : <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %> + <%= l(:label_softapplication_version_available) %> + * : <%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:400px;" %>

- <%= l(:label_softapplication_type) %> + <%= l(:label_softapplication_type) %> - * : <%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %> + * : <%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %>
diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index 3728af02d..0d735abcd 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -10,27 +10,27 @@

<%= notice %>

-
+
- + - + - + - @@ -41,14 +41,14 @@
-
-
应用简介:
+
+
应用简介:
<%= @softapplication.description %>
-
软件截图:
+
软件截图:
<% @image_results.take(4).each do |attachment| %> <%= link_to_attachment_img attachment, :class => "soft-application", :download => "true" %> @@ -60,7 +60,7 @@
-
软件评论:
+
软件评论:
diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index b1c009c94..1b265ade9 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -101,7 +101,7 @@ <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %>
-
+
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 479bfe401..ad0d98f51 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1843,4 +1843,5 @@ zh: label_user_login_softapplication_board: 您还没有登录,请登录后参与应用评价。 label_contest_description_no: 暂无描述。 label_no_contest_softapplication: 暂无参赛应用 + label_button_ok: 确定 \ No newline at end of file diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index c8582a575..b8f40bdfe 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -9,6 +9,14 @@ h4, .wiki h3 {font-size: 13px;} h4 {border-bottom: 1px dotted #bbb;} /*huang*/ /*current position*/ +.contest_count{ + width: 20%; + height: 60px; + border: 1px solid #15bccf; + border-radius: 5px 5px 5px 5px; + float:right; +} + .top-content{ background-color: #f7f7f7; height: 56px; @@ -2712,4 +2720,15 @@ div.repos_explain{ margin-bottom: 10px; border-bottom: 1px dashed rgb(204, 204, 204); width: 660px; -} \ No newline at end of file +} + +.contest-star{ + color: #bb0000; +} + +.contes-new-box{ + background: #fcfcfc; + padding-left: 85px; + padding-top: 20px; + padding-bottom: 20px; +} From c964cf9d9dfe453ee3dc79a77576bb5d5400d44d Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Mon, 14 Apr 2014 22:12:13 +0800 Subject: [PATCH 23/43] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=86=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E5=BA=94=E7=94=A8=E9=A1=B5=E9=9D=A2=E6=98=9F=E6=98=9F?= =?UTF-8?q?=E7=9A=84=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/softapplications/new.html.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/softapplications/new.html.erb b/app/views/softapplications/new.html.erb index 444a217f6..d7ea95799 100644 --- a/app/views/softapplications/new.html.erb +++ b/app/views/softapplications/new.html.erb @@ -28,23 +28,23 @@ <%= l(:label_softapplication_type) %> - * : + * :

- - : + <%= l(:label_softapplication_description) %> + * :

- - : + <%= l(:label_softapplication_developers) %> + * :
From 484d334c3cfeed06bb3fe303f469e9bb7e821e8e Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Tue, 15 Apr 2014 10:34:28 +0800 Subject: [PATCH 24/43] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=B8=AD=E5=8F=82=E8=B5=9B=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=9A=84=E5=88=86=E9=A1=B5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 23 +++++++++++-------- app/views/contests/_list_projects.html.erb | 1 + .../contests/_list_softapplications.html.erb | 1 + .../contests/_softapplication_list.html.erb | 2 +- app/views/contests/show_project.html.erb | 1 + app/views/softapplications/show.html.erb | 2 +- app/views/tags/_sidebar_tags.html.erb | 1 + app/views/tags/_tag.html.erb | 1 + 8 files changed, 21 insertions(+), 11 deletions(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index ccc5c51ab..86c4df367 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -190,6 +190,8 @@ class ContestsController < ApplicationController def show_project @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) @option = [] + # @contesting_project_count = @contesting_project_all.count + # @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page'] @membership.each do |membership| unless(membership.project.project_type==1) membership.member_roles.each{|role| @@ -214,17 +216,18 @@ class ContestsController < ApplicationController @contesting_project = @temp else - @temp = [] - @contesting_project.each do |pro| - if pro.project && pro.project.project_status - @temp << pro + @temp = [] + @contesting_project.each do |pro| + if pro.project && pro.project.project_status + @temp << pro + end + @temp + end + if @temp.size > 0 + @contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} end - @temp - end - if @temp.size > 0 - @contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} - end end + @contesting_project = paginateHelper @contesting_project respond_to do |format| format.html { render :layout => 'base_newcontest' @@ -241,6 +244,8 @@ class ContestsController < ApplicationController # @user = @contest.user @softapplication = Softapplication.all @contesting_softapplication = @contest.contesting_softapplications + + @contesting_softapplication = paginateHelper @contesting_softapplication, 10 # @temp = [] # @softapplicationt.each do |pro| diff --git a/app/views/contests/_list_projects.html.erb b/app/views/contests/_list_projects.html.erb index 6a778819d..48a5ed328 100644 --- a/app/views/contests/_list_projects.html.erb +++ b/app/views/contests/_list_projects.html.erb @@ -99,4 +99,5 @@
<%= @softapplication.name %><%= @softapplication.name %>
所属类别:<%= @softapplication.app_type_name %>发布时间:<%=format_time @softapplication.created_at %>发布时间:<%=format_time @softapplication.created_at %>
发布人员:<%= @softapplication.user.name %> 系统支持:<%= @softapplication.android_min_version_available %>
应用下载: - <% options = {:author => true, :deletable => @softapplication.user.eql?(User.current) } %> - <%= render :partial => 'attachments/app_link', :locals => {:attachments => @app_items, :options => options} %> + 应用下载: + <% options = {:author => true, :deletable => @softapplication.user.eql?(User.current) } %> + <%= render :partial => 'attachments/app_link', :locals => {:attachments => @app_items, :options => options} %> 开发人员:<%= @softapplication.application_developers %>
竞赛总量:
<%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %><%= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %>
<%= l(:label_softapplication_description) %> * <%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %><%= f.text_field :description, :required => true, :size => 60, :style => "width:400px;" %>
<%= l(:label_softapplication_developers) %> * <%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:400px;" %><%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:400px;" %>
<% end %> <% end %> + diff --git a/app/views/contests/_list_softapplications.html.erb b/app/views/contests/_list_softapplications.html.erb index a0099c727..2c2034a5d 100644 --- a/app/views/contests/_list_softapplications.html.erb +++ b/app/views/contests/_list_softapplications.html.erb @@ -37,4 +37,5 @@ <% end %> <% end %> + diff --git a/app/views/contests/_softapplication_list.html.erb b/app/views/contests/_softapplication_list.html.erb index 570a40674..ee4b37921 100644 --- a/app/views/contests/_softapplication_list.html.erb +++ b/app/views/contests/_softapplication_list.html.erb @@ -2,7 +2,7 @@ <%= render_flash_messages %> - + <% if User.current.logged? %>
+ +
+
+ + + + + + <% end %> +
<% end %> diff --git a/app/views/contests/_softapplication_list.html.erb b/app/views/contests/_softapplication_list.html.erb index ee4b37921..e5d030123 100644 --- a/app/views/contests/_softapplication_list.html.erb +++ b/app/views/contests/_softapplication_list.html.erb @@ -7,7 +7,7 @@ <% end %> diff --git a/app/views/contests/show_softapplication.html.erb b/app/views/contests/show_softapplication.html.erb index 068ac79cd..6c932df50 100644 --- a/app/views/contests/show_softapplication.html.erb +++ b/app/views/contests/show_softapplication.html.erb @@ -59,7 +59,7 @@ <% if User.current.logged? %>
-
+
<%= l(:label_contest_softapplication) %>(<%= contesting_softapplication.count%>) <%= l(:label_contest_softapplication) %>(<%= @contest.contesting_softapplications.count%>)
diff --git a/app/views/contests/show_project.html.erb b/app/views/contests/show_project.html.erb index 07ddd6217..202d3b632 100644 --- a/app/views/contests/show_project.html.erb +++ b/app/views/contests/show_project.html.erb @@ -96,4 +96,5 @@
<%= render :partial => 'project_list', :locals => {:contesting_project => @contesting_project,:contest => @contest} %>
+ diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index 0d735abcd..f21d2cecb 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -60,7 +60,7 @@
-
软件评论:
+
软件评论:
diff --git a/app/views/tags/_sidebar_tags.html.erb b/app/views/tags/_sidebar_tags.html.erb index a9570f609..cc377e6b4 100644 --- a/app/views/tags/_sidebar_tags.html.erb +++ b/app/views/tags/_sidebar_tags.html.erb @@ -9,4 +9,5 @@ (<%= Bid.tagged_with("#{sg}").size %>) <% when '5' then %> (<%= Forum.tagged_with("#{sg}").size %>) + <% end %> diff --git a/app/views/tags/_tag.html.erb b/app/views/tags/_tag.html.erb index 0d9467025..c38bdbaf5 100644 --- a/app/views/tags/_tag.html.erb +++ b/app/views/tags/_tag.html.erb @@ -6,6 +6,7 @@ 4 代表是bid类型 5 代表是forum类型 6 代表是Attachment类型 + #end%> <% if object_flag == '3' %> From 6421f02ac80d7682ae5ba59a4b792e7e3b915260 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 16 Apr 2014 08:46:04 +0800 Subject: [PATCH 25/43] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=86=E5=8F=82?= =?UTF-8?q?=E8=B5=9B=E5=BA=94=E7=94=A8=E5=88=97=E8=A1=A8=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/tags_controller.rb | 88 ++++++++++++------- app/controllers/users_controller.rb | 2 + app/helpers/tags_helper.rb | 10 ++- .../contests/_list_softapplications.html.erb | 56 ++++++------ .../contests/_softapplication_list.html.erb | 2 +- .../contests/show_softapplication.html.erb | 2 +- app/views/layouts/base_newcontest.html.erb | 2 +- app/views/softapplications/show.html.erb | 5 +- app/views/tags/_sidebar_tags.html.erb | 3 +- app/views/tags/_tag.html.erb | 2 +- app/views/tags/_tag_name.html.erb | 7 ++ app/views/tags/_tag_search_results.html.erb | 4 + app/views/tags/add_tag.js.erb | 2 +- app/views/tags/delete_tag.js.erb | 2 +- app/views/tags/index.html.erb | 14 ++- config/locales/zh.yml | 4 + public/stylesheets/application.css | 6 +- 17 files changed, 131 insertions(+), 80 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 71c9b0e7e..bcd9992bc 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -11,6 +11,7 @@ class TagsController < ApplicationController include BidsHelper include ForumsHelper include AttachmentsHelper + include ContestsHelper include ActsAsTaggableOn::TagsHelper helper :projects include TagsHelper @@ -30,7 +31,7 @@ class TagsController < ApplicationController # 最后是2个过滤何种数据,显示结果的控制参数params[:obj_id],params[:object_falg] # 0代表删除tag 1代表增加tag def index - + @obj_id = params[:obj_id] @obj_flag = params[:object_flag] @@ -44,28 +45,29 @@ class TagsController < ApplicationController @tag = params[:tag] @selected_tags = params[:current_selected_tags] @selected_tags = @selected_tags.nil? ? Array.new : @selected_tags - + case @do_what when '0' then - @selected_tags.delete @tag #数组中删除有多方式 可以改用shift,pop + @selected_tags.delete @tag #数组中删除有多方式 可以改用shift,pop when '1' then - # 判断是否已存在该tag 主要用来处理分页的情况 - unless @selected_tags.include? @tag - @selected_tags << @tag - end + # 判断是否已存在该tag 主要用来处理分页的情况 + unless @selected_tags.include? @tag + @selected_tags << @tag + end end end - - @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num, + + @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num,@contests_tags_num, @forum_tags_num, @attachments_tags_num = get_tags_size - + # 获取搜索结果 @obj,@obj_pages,@results_count,@users_results, @projects_results, @issues_results, @bids_results, @forums_results, - @attachments_results = refresh_results(@obj_id,@obj_flag,@selected_tags) + @attachments_results, + @contests_tags = refresh_results(@obj_id,@obj_flag,@selected_tags) # 这里是做tag推荐用的, 用来生产推荐的tags unless @obj.nil? @@ -74,13 +76,13 @@ class TagsController < ApplicationController # @selected_tags.each do |i| # @tags.delete(i) # end - @related_tags = @tags + @related_tags = @tags else return end end - + # 增加已选的tag def add_tag @tag = params[:tag] @@ -90,11 +92,13 @@ class TagsController < ApplicationController $related_tags.delete(@tag) # 获取搜索结果 - @obj,@obj_pages,@users_results, + @obj,@obj_pages,@results_count,@users_results, @projects_results, @issues_results, @bids_results, - @forums_results = refresh_results(@obj_id,@show_flag) + @forums_results, + @attachments_results, + @contests_results = refresh_results(@obj_id,@show_flag) end # 删除已选tag @@ -110,13 +114,15 @@ class TagsController < ApplicationController @projects_results, @issues_results, @bids_results, - @forums_results = refresh_results(@obj_id,@show_flag) + @forums_results, + @attachments_results, + @contests_results = refresh_results(@obj_id,@show_flag) end def show_all - @tags = ActsAsTaggableOn::Tag.find(:all) + @tags = ActsAsTaggableOn::Tag.find(:all) end - + # 完全从数据库删除tag # 这种删除方式是针对 印有该 tag所有对象来做删除的 # 这样是从整个系统数据库中把该tag删除了 @@ -149,24 +155,24 @@ class TagsController < ApplicationController # if can_remove_tag?(User.current,@taggable_id,@taggable_type) - @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) - - unless @taggings.nil? - @taggings.delete - end + @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) + + unless @taggings.nil? + @taggings.delete + end # 是否还有其他记录 引用了 tag_id - @tagging = ActsAsTaggableOn::Tagging.find_by_tag_id(@tag_id) + @tagging = ActsAsTaggableOn::Tagging.find_by_tag_id(@tag_id) # 如果taggings表中记录已经不存在 ,那么检查tags表 作删除动作 - if @tagging.nil? - @tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id) - @tag.delete unless @tag.nil? - end + if @tagging.nil? + @tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id) + @tag.delete unless @tag.nil? + end # end end end -private + private # 这里用来刷新搜索结果的区域 # 函数的返回值 前2字段用来处理获取其他tag和分页 ,另外4个返回值为过滤结果 def refresh_results(obj_id,obj_flag,selected_tags) @@ -174,11 +180,12 @@ private @projects_results = nil @issues_results = nil @bids_results = nil + @contests_results = nil @forums_results = nil attachments_results = nil @obj_pages = nil @obj = nil - + # 这里为了提高系统的响应速度 把搜索结果放到case中去了 case obj_flag when '1' then @@ -199,10 +206,22 @@ private when '6' @obj = Attachment.find_by_id(obj_id) @obj_pages, attachments_results, @results_count = for_pagination(get_attachments_by_tag(selected_tags)) + when '7' + @obj = Contest.find_by_id(obj_id) + @obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags)) else - @obj = nil + @obj = nil end - return @obj,@obj_pages,@results_count,@users_results,@projects_results,@issues_results,@bids_results,@forums_results, attachments_results + return [@obj, + @obj_pages, + @results_count, + @users_results, + @projects_results, + @issues_results, + @bids_results, + @forums_results, + attachments_results, + @contests_results] end def for_pagination(results) @@ -222,7 +241,8 @@ private @bids_tags_num = Bid.tag_counts.size forum_tags_num = Forum.tag_counts.size attachment_tags_num = Attachment.tag_counts.size - return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num, forum_tags_num, attachment_tags_num + @contests_tags_num = Contest.tag_counts.size + return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num, forum_tags_num, attachment_tags_num, @contests_tags_num end # 通过数字 来转换出对象的类型 @@ -243,6 +263,8 @@ private return 'Forum' when '6' return 'Attachment' + when '7' + return 'Contest' else render_error :message => e.message return diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e9e649181..446266fb7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -653,6 +653,8 @@ class UsersController < ApplicationController @obj = Forum.find_by_id(@obj_id) when '6' @obj = Attachment.find_by_id(@obj_id) + when '7' then + @obj = Contest.find_by_id(@obj_id) else @obj = nil end diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index c4ee5273d..ba2470fe9 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -5,15 +5,17 @@ module TagsHelper @obj = nil case obj_type when '1' - @obj = User.find_by_id(obj_id) + @obj = User.find_by_id(obj_id) when '2' @obj = Project.find_by_id(obj_id) when '3' @obj = Issue.find_by_id(obj_id) when '4' - @obj = Bid.find_by_id(obj_id) + @obj = Bid.find_by_id(obj_id) when '6' @obj = Attachment.find_by_id(obj_id) + when '7' + @obj= Contest.find_by_id(obj_id) else raise Exception, '[TagsHelper] ===> tag type unknow.' end @@ -40,6 +42,10 @@ module TagsHelper if user.id == obj_id @result = true end + when '7' + if user.id == obj_id + @result = true + end end return @result end diff --git a/app/views/contests/_list_softapplications.html.erb b/app/views/contests/_list_softapplications.html.erb index 2c2034a5d..29c985b7e 100644 --- a/app/views/contests/_list_softapplications.html.erb +++ b/app/views/contests/_list_softapplications.html.erb @@ -1,41 +1,35 @@ <% contesting_softapplication.each do |c_softapplication|%> <% if c_softapplication.softapplication %> - +
+
+
+ + +
+ +
+ - -
应用软件: + <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication)) %> +
简介: - - - - - - -
- - - - - - - - - - - - -
- - <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication)) %> - - <%= l(:label_joined_contest)%> -
<%= c_softapplication.softapplication.description %>
- <%=format_time c_softapplication.created_at %> -
-
+ <%= c_softapplication.softapplication.description %>
+
发布时间: + <%=format_time c_softapplication.created_at %> +
- <%= link_to(l(:button_contesting_as_application), {:controller => 'softapplications', :action => 'new'}) %> + <%= link_to l(:button_contesting_as_application), "javascript:void(0);", onclick: "$('#put-bid-form').toggle();" %>
diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index 3c37cfe5a..79118fca7 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -146,7 +146,7 @@
- <%= render :partial => 'tags/tag', :locals => {:obj => @contest, :object_flag => "4"}%> + <%= render :partial => 'tags/tag', :locals => {:obj => @contest, :object_flag => "7"}%>
diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index f21d2cecb..0e2ee738d 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -59,7 +59,7 @@
-
+
软件评论:
@@ -78,6 +78,5 @@
-<%= link_to 'Edit', edit_softapplication_path(@softapplication) %> | -<%= link_to 'Back', softapplications_path %> +<%#= link_to '返回竞赛页面', show_softapplication_contest_path(contest)) %>
diff --git a/app/views/tags/_sidebar_tags.html.erb b/app/views/tags/_sidebar_tags.html.erb index cc377e6b4..8db485d1f 100644 --- a/app/views/tags/_sidebar_tags.html.erb +++ b/app/views/tags/_sidebar_tags.html.erb @@ -9,5 +9,6 @@ (<%= Bid.tagged_with("#{sg}").size %>) <% when '5' then %> (<%= Forum.tagged_with("#{sg}").size %>) - +<% when '6' then %> +(<%= Attachment.tagged_with("#{sg}").size %>) <% end %> diff --git a/app/views/tags/_tag.html.erb b/app/views/tags/_tag.html.erb index c38bdbaf5..896b6a2c8 100644 --- a/app/views/tags/_tag.html.erb +++ b/app/views/tags/_tag.html.erb @@ -6,7 +6,7 @@ 4 代表是bid类型 5 代表是forum类型 6 代表是Attachment类型 - + 7 代表是contest类型 #end%> <% if object_flag == '3' %> diff --git a/app/views/tags/_tag_name.html.erb b/app/views/tags/_tag_name.html.erb index d1291ee78..297f813df 100644 --- a/app/views/tags/_tag_name.html.erb +++ b/app/views/tags/_tag_name.html.erb @@ -79,6 +79,13 @@ <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag, :taggable_id => obj.id,:taggable_type => object_flag %> <% end %> + <% when '7'%> + <% if obj.author_id == User.current.id %> + + <%= link_to 'x',:controller => "tags",:action => "remove_tag",:remote => true,:tag_name => tag, + :taggable_id => obj.id,:taggable_type => object_flag %> + + <% end %> <% end %> diff --git a/app/views/tags/_tag_search_results.html.erb b/app/views/tags/_tag_search_results.html.erb index c67ece520..49a5bcd82 100644 --- a/app/views/tags/_tag_search_results.html.erb +++ b/app/views/tags/_tag_search_results.html.erb @@ -19,6 +19,9 @@ <% when show_flag == '6'%> <%= l(:label_attachment)%>(<%= @results_count %>) <%= render :partial => "show_attachments",:locals => {:attachments_results => attachments_results}%> + <% when show_flag == '7'%> + <%= l(:label_contest_innovate)%>(<%= @results_count %>) + <%= render :partial => "show_contests",:locals => {:contests_results => contests_results}%> <% else %> <%= l(:label_tags_all_objects)%> @@ -26,6 +29,7 @@ <%= render :partial => "show_users",:locals => {:users_results => users_results }%> <%= render :partial => "show_projects",:locals => {:projects_results => projects_results }%> <%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%> + <%= render :partial => "show_contests",:locals => {:contests_results => contests_results}%> <% end %> <% else %> diff --git a/app/views/tags/add_tag.js.erb b/app/views/tags/add_tag.js.erb index fb4dd5af9..662e3f77c 100644 --- a/app/views/tags/add_tag.js.erb +++ b/app/views/tags/add_tag.js.erb @@ -5,6 +5,6 @@ $('#related_tags').html('<%= j(render :partial => "related_tags", $('#show_results').html('<%= j(render :partial => "tag_search_results",:locals => {:issues_results => @issues_results, :projects_results => @projects_results,:users_results => @users_results, - :bids_results => @bids_results ,:show_flag => @show_flag,:obj_pages => @obj_pages })%>') + :bids_results => @bids_results,:contests_results => @contests_results,:show_flag => @show_flag,:obj_pages => @obj_pages })%>') diff --git a/app/views/tags/delete_tag.js.erb b/app/views/tags/delete_tag.js.erb index 37f0de92f..19cd2f5e9 100644 --- a/app/views/tags/delete_tag.js.erb +++ b/app/views/tags/delete_tag.js.erb @@ -5,6 +5,6 @@ $('#related_tags').html('<%= j(render :partial => "related_tags", $('#show_results').html('<%= j(render :partial => "tag_search_results",:locals => {:issues_results => @issues_results, :projects_results => @projects_results,:users_results => @users_results, - :bids_results => @bids_results ,:show_flag => @show_flag ,:obj_pages => @obj_pages })%>') + :bids_results => @bids_results ,:contests_results => @contests_results ,:show_flag => @show_flag ,:obj_pages => @obj_pages })%>') diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb index 17ac58184..48ba53d88 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/tags/index.html.erb @@ -23,12 +23,20 @@ <%= l(:label_user_plural) %>(<%= @users_tags_num %>) | <%= l(:label_tags_call)%>(<%= @bids_tags_num %>) | <%= l(:field_filename)%>(<%= @attachments_tags_num %>) + <%= l(:label_tags_contest)%>(<%= @contests_tags_num %>) |
<%# 求工厂模式重构 %> - <%= render :partial => "tag_search_results",:locals => {:issues_results => @issues_results, - :projects_results => @projects_results,:users_results => @users_results , - :bids_results=>@bids_results,:forums_results => @forums_results, :attachments_results => @attachments_results, :show_flag => @obj_flag}%> + <%= render :partial => "tag_search_results", + :locals => {:issues_results => @issues_results, + :projects_results => @projects_results, + :users_results => @users_results, + :bids_results => @bids_results, + :forums_results => @forums_results, + :attachments_results=> @attachments_results, + :contests_results => @contests_results, + :show_flag => @obj_flag} + %>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index ad0d98f51..a483f32dd 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1844,4 +1844,8 @@ zh: label_contest_description_no: 暂无描述。 label_no_contest_softapplication: 暂无参赛应用 label_button_ok: 确定 + label_tags_contest: 竞赛标签 + label_tags_contest: 竞赛名称 + label_tags_contest_description: 竞赛描述 + \ No newline at end of file diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index b8f40bdfe..bbf48703b 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -2721,7 +2721,11 @@ div.repos_explain{ border-bottom: 1px dashed rgb(204, 204, 204); width: 660px; } - +.underline-contests_three{ + margin-bottom: 10px; + border-bottom: 1px dashed rgb(204, 204, 204); + width: 688px; +} .contest-star{ color: #bb0000; } From 945ca3787a9a1e489a183460bc587533b34075a0 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 16 Apr 2014 09:52:36 +0800 Subject: [PATCH 26/43] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E4=B8=ADtop-menu=E8=B7=B3=E8=BD=AC=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=EF=BC=9A=E5=A2=9E=E5=8A=A0=E8=B7=B3=E8=BD=AC=E5=88=B0?= =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E6=A8=A1=E5=9D=97=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_base_header.html.erb | 1 + app/views/welcome/contest.html.erb | 98 ++++++++++--------------- 2 files changed, 39 insertions(+), 60 deletions(-) diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index 8a066d4f8..140ff92ba 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -5,6 +5,7 @@ @nav_dispaly_home_path_label = 1 @nav_dispaly_main_course_label = 1 @nav_dispaly_main_project_label = 1 + @nav_dispaly_contest_label = 1 elsif (realUrl.match(/contest/)) @nav_dispaly_contest_label = 1 elsif (realUrl.match(/calls/)) diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 1b265ade9..60aafd949 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -101,7 +101,7 @@ <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %>
-
+ + +
+ <%= form_tag({controller: 'contests', action: 'index'}, method: :get) do %> + <%= text_field_tag 'name', params[:name], placeholder:'请输入要搜索的关键字', name: "name", :class => 'blueinputbar', :style => 'width:240px;'%> +   + <%= hidden_field_tag 'project_type', params[:project_type] %> + <%= submit_tag l(:label_search), :class => "enterprise" , :name => nil%> + <% end %> +
+
- -
- - <%= form_tag({controller: 'contests', action: 'index'}, method: :get) do %> - <%= text_field_tag 'name', params[:name], placeholder:'请输入要搜索的关键字', name: "name", :class => 'blueinputbar', :style => 'width:400px;'%> -   - <%= hidden_field_tag 'project_type', params[:project_type] %> - <%= submit_tag l(:label_search), :class => "enterprise" , :name => nil%> - <% end %> -
竞赛相关内容搜索,如竞赛题目,参赛题目,参赛人名等。
-
+ @@ -138,7 +139,7 @@

最新热门竞赛

- <%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1, :host => Setting.contest_domain}, :target => "_blank" %> + <%= link_to "更多>>", {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %>
    <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[10]) %> @@ -157,29 +158,35 @@
-
    -

    用户动态

    - <%= link_to "更多>>", { :controller => 'users', :action => 'index'}, :target => "_blank" %> -
    - <% find_all_activities.each do |event| %> -
  • -
    - <%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %> -
    - -
    - <%= link_to event.event_author, (user_path(event.event_author) if event.event_author), :style => "color:green;", :target => "_blank" %><%= show_user_content event %> -

    <%= l(:field_updated_on) %><%= time_tag_welcome event.event_datetime %>前     <%= show_event_reply event %>

    +

    + 问题和反馈动态 + <%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> + <%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> +

    + <%= link_to "更多>>", forums_path %> +
    +
      + <% find_new_forum_topics(10).each do |topic|%> +
    • +
      +       + <%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %> + +
      + <%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前 + + 由 <%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);" %> 发表 + + 回复(<%= link_to (topic.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url %>)
    • - <% end %> -
    + <% end %>
+
-

最新参赛应用

- <%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1, :host => Setting.contest_domain}, :target => "_blank" %> +

最新参赛应用

    <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[10]) %> @@ -196,36 +203,7 @@
-
-
    -
    -

    - 贴吧动态 - <%= link_to "我要提问" , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> - <%= link_to "我要反馈" , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>

    - <%= link_to "更多>>", forums_path %> -
    -
    - <% find_new_forum_topics(7).each do |topic|%> -
  • -
    -       - <%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;", :target => "_blank" %> - -
    - <%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前 - - 由 <%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);", :target => "_blank" %> 发表 - - 回复(<%= link_to (topic.parent ? topic.parent.replies_count : topic.replies_count), topic.event_url, :target => "_blank" %>) -
    -
  • - <% end %> -
    -
-
- - +
From 3a5b5bc0cec58fa75ea9c38fd496963947e85bd8 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 16 Apr 2014 17:32:58 +0800 Subject: [PATCH 27/43] =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=B9=B6=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E7=AB=9E=E8=B5=9B=E6=A8=A1=E5=9D=97=E7=9A=84=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E6=98=BE=E7=A4=BA=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/contests_helper.rb | 1 + app/helpers/welcome_helper.rb | 6 +- app/views/welcome/contest.html.erb | 101 +++++++++++++++++------------ 3 files changed, 65 insertions(+), 43 deletions(-) diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb index 93af48b4c..cb4d6a0f7 100644 --- a/app/helpers/contests_helper.rb +++ b/app/helpers/contests_helper.rb @@ -167,5 +167,6 @@ module ContestsHelper end tmp end + end \ No newline at end of file diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index f56281d6b..10e8a4471 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -98,9 +98,13 @@ module WelcomeHelper end def find_all_hot_contest limit=10 - Contest.all.take limit + Contest.reorder("created_on DESC").all.take limit end + def find_all_hot_softapplication limit=10 + Softapplication.reorder("created_at DESC").all.take limit + end + def cal_memos_count event return nil if event.parent_id event.replies_count diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 60aafd949..935f28ea5 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -93,10 +93,11 @@
+
<%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %>
@@ -125,38 +126,46 @@ <% end %>
-
- -
-
-

最新热门竞赛

- <%= link_to "更多>>", {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %> +
+

最新热门竞赛

+ <%= link_to "更多>>", {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %>
-
    - <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[10]) %> -
  • -

    - <%= link_to( contest.name, respond_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", - :style => "margin-left: 28px;", :target => "_blank") %> -

    -

    - <%= content_tag "span", contest.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => contest.description %> -

    +
    + <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %> + +
  • +
    + <%= image_tag('/images/039.gif')%> +
    + +
    + <%= link_to(contest.name, show_contest_contest_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %> +
    + +
    + ><%=contest.description.truncate(50, omission: '...')%> +

    + +
    + <%= l(:label_contest_project, :count => contest.contesting_projects.count) %>(<%= link_to(contest.contesting_projects.count, show_project_contest_path(contest)) %>) + <%= l(:label_contest_softapplication, :count => contest.contesting_softapplications.count) %>(<%= link_to(contest.contesting_softapplications.count, show_softapplication_contest_path(contest)) %>) +
    +
  • - <% end %> -
+ <% end; reset_cycle %> + +
+

问题和反馈动态 @@ -167,7 +176,7 @@
    <% find_new_forum_topics(10).each do |topic|%> -
  • +
  •       <%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;" %> @@ -184,32 +193,40 @@

-
-

最新参赛应用

+
+

最新参赛应用

+ <%= link_to "更多>>", {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %>
-
    - <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[10]) %> -
  • -

    - <%= link_to( contest.name, respond_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", - :style => "margin-left: 28px;", :target => "_blank") %> -

    -

    - <%= content_tag "span", contest.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => contest.description %> -

    +
    + <% find_all_hot_softapplication.map do |softapplication| break if(softapplication == find_all_hot_softapplication[5]) %> + +
  • +
    + <%= image_tag('/images/007.gif')%> +
    + +
    + <%= link_to(softapplication.name, softapplication_path(softapplication.id), :class => "d-g-blue d-p-project-name", :title => "#{softapplication.name}", :target => "_blank") %> +
    + +
    + ><%=softapplication.description.truncate(50, omission: '...')%> +

    + +
    + 发布时间:<%=format_time softapplication.created_at %> +
    +
  • - <% end %> -
+ <% end; reset_cycle %> + +
- -
-
- -






-
+
+ From 1a6a20e761b61fddacbf7cf5655b78eabf38b322 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 16 Apr 2014 20:23:38 +0800 Subject: [PATCH 28/43] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=B8=83=E5=B1=80=E5=92=8C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E8=B0=83=E6=95=B4=E5=A5=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/tags/_show_contests.html.erb | 15 +++++++++++++++ app/views/welcome/contest.html.erb | 8 ++++---- public/images/008.jpg | Bin 0 -> 12246 bytes public/images/009.gif | Bin 0 -> 361 bytes 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 app/views/tags/_show_contests.html.erb create mode 100644 public/images/008.jpg create mode 100644 public/images/009.gif diff --git a/app/views/tags/_show_contests.html.erb b/app/views/tags/_show_contests.html.erb new file mode 100644 index 000000000..79c756522 --- /dev/null +++ b/app/views/tags/_show_contests.html.erb @@ -0,0 +1,15 @@ +
+ <% if contests_results.size > 0 %> +
+ <% contests_results.each do |contest| %> +

+ <%= l(:label_tags_contest) %>:<%= link_to "#{contest.name}", + :controller => "contests",:action => "show",:id => contest.id %> +
+ <%= l(:label_tags_contest_description) %>:<%= contest.description %> + <%= contest.updated_on %> +

+
+ <% end %> + <% end %> +
diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 935f28ea5..3135595f8 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -141,7 +141,7 @@ <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
  • -
    +
    <%= image_tag('/images/039.gif')%>
    @@ -196,14 +196,14 @@

    最新参赛应用

    - <%= link_to "更多>>", {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %> +
    <% find_all_hot_softapplication.map do |softapplication| break if(softapplication == find_all_hot_softapplication[5]) %>
  • -
    - <%= image_tag('/images/007.gif')%> +
    + <%= image_tag('/images/009.gif')%>
    diff --git a/public/images/008.jpg b/public/images/008.jpg new file mode 100644 index 0000000000000000000000000000000000000000..378e72164127df215c430eb53893e456fdda672f GIT binary patch literal 12246 zcmeG?cUV-%_H(xayYwPpVWmskzU;0dWvK#!fC|Q_%kE`a*ya{MVz03z#)hKChFzb= ziW)TvmRMpzvByw?-2@AYqVk)2mztNDeD8hlub;EuoIP{SnKNh3oS8d!?zG-$tpRp} zViRHkLO?(~{DIb5(u9~IWexzz$shm#U;(Iz10X^Sfj@w_12T>Skd5^0!1ECQHW>nx zVFL(3FPQZR2gjWt{`D*+Ahp$95C1O#t9O$D@Uv_GkCbb(QATR6)~Ge)YIO`rI*&12 zsgY|74S>U9^TaHkm@QziMPeRAI8X&3u0c9&TSMs3-*XMI1GmEjVWJ?!Hd#v7ejt51 z`+@j&?FaNpo4rT~p+h$@&a4je7UmK2e`{A?Vl>Q`PXQh8(`ZRDKw5tTHh2lhCu22R zZ-eQ8Zed|zX+gKNq}$W1X!g#wbh@pxtD~c{qob=m9Zzk4=E5H#Vojr2+gRJ#*w{JQ z*w{E>z{bg3#r~ftXgvn(Er1>9NklvW!5$&nBdtHfZWCHhAmPwTGJ+>)FqVigP)KA7 z)xy$>2E(B{69EKbJJSvzB!oyH5y(`E1(`_aLZ&^D)YpMcjvOL&^c*{dLvdQLc2|^_ zw{zO@Y%Whf^|FNOvoO7}_Lwz)-W2snIj-6h)c>jI1XS1m^#2X1&T zKW&;YJlwb9R=)%8%bxar_%uHtKd|ua@X&WJHQSns-yPjBe`(Ay87=eO_C(r|Q1!sa zna2+v-MR7L*=HZV`(;kc&WH1Mzp53VeO=EI-sOaaT~L$_zFj)&V72r^$+rDNwVTkA zw|N^A?z;(I(%6rSCk?&PAR3kKYrAsnxv8S0O-~!g%IjJD(&q5bUY?z#%U^rt)hd_LU*+_;gY!yDi#6ki zym}TVs(U&94!5S}&HLZ0!&`5*KD8Xsxd3oOSU?z+kWBKyqpy7;;{^<0JmS+fo_RVF z+NLD|ujh;NY;cH!@X6*{Bx}5gP46OH(ygQ12iN)nFI(ae0t9ahE>&2v!lylk;jIvx zFch}S%*lZq6@+ksfeC4&tSw#MLBUon1dM>NU51ZSf;%aA`^~TnfDSGqf0~F7F!rCa zTK^j!?h8yc>|2|su%*1S#KKF6*&ig#YOE*NGHCX=1x~^I1Zji_b8ger2T}pPq?$+7 z9V-(1Ltyp=Rs?V@0-z_%M8L*>xF(FzEnzLTCrlcv)h%@uXlJyUg%vd>l?wi0oug!H zO&Yl&B|A?BOKtViWJWeDVF3a%;Il}j)hI9=OG#*sv1>WXs8zR>aWm2sx$S(+G>So` zl%a-Usw4v}A>G;`<2*=qfSHOH5~924rYiJWldc0PBUMU8yQgf;osVxP z!172m|Wh=rlOQxqlSL=c_-a4A5aFgg4^2d46G=E^`PIaXCx^ z5Zi;ieb&HnAxA)Z9B_r3l26;1PurM#uRd*K{=03AdH(gq<{KCaGkjhGU<)FF9B4r{ zKmh}!f?S9jVK(5H4oW!wjRXToKsw-I3e7E;pPN+kYYGBi-s}T&jYgfA$(TV$ z!5OmRe3?k@89tCPph#S#)~QjWlu@KsX$<0`Fi%{$7~&Y2>B+!FjQL@n_$v-0GdYzZ z(dtnKFN71q36`-0Tn3*T!sT-W99|HE!(s`UtWYMG70edGS2;0T$Y@KRusyvzN1PTN z+twN^g?YAhtFW*zq>vk;)hn26kx0a3ahM!VFq8;3jMEsUMZp?_SG$I2)F9IzcS5b}Q2VFe>LQq&{BcpW8gl`z)?kb&fUSIN7!24`gPDdJv?jd_ zjVVAiMz8kja#=@R9ei%$J(bIts0vj>F#{Y%c1KgX_BZ8@D&6|g!N$kFy#b>#r_-I? zGrE(Oy>$>#}42SzYr+O{)6O zbjW4m9Iak0g#o5iOBEvrF%n`V z0=7sX2Nh#35bC4dRFdL0lF) zh|3njEDGXtVCHfl4eAMH!3VdnCv`XhCcwhbxE{ z31cILq8R8fEUv|=$|6*i8LfmvY`}fN3GK?s>cU|Q+Bmr1)8X0*{R>@(>*?M_u0SZ@ z1@TxS0SkxF_)s>-3^_Q(47rfbXPaesL0GL&9Kw#mPCyETkirx4SvZ89ggERXgwQFW zT<9_kLU{;97!*QD2(h-f(194lTH!*+Vi4Aa5U&f}%472&7lY7R2+fpG92a6x1nqPNwgagH6i=a*nVs%AAtgc9i$%urQj7Wsbh}bxeX%pevL?Wz35w25& zSpt^^K@c3wAQ%8af}qeKVUQ>Yx`xdTVsnDn+#ohD2o5e3VuuF7NZ>$O7#}b^VC3*& z5WyIL;R2(ezc5xPltl93K(qO*$f!sjD>e$oe^jI}QW6>+Bfy>+a2bG;J6>skOWC-# zr%*aNwhdD$8TisJmdebNL53}QsNA!Sto)M&X+PI_n{#9c95Va9`S88aS%;c~SGehDC8HtXbSIfkEr_?HDH>Y*%< zXm#W8!)u1WtRMV*FA_51(Lxn!GzO=_(UhY;4W^7enwdLtM^x(mHE)(zNT~r!4rnkN8a|ExQze@)-cQ-s+@zuYt#X(*f9j zu}gnkuz2Zmj-^CpA(%ru(%%YnNd7g_rM(cWy^fcBMzr}`2Lp?08T@u((lZR$3o9e| zk3sw&SL|X|7dwK|&>U2c!owEEFc@V@jRFq0My|vU=9HRlM-g2#{D;-LXuwc&Ttmch z{RiMQIt18VbOOYu=K;x)28bh9K@QR}Zb_EI;JGXS!#(bs;~wIWkHc<&Fdr5P1||Oe z3`o*47&4Q-z$`+-{>bnnu`O@{ZlDkF0{$Qva6l;N4;~oFFgOlQfphS-Of|R-YCr>c3>v{J&;sveP!Vgy z5phF25FaEE;UGd}AQFQlA!$e!G6qo~8pMQ*N2Vcjk%h=|WG%7<*@YZLjw5G~%g9Zn z7I}y~N8S>M1UkWq(3{{(U=oCcNJ1hZgYY>)K^RLYCQK)MO;|=)N7zo-PdH9EN2n&$ z5FQhn;6)l5(S_KT7)%rrCBzis2x1OVPn<}cLo6Y#Bkmv`BAzB*A=VI|5Z{m}Bu5g1 z6in(*iYE;v$w*^K6G`((%SoF_`$;EAS4g#_M$!keHMti#kSr!AkTb~&av^ypxrDrt zypMd6Tup8uzoJkmE)+jXC?%efMaiRlL77MSma>y_jB=S$Pidl3sczIjY8W+zDy15! zGpVK2?bIKrRn!J*vjxqjD#A2((QHv^z`xY&hc9uStV#^dux#c*^ z`IhS~4_RKcY_M#xvbXZH3bV?v%CnkcwajXV)k&*6RxfBYnkP*}8$wgkCexPDzN7s} ztEIi6JJ18@68cEGiT*Wx6a5(dCjEuAwY9Hxg!Kq(qxIL;TdXUs?^-w8INF5RB-qGp zCfTg8*>6*2^P8=ut&eS_?I_z~+Y;M7wij)m*jd{7+DYuBb`$MZ*d4UHZr5b*XwSA! zu~*yAv)^ie#{Pi=)xp;x#zF2d-J#5((xKjw=;-Arag;eub6oFu(y_sb;^gO);FRYy z*XdtQ7n~ZM9h`a2!<>tpS2!PWu5lr{__`#xs9ff|>~^{4^0r6s9+5rJ9YS*`J47V7!e76N|{-mc<&;C7SJ?He? z-Sbv2La%^cX}!MaRo3f#ucqF8ddKzF^)BsQ+51T!mp&1F^7<_9bF|Mx4@ZxI9!ihJ z9zS?IVmLD*87jsy#tBAa-(G#=`IIGP|vBJJ3W8)vhoso<#;Xjs_<&` z_V7;j9`C))`<9QTkI*OAXQ|I=pVz*AzQcWI`Ih@W@N@M`@GJJ)=6A>6+CSWXtp7Uy ztNkebg#GgSecSI+03m=MkQ=Zf;9?*lP!OmL{5J4%5E-5!X@b@TT@R)QM+O%JZwsys zaS2HZnHo|a@*C5eIfA)>d7Alw#b>El>shzi4(vhfsq91S=bQkJjI)Asm21t7lBI|L6yy+g-@t_-~{bP}ct=LvrlkwsCWNutA| zH)4UC&SW)_@eNnF^V#x%_v1np+T=bmi3o#BcLt~c5+>P~&Rm5(K zZH(i`eGzvoo*bVTzaaj4Lhl4w!j^=_L7{^t3_6iWPfSl-o>-R@kfcvKluSq-l)NbU z&S0Oxn!)8MASEGXQOeJ$eyL+qzaK&wk~(C?kb7zDwDD=D(;d@Cr*BPvl@XOOKjZdL z|DmR#6~kFoHT_*ociInm&v9Y{_R0Bl#m| zj=c7{-{(c2pBd#oN;T@pXxq`!(R;>_#|$5{b<8_yigcZ{DLWy1Wp<-XB3mkZERT>c zmOn(p(1qyzoUojQIS&+JibaZtx#77bxlfc5<#Oe-y!gD;d9U+R@;BwTs)nm}sx8!G z)CV;VntaU(Z69rs_OdQeH&a(LRy=me*hYP#exm^~d~P^kbb_0y^Co}O3{!2vz=9P8 z&4t4X_Y~O|X^PH|3m7+h-2LL%;tgMrzL0%UF~0BkDdTG=L{3;c5t*1hv0{?fr0J6y zCdWOTpoUbp;7tCMv4dolnH`f+~FW9`$eqr&# z`bEi$_Ah2Ep0oJnlF>`fl<-PcFSS}~T3WL#Y1x5N@6vBd-!0EwUcDk}#m<$zR?c4e z`dj(8RjVRa?O5G=_1x8O*C^NASR1!?|2p4wC1sSdg0g$-hpj)oLAYVdM)!?#H@@Gb z*;KPRZS#pOp__&G+uvB8TV8V@>%irMgAP_4>VIh8_aWbJI^6g0iX+ZP z<{z~>I{j$t55+$;9n&3qa$Iq|zG8I6?aIu`t0#t>xNtJ@{h|8mfMr>knha-+3x3(yS?tN`=#G6J8J|rM{1*M z&)22b-L99_KmOJ5>$`^O_pI-g-1oS@ z@0Pvq_x{j_#1D5`)$meQ=S@#+FJQjuNg5Qz39K!#U6BZp8NrSPh!6KBC%s%KvhTK?LRcGNl&C<%%ZTjMv*!6pdT^Z`{{=EJLcH0v*%~)c- z@%a}QK85j_xkXW64m%EP3&@NBzXw5m@;Uh)CdYQUrP}q9YB!rd zV)7p@lPXHbHxZ8-hr z7uMce&GCcfZ=;WdR~Lq@y^%%wPI`*zUHf=xWAn<9>2<4HMz<_G;+&Nw>9_T}%>z#h zb_T?#?)pz^z4Y{M-n+v`s|TEsZn=3E*+g5GQ*E4m^S$K+LD`@$Ma-?T%`JiF-t5WR z{^UhT#4qdW>m{j{umPi^ zWsmDVY@al(Is8KL;nKaX&n+qkl+AnOW!ZRdwQWNyV4iL&Iv8#WPO-z3(kBY&q9wh0oRp4vA8$&qo#CU3Mr-y?$SUd;h#$v+K&IJx%!O zUTw?ahZmXjc}Yk3#~(JOyt%u|qxQqL4Of&c;U_EUyDA+Q%imqJQJ%9|U0L5aV8Eq| z{$ua8f_`od=ic>VpFH{aLHJq|Gw#a!@JSb|UcT433^-VPbknvE&l{VB6YHPA>$5F8 zuf2bj)97(O@%{XFiRUM3d;c!<_n#NY}LtRbX``=$Qw}SbV?{Bx>{6DSV BWO4ui literal 0 HcmV?d00001 diff --git a/public/images/009.gif b/public/images/009.gif new file mode 100644 index 0000000000000000000000000000000000000000..b90b130fb498f23be9d51ab122ccf6715837b6ae GIT binary patch literal 361 zcmZ{fO(??w9ESgXKDQy%Ldtj1Y(oAF3CqWp9H4i1!)oLqh{bN3#e({p&^#@^YSd#=3rfg z-HIa{9_|pjM>vR=FkWBq@y_aO)|T`o#{s_!fn%KdaS_1v*>Brlb>DmF^=p+AE{E^Lty?|3aGvTfHAimWXit++_XCWXpO^pu literal 0 HcmV?d00001 From 28ffd44e5574df56ce2af8b2cdd48ccbfd58e223 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 16 Apr 2014 21:16:51 +0800 Subject: [PATCH 29/43] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=8A=A0=E5=85=A5=E7=AB=9E=E8=B5=9B=EF=BC=8C?= =?UTF-8?q?=E5=85=B3=E6=B3=A8=E4=BB=A5=E5=8F=8A=E9=85=8D=E7=BD=AE=E7=AB=9E?= =?UTF-8?q?=E8=B5=9B=E7=9A=84=E6=98=BE=E7=A4=BA=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_newcontest.html.erb | 45 +++++++++++++--------- app/views/welcome/contest.html.erb | 4 +- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index 79118fca7..f8c7056b6 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -56,29 +56,34 @@ <%= image_tag(url_to_avatar(@user), :class => "avatar2") %> - + + - - - - - <% if User.current.login? %> - - - - <% end %> - -
    <%= h @contest.name %>
    - <%= join_in_competition(@contest, User.current)%> - <%= new_watcher_link(@contest, User.current) %> -
    - + + + + + <% if User.current.login? %> + + + + <% end %> + <% if User.current.logged? %> <% if @contest.author.id == User.current.id %> - <%= link_to l(:label_contest_modify_settings), {:controller => 'contests', :action => 'settings', :id => @contest} %> + + + <% end %> - <% end %> - + <% end %> +
    <%= h @contest.name %>
    + <%= join_in_competition(@contest, User.current)%> + <%= new_watcher_link(@contest, User.current) %> +
    + <%= link_to l(:label_contest_modify_settings), {:controller => 'contests', :action => 'settings', :id => @contest} %> +
    + +
    @@ -201,8 +206,10 @@
  • +
    +
    <% if display_main_menu?(@contest) %>
    diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 3135595f8..f3d7f092e 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -119,7 +119,7 @@
    <%= form_tag({controller: 'contests', action: 'index'}, method: :get) do %> - <%= text_field_tag 'name', params[:name], placeholder:'请输入要搜索的关键字', name: "name", :class => 'blueinputbar', :style => 'width:240px;'%> + <%= text_field_tag 'name', params[:name], placeholder:'请输入要搜索的关键字', name: "name", :class => 'blueinputbar', :style => 'width:240px; padding-right:50px;'%>   <%= hidden_field_tag 'project_type', params[:project_type] %> <%= submit_tag l(:label_search), :class => "enterprise" , :name => nil%> @@ -175,7 +175,7 @@ <%= link_to "更多>>", forums_path %>
      - <% find_new_forum_topics(10).each do |topic|%> + <% find_new_forum_topics(11).each do |topic|%>
    •       From 7adb1f8a60737ca6562e59f1eecd95c215a92b0c Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 16 Apr 2014 21:23:04 +0800 Subject: [PATCH 30/43] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BE=A7=E9=9D=A2?= =?UTF-8?q?=E7=9F=AD=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/contests/show_softapplication.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/contests/show_softapplication.html.erb b/app/views/contests/show_softapplication.html.erb index 6c932df50..f320393ea 100644 --- a/app/views/contests/show_softapplication.html.erb +++ b/app/views/contests/show_softapplication.html.erb @@ -68,7 +68,7 @@

      - <%= link_to '发布应用', new_softapplication_path(:target=>'_blank') %> + <%= link_to '发布应用', new_softapplication_path(:target=>'_blank'), :target=>'_blank' %>

      From a52e057d94bc9e974ea4fe7f0370b02eeced3047 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Wed, 16 Apr 2014 21:44:52 +0800 Subject: [PATCH 31/43] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=B8=8D=E8=83=BD=E5=88=B7=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 6 +++--- config/locales/zh.yml | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 86c4df367..2c09a8809 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -300,13 +300,13 @@ class ContestsController < ApplicationController contest_message = params[:contest_for_save][:contest_message] if ContestingSoftapplication.where("softapplication_id = ? and contest_id = ?", softapplication.id, @contest.id).size == 0 if ContestingSoftapplication.create_softapplication_contesting(@contest.id, softapplication.id, contest_message) - flash.now[:notice] = l(:label_bidding_contest_succeed) + flash.now[:notice] = l(:label_release_add_contest_succeed) end else - flash.now[:error] = l(:label_bidding_fail) + flash.now[:error] = l(:label_add_contest_succeed_fail) end - @contesting_softapplication = @contest.contesting_softapplications + @contesting_softapplication = paginateHelper @contest.contesting_softapplications respond_to do |format| diff --git a/config/locales/zh.yml b/config/locales/zh.yml index a483f32dd..2b1883382 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1847,5 +1847,8 @@ zh: label_tags_contest: 竞赛标签 label_tags_contest: 竞赛名称 label_tags_contest_description: 竞赛描述 + label_release_add_contest_succeed: 该应用发布并添加成功. + label_add_contest_succeed_fail: 添加失败,该应用已参赛. + \ No newline at end of file From 9206a30bd4aba7ecd27ff63b35b020106ebd79a1 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Thu, 17 Apr 2014 14:49:51 +0800 Subject: [PATCH 32/43] =?UTF-8?q?=E5=B0=86=E6=8F=90=E4=BA=A4=E5=92=8C?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=8C=89=E9=92=AE=E6=94=BE=E5=88=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E7=9A=84=E6=A1=86=E5=86=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/new_submit_homework.html.erb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/bids/new_submit_homework.html.erb b/app/views/bids/new_submit_homework.html.erb index dd06af643..eb89740a8 100644 --- a/app/views/bids/new_submit_homework.html.erb +++ b/app/views/bids/new_submit_homework.html.erb @@ -8,8 +8,9 @@

      <%= render :partial => 'attachments/form' %>

      + <%= submit_tag l(:button_create) %> + <%= link_to (t :button_back), project_for_bid_homework_path %> - <%= submit_tag l(:button_create) %> - <%= link_to (t :button_back), project_for_bid_homework_path %> + <% end %>
      \ No newline at end of file From 7c8ecd19441d2687270b213fb74bd0c5ba6ca32a Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Thu, 17 Apr 2014 16:50:36 +0800 Subject: [PATCH 33/43] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8A=A8=E6=80=81=E5=90=8E=E4=BE=9D=E7=84=B6=E8=83=BD?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=A1=B9=E7=9B=AE=E5=88=9B=E5=BB=BA=E7=9A=84?= =?UTF-8?q?=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/show.html.erb | 40 ++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index c49b08b5d..3ca41d072 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -1,4 +1,4 @@ -<% if @events_by_day.size >0 %> +

      @@ -43,26 +43,30 @@ <% end %>

      <% end -%> + + +
      + + + + + +
      <%= image_tag(url_to_avatar(@user), :class => "avatar") %> + + + + + +
      <%= link_to (h @user.try(:name)), user_path(@user) if @user %> <%= l(:label_user_create_project) %> <%= link_to @project.name %> !
      <%= l :label_update_time %>: <%= format_time(@project.created_on) %> +
      +
      +
    -<% else %> -
    - - - - - -
    <%= image_tag(url_to_avatar(@user), :class => "avatar") %> - - - - - -
    <%= link_to (h @user.try(:name)), user_path(@user) if @user %> <%= l(:label_user_create_project) %> <%= link_to @project.name %> !
    <%= l :label_update_time %>: <%= format_time(@project.created_on) %> -
    -
    -<% end %> + + + From 5699a947ec8d27d3bdd6e87c704bd78398a75403 Mon Sep 17 00:00:00 2001 From: Wen Date: Thu, 17 Apr 2014 17:36:41 +0800 Subject: [PATCH 34/43] =?UTF-8?q?=E5=BB=BA=E7=AB=8B=E4=BA=86=E5=AD=A6?= =?UTF-8?q?=E6=A0=A1=E4=B8=8E=E7=94=A8=E6=88=B7=E7=9A=84=E5=85=B3=E8=81=94?= =?UTF-8?q?=20=E8=AF=BE=E7=A8=8B=E4=B8=8E=E7=94=A8=E6=88=B7=E7=9A=84?= =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E5=AD=97=E6=AE=B5=E5=9D=87=E4=B8=BA=E5=AD=A6?= =?UTF-8?q?=E6=A0=A1id=E8=80=8C=E4=B8=8D=E5=86=8D=E6=98=AF=E5=AD=A6?= =?UTF-8?q?=E6=A0=A1=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 页面暂时改了想到的地方= = --- app/controllers/my_controller.rb | 4 +- app/controllers/projects_controller.rb | 2 +- app/controllers/school_controller.rb | 2 +- app/models/user_extensions.rb | 1 + app/views/layouts/base_users.html.erb | 550 +++++++++--------- app/views/my/account.html.erb | 2 +- app/views/projects/_course_form.html.erb | 2 +- ...85550_rename_courses_column_school_name.rb | 9 + ...7090022_change_courses_column_school_id.rb | 9 + ...091429_add_school_id_to_user_extensions.rb | 5 + db/schema.rb | 291 +++++++-- 11 files changed, 540 insertions(+), 337 deletions(-) create mode 100644 db/migrate/20140417085550_rename_courses_column_school_name.rb create mode 100644 db/migrate/20140417090022_change_courses_column_school_id.rb create mode 100644 db/migrate/20140417091429_add_school_id_to_user_extensions.rb diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index d05a1f59c..c469c72ee 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -87,7 +87,7 @@ class MyController < ApplicationController se = UserExtensions.new se.user_id = @user.id if params[:occupation] - se.occupation = params[:occupation] + se.school_id = params[:occupation] end se.gender = params[:gender] @@ -109,7 +109,7 @@ class MyController < ApplicationController else se = @user.user_extensions if params[:occupation] - se.occupation = params[:occupation] + se.school_id = params[:occupation] end se.gender = params[:gender] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 7db953a0b..c130d2ba6 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -390,7 +390,7 @@ class ProjectsController < ApplicationController # added by bai @course.term = params[:term] @course.time = params[:time] - @course.school_name = params[:occupation] + @course.school_id = params[:occupation] @course.setup_time = params[:setup_time] @course.endup_time = params[:endup_time] @course.class_period = params[:class_period] diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index 63791795c..749491b69 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -6,7 +6,7 @@ class SchoolController < ApplicationController options = "" @school.each do |s| - options << "" + options << "" end render :text => options diff --git a/app/models/user_extensions.rb b/app/models/user_extensions.rb index ea1548be9..7b35b16b4 100644 --- a/app/models/user_extensions.rb +++ b/app/models/user_extensions.rb @@ -8,6 +8,7 @@ =end class UserExtensions < ActiveRecord::Base belongs_to :user + belongs_to :school, :class_name => 'School', :foreign_key => :school_id attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code,:identity, :technical_title,:student_id TEACHER = 0 STUDENT = 1 diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 2063528cc..6fdb2d9ea 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -1,275 +1,275 @@ -<% @nav_dispaly_user_label = show_item_on_navbar(params) %> - - - - - <%= h html_title %> - - - <%= csrf_meta_tag %> - <%= favicon %> - <%= 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 %> - - <%= heads_for_theme %> - <%= call_hook :view_layouts_base_html_head %> - - <%= yield :header_tags -%> - - -
    -
    -
    - <%= render :partial => 'layouts/base_header'%> -
    - -
    - - - - - - - - - - -
    <%= l(:label_user_home) %><%= l(:label_user_location) %> : - -
    <%=link_to request.host()+"/users" ,:controller => 'users', :action => 'index' %> <%=link_to "主页", home_path %> > <%=link_to "软件创客", :controller => 'users', :action => 'index' %> > <%=link_to @user.name, user_path %>
    -
    - - - - -
    -
    - <% if @user.user_extensions.identity == 2 %> - <%= render_menu :user_enterprise_menu %> - <% else %> - <%= render_menu :user_menu %> - <% end %> -
    - - <%= yield %> - <%= call_hook :view_layouts_base_content %> -
    - <%= render_flash_messages %> - -
    - - <%= render :partial => 'layouts/base_footer'%> -
    - - -
    -
    -
    - <%= call_hook :view_layouts_base_body_bottom %> - - +<% @nav_dispaly_user_label = show_item_on_navbar(params) %> + + + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= 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 %> + + <%= heads_for_theme %> + <%= call_hook :view_layouts_base_html_head %> + + <%= yield :header_tags -%> + + +
    +
    +
    + <%= render :partial => 'layouts/base_header'%> +
    + +
    + + + + + + + + + + +
    <%= l(:label_user_home) %><%= l(:label_user_location) %> : + +
    <%=link_to request.host()+"/users" ,:controller => 'users', :action => 'index' %> <%=link_to "主页", home_path %> > <%=link_to "软件创客", :controller => 'users', :action => 'index' %> > <%=link_to @user.name, user_path %>
    +
    + + + + +
    +
    + <% if @user.user_extensions.identity == 2 %> + <%= render_menu :user_enterprise_menu %> + <% else %> + <%= render_menu :user_menu %> + <% end %> +
    + + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
    + <%= render_flash_messages %> + +
    + + <%= render :partial => 'layouts/base_footer'%> +
    + + +
    +
    +
    + <%= call_hook :view_layouts_base_body_bottom %> + + diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 6ff37ed7c..e46b25fc4 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -91,7 +91,7 @@

    <%= l(:field_occupation) %> *<%= 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", options_for_select([['安徽大学','安徽大学'],['合肥工业大学','合肥工业大学'],['中国科技大学','中国科技大学']]) %> + <%= select_tag "occupation" %>

    diff --git a/app/views/projects/_course_form.html.erb b/app/views/projects/_course_form.html.erb index ca736b05a..944157a9b 100644 --- a/app/views/projects/_course_form.html.erb +++ b/app/views/projects/_course_form.html.erb @@ -289,7 +289,7 @@ <%=l(:label_new_course_school)%>*    <%= 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", options_for_select([['安徽大学','安徽大学'],['合肥工业大学','合肥工业大学'],['中国科技大学','中国科技大学']]) %> + <%= select_tag "occupation" %>

    diff --git a/db/migrate/20140417085550_rename_courses_column_school_name.rb b/db/migrate/20140417085550_rename_courses_column_school_name.rb new file mode 100644 index 000000000..9a7d81067 --- /dev/null +++ b/db/migrate/20140417085550_rename_courses_column_school_name.rb @@ -0,0 +1,9 @@ +class RenameCoursesColumnSchoolName < ActiveRecord::Migration + def up + rename_column :courses, :school_name, :school_id + end + + def down + rename_column :courses, :school_id, :school_name + end +end diff --git a/db/migrate/20140417090022_change_courses_column_school_id.rb b/db/migrate/20140417090022_change_courses_column_school_id.rb new file mode 100644 index 000000000..813dbfdf9 --- /dev/null +++ b/db/migrate/20140417090022_change_courses_column_school_id.rb @@ -0,0 +1,9 @@ +class ChangeCoursesColumnSchoolId < ActiveRecord::Migration + def up + change_column :courses, :school_id, :integer + end + + def down + change_column :courses, :school_id, :string + end +end diff --git a/db/migrate/20140417091429_add_school_id_to_user_extensions.rb b/db/migrate/20140417091429_add_school_id_to_user_extensions.rb new file mode 100644 index 000000000..f97e8b9e3 --- /dev/null +++ b/db/migrate/20140417091429_add_school_id_to_user_extensions.rb @@ -0,0 +1,5 @@ +class AddSchoolIdToUserExtensions < ActiveRecord::Migration + def change + add_column :user_extensions, :school_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index a5cb5409c..669a6cb03 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140415090829) do +ActiveRecord::Schema.define(:version => 20140417091429) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -23,6 +23,15 @@ ActiveRecord::Schema.define(:version => 20140415090829) 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 => 20140415090829) 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 => 20140415090829) 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 @@ -157,38 +185,6 @@ ActiveRecord::Schema.define(:version => 20140415090829) do add_index "comments", ["author_id"], :name => "index_comments_on_author_id" add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" - create_table "contesting_projects", :force => true do |t| - t.integer "project_id" - t.string "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contesting_softapplications", :force => true do |t| - t.integer "softapplication_id" - t.integer "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contests", :force => true do |t| - t.string "name" - t.integer "budget" - 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 - end - create_table "courses", :force => true do |t| t.integer "tea_id" t.string "name" @@ -205,7 +201,7 @@ ActiveRecord::Schema.define(:version => 20140415090829) do t.string "setup_time" t.string "endup_time" t.string "class_period" - t.string "school_name" + t.integer "school_id" end create_table "custom_fields", :force => true do |t| @@ -265,6 +261,14 @@ ActiveRecord::Schema.define(:version => 20140415090829) 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 +290,137 @@ ActiveRecord::Schema.define(:version => 20140415090829) 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 => "" @@ -386,13 +521,6 @@ ActiveRecord::Schema.define(:version => 20140415090829) do add_index "issues", ["status_id"], :name => "index_issues_on_status_id" add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" - create_table "join_in_competitions", :force => true do |t| - t.integer "user_id" - t.integer "competition_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "join_in_contests", :force => true do |t| t.integer "user_id" t.integer "bid_id" @@ -518,6 +646,22 @@ ActiveRecord::Schema.define(:version => 20140415090829) 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 +677,19 @@ ActiveRecord::Schema.define(:version => 20140415090829) 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 +769,23 @@ ActiveRecord::Schema.define(:version => 20140415090829) 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 @@ -684,21 +858,6 @@ ActiveRecord::Schema.define(:version => 20140415090829) do t.string "description" end - create_table "softapplications", :force => true do |t| - t.string "name" - t.string "description" - t.integer "app_type_id" - t.string "app_type_name" - t.string "android_min_version_available" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "contest_id" - t.integer "softapplication_id" - t.integer "is_public" - t.string "application_developers" - end - create_table "students_for_courses", :force => true do |t| t.integer "student_id" t.integer "course_id" @@ -764,6 +923,22 @@ ActiveRecord::Schema.define(:version => 20140415090829) 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 @@ -789,6 +964,7 @@ ActiveRecord::Schema.define(:version => 20140415090829) do t.string "teacher_realname" t.string "student_realname" t.string "location_city" + t.integer "school_id" end create_table "user_grades", :force => true do |t| @@ -820,6 +996,9 @@ ActiveRecord::Schema.define(:version => 20140415090829) do 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| From 5ee1c8e2f2f1a3dd5dfcada1d4b6db226dd99502 Mon Sep 17 00:00:00 2001 From: yanxd Date: Thu, 17 Apr 2014 19:19:42 +0800 Subject: [PATCH 35/43] refactory zip --- app/controllers/zipdown_controller.rb | 161 ++++++++++++++++---------- app/views/test/courselist.html.erb | 4 +- 2 files changed, 104 insertions(+), 61 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 12f1976e0..dd855bc74 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -1,68 +1,111 @@ class ZipdownController < ApplicationController - def assort - obj_class = params[:obj_class] - obj_id = params[:obj_id] - obj = obj_class.constantize.find(obj_id) - case obj.class.to_s.to_sym - when :Bid - zip obj - else - logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!" - end + SAVE_FOLDER = "#{Rails.root}/files" + OUTPUT_FOLDER = "#{Rails.root}/tmp/archiveZip" - rescue NameError, ActiveRecord::RecordNotFound => e - logger.error "[ZipDown] ===> #{e}" - @error = e - end + def assort + obj_class = params[:obj_class] + obj_id = params[:obj_id] + obj = obj_class.constantize.find(obj_id) + zipfile = nil + case obj.class.to_s.to_sym + when :Bid + zipfile = zip_bid obj + else + logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!" + end + send_file zipfile, :filename => obj.name, :type => detect_content_type(zipfile) if zipfile - private + rescue NameError, ActiveRecord::RecordNotFound => e + logger.error "[ZipDown] ===> #{e}" + @error = e + end - def zip bid - # Todo: User Access Controll - homeworks_attach_path = [] - bid.homeworks.each do |homeattach| - homeattach.attachments.each do |attach| - length = attach.storage_path.length - homeworks_attach_path << attach.diskfile.to_s.slice((length+1)..-1) - end - end - @paths = homeworks_attach_path - zipfile = ziping homeworks_attach_path - send_file zipfile, :filename => bid.name, - :type => detect_content_type(zipfile) - rescue Errno::ENOENT => e - logger.error "[Errno::ENOENT] ===> #{e}" - @error = e - end + private - def ziping files_path - ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE') - folder = "#{Rails.root}/files" - input_filename = files_path - zipfile_name = "#{Rails.root}/tmp/archiveZip/archive_#{Time.now.to_i}.zip" + def zip_bid(bid) + # Todo: User Access Controll - Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) - Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| - input_filename.each do |filename| - zipfile.add(ic.iconv(filename_to_real(File.basename(filename))), folder + '/' + filename) - end - zipfile.get_output_stream("ReadMe"){ |os| - os.write "Homeworks" - } - end - zipfile_name - rescue Errno=> e - logger.error "[zipdown#zipping] ===> #{e}" - @error = e - end + homeattaches = bid.homeworks + # 得到每一个人所有文件打包的zip文件 + # 并将每一个人的zip打包为一个并返回路径 + user_zip_paths = homeattaches.map do |homeattach| + zip_homework_by_user homeattach + end + zipping bid.name, user_zip_paths, OUTPUT_FOLDER - def detect_content_type(name) - content_type = Redmine::MimeType.of(name) - content_type.to_s - end + #@paths = homeworks_attach_path + #zipfile = ziping homeworks_attach_path + #send_file zipfile, :filename => bid.name, + # :type => detect_content_type(zipfile) + #rescue Errno::ENOENT => e + # logger.error "[Errno::ENOENT] ===> #{e}" + # @error = e + end + + def zip_homework_by_user(homeattach) + homeworks_attach_path = [] + # 需要将所有homework.attachments遍历加入zip + # 并且返回zip路径 + user_attaches_paths = homeattach.attachments.each do |attach| + #length = attach.storage_path.length + homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) + end + zipping homeattach.user.name, user_attaches_paths, OUTPUT_FOLDER + end + + + def zipping(zip_name_refer, files_paths, output_path) + # 输入待打包的文件列表,已经打包文件定位到ouput_path + ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE') + #folder = SAVE_FOLDER + input_filename = files_paths + zipfile_name = "#{output_path}/archive_#{Time.now.to_i}.zip" + + Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) + + Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| + input_filename.each do |filename| + zipfile.add(ic.iconv(filename_to_real(zip_name_refer+"#{Time.now.to_s}") ), filename) + end + zipfile.get_output_stream('ReadMe') do |os| + os.write 'Homeworks' + end + end + zipfile_name + rescue Errno => e + logger.error "[zipdown#zipping] ===> #{e}" + @error = e + end + + #def ziping files_path + # ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE') + # folder = SaveFolder + # input_filename = files_path + # zipfile_name = "#{OutputFolder}/archive_#{Time.now.to_i}.zip" + # + # Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) + # Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| + # input_filename.each do |filename| + # zipfile.add(ic.iconv(filename_to_real(File.basename(filename))), folder + '/' + filename) + # end + # zipfile.get_output_stream("ReadMe") { |os| + # os.write "Homeworks" + # } + # end + # zipfile_name + #rescue Errno => e + # logger.error "[zipdown#zipping] ===> #{e}" + # @error = e + #end + + def detect_content_type(name) + content_type = Redmine::MimeType.of(name) + content_type.to_s + end + + def filename_to_real(name) + attach = Attachment.find_by_disk_filename(name) + attach.filename + end - def filename_to_real name - attach = Attachment.find_by_disk_filename(name) - attach.filename - end end diff --git a/app/views/test/courselist.html.erb b/app/views/test/courselist.html.erb index 61cd69e13..959d6a4be 100644 --- a/app/views/test/courselist.html.erb +++ b/app/views/test/courselist.html.erb @@ -17,14 +17,14 @@ <% @courses.each do |course| %>
    - <%= course.name %> + <%= course.name %> <% course.homeworks.each do |homework| %> <% homeworks_attach_path = [] %>
    <%= link_to homework.name, respond_path(homework) %>(<%=homework.homeworks.count %>)<%#Bid%>
    - <%= link_to "package", test_zip_path(:homework_id => homework.id)%>
    + <%= link_to "package", zipdown_assort_path(obj_class: homework.class, obj_id: homework.id) %>
    <% homework.homeworks.each do |homeattach|%><%#homework.class == Bid %> <% homeattach.attachments.each do |attach|%> <%= link_to_attachment attach, author: true, :download => true %> (<%=attach.author%>) From f30513217eea8f8d4107aa84d1889bf1e3bf830f Mon Sep 17 00:00:00 2001 From: xx Date: Fri, 18 Apr 2014 05:18:15 +0800 Subject: [PATCH 36/43] zip factory --- app/controllers/zipdown_controller.rb | 30 +++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index dd855bc74..57078a436 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -15,9 +15,9 @@ class ZipdownController < ApplicationController end send_file zipfile, :filename => obj.name, :type => detect_content_type(zipfile) if zipfile - rescue NameError, ActiveRecord::RecordNotFound => e - logger.error "[ZipDown] ===> #{e}" - @error = e + #rescue NameError, ActiveRecord::RecordNotFound => e + #logger.error "[ZipDown] ===> #{e}" + #@error = e end private @@ -31,7 +31,7 @@ class ZipdownController < ApplicationController user_zip_paths = homeattaches.map do |homeattach| zip_homework_by_user homeattach end - zipping bid.name, user_zip_paths, OUTPUT_FOLDER + zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER #@paths = homeworks_attach_path #zipfile = ziping homeworks_attach_path @@ -50,24 +50,28 @@ class ZipdownController < ApplicationController #length = attach.storage_path.length homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) end - zipping homeattach.user.name, user_attaches_paths, OUTPUT_FOLDER + zipping "#{Time.now.to_i}_#{homeattach.user.name.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true end - def zipping(zip_name_refer, files_paths, output_path) + def zipping(zip_name_refer, files_paths, output_path, is_attachment=false) # 输入待打包的文件列表,已经打包文件定位到ouput_path ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE') - #folder = SAVE_FOLDER input_filename = files_paths - zipfile_name = "#{output_path}/archive_#{Time.now.to_i}.zip" + + rename_zipfile = zip_name_refer ||= "archive_#{Time.now.to_i}.zip" + zipfile_name = "#{output_path}/#{rename_zipfile}" Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) - Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| - input_filename.each do |filename| - zipfile.add(ic.iconv(filename_to_real(zip_name_refer+"#{Time.now.to_s}") ), filename) - end - zipfile.get_output_stream('ReadMe') do |os| + Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| + input_filename.each do |filename| + rename_file = Time.now.to_i.to_s+ ic.iconv( (File.basename(filename)) ).to_s + rename_file = ic.iconv( filename_to_real( File.basename(filename))).to_s if is_attachment + + zipfile.add(rename_file, filename) + end + zipfile.get_output_stream('ReadMe') do |os| os.write 'Homeworks' end end From abef68d13a19d78e30845dbde72e3395634d195e Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 18 Apr 2014 09:06:52 +0800 Subject: [PATCH 37/43] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=97=B6=E4=B8=8D=E8=83=BD=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=88=B7=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 2 +- db/schema.rb | 235 ++++++++++++++++++++++++- 2 files changed, 235 insertions(+), 2 deletions(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 2c09a8809..5511b15ca 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -286,7 +286,7 @@ class ContestsController < ApplicationController flash.now[:error] = l(:label_bidding_fail) end - @contesting_project = @contest.contesting_projects + @contesting_project = paginateHelper @contest.contesting_projects respond_to do |format| diff --git a/db/schema.rb b/db/schema.rb index 54947fe75..b4a9ba972 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140414012423) do +ActiveRecord::Schema.define(:version => 20140417091429) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -23,6 +23,15 @@ ActiveRecord::Schema.define(:version => 20140414012423) 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 => 20140414012423) 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 => 20140414012423) 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 @@ -265,6 +293,14 @@ ActiveRecord::Schema.define(:version => 20140414012423) 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 => 20140414012423) 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 => 20140414012423) 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 => 20140414012423) 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 => 20140414012423) 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 @@ -764,6 +977,22 @@ ActiveRecord::Schema.define(:version => 20140414012423) 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 @@ -789,6 +1018,7 @@ ActiveRecord::Schema.define(:version => 20140414012423) do t.string "teacher_realname" t.string "student_realname" t.string "location_city" + t.integer "school_id" end create_table "user_grades", :force => true do |t| @@ -820,6 +1050,9 @@ ActiveRecord::Schema.define(:version => 20140414012423) do 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| From e136254c8d1d2bee9726bc6f282850530c9f00c5 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 18 Apr 2014 09:28:44 +0800 Subject: [PATCH 38/43] =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E4=BA=86=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E9=A1=B5=E9=9D=A2=E4=B8=AD=E7=9A=84=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_projects.html.erb | 2 +- lib/redmine.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index af9ad87eb..1a4ed1b47 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -53,7 +53,7 @@ <% @project = Project.find_by_id(@project.id)%> - + diff --git a/config/application.rb b/config/application.rb index 593eed64e..d37a9eae2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,6 +1,7 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' +require 'sprockets/railtie' if defined?(Bundler) # If you precompile assets before deploying to production, use this line diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 2845c3ce0..3067b0f23 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1,3 +1,4 @@ +//= require_directory ./rateable /* Redmine - project management software Copyright (C) 2006-2013 Jean-Philippe Lang */ From 775774ad634559b6b64564999f85436f94adc607 Mon Sep 17 00:00:00 2001 From: Wen Date: Fri, 18 Apr 2014 14:46:32 +0800 Subject: [PATCH 40/43] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8E=AA=E6=96=BD?= =?UTF-8?q?=EF=BC=9A=E5=8D=B3=E4=BD=BF=E7=94=A8=E6=88=B7=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=A1=AB=E5=86=99=E5=8D=95=E4=BD=8D=EF=BC=8C=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=B9=9F=E5=8F=AF=E4=BB=A5=E6=AD=A3=E5=B8=B8=E6=89=93=E5=BC=80?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E4=B8=8D=E6=98=AF=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_users.html.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 6fdb2d9ea..5c6f24524 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -166,7 +166,11 @@ <% unless @user.user_extensions.nil? %> <% unless @user.user_extensions.identity == 2 %> - + <% end %> From 76ccfe8ac434a902b6784c898de3df06aba2676f Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 18 Apr 2014 16:35:48 +0800 Subject: [PATCH 41/43] fix --- .idea/.generators | 8 + .idea/.name | 1 + .idea/.rakeTasks | 7 + .idea/encodings.xml | 5 + .idea/misc.xml | 5 + .idea/modules.xml | 9 + .idea/scopes/scope_settings.xml | 5 + .idea/trustie2.iml | 65 ++ .idea/vcs.xml | 7 + .idea/workspace.xml | 989 +++++++++++++++++++++ Gemfile.lock | 4 - app/helpers/application_helper.rb | 4 +- app/models/softapplication.rb | 3 +- app/views/layouts/_base_header.html.erb | 4 + app/views/layouts/base_newcontest.html.erb | 1 - app/views/softapplications/show.html.erb | 2 +- public/images/android_0.jpg | Bin 0 -> 1658 bytes 17 files changed, 1110 insertions(+), 9 deletions(-) create mode 100644 .idea/.generators create mode 100644 .idea/.name create mode 100644 .idea/.rakeTasks create mode 100644 .idea/encodings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/scopes/scope_settings.xml create mode 100644 .idea/trustie2.iml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 public/images/android_0.jpg diff --git a/.idea/.generators b/.idea/.generators new file mode 100644 index 000000000..48c69bb77 --- /dev/null +++ b/.idea/.generators @@ -0,0 +1,8 @@ + + diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 000000000..2327e6ef0 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +trustie2 \ No newline at end of file diff --git a/.idea/.rakeTasks b/.idea/.rakeTasks new file mode 100644 index 000000000..212558e83 --- /dev/null +++ b/.idea/.rakeTasks @@ -0,0 +1,7 @@ + + diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 000000000..e206d70d8 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..12817166a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..eb86c781f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100644 index 000000000..922003b84 --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/trustie2.iml b/.idea/trustie2.iml new file mode 100644 index 000000000..897cad7ea --- /dev/null +++ b/.idea/trustie2.iml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..c80f2198b --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 000000000..2bb1461a3 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,989 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CSS + + + Code style issuesJavaScript + + + Control flow issuesJavaScript + + + JavaScript + + + JavaScript function metricsJavaScript + + + JavaScript validity issuesJavaScript + + + Potentially confusing code constructsJavaScript + + + Ruby + + + SQL + + + + + CoffeeScript + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1397784941950 + 1397784941950 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Gemfile.lock b/Gemfile.lock index 42cb62272..d60847b17 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,9 +79,6 @@ GEM rdoc (3.12.2) json (~> 1.4) ruby-openid (2.1.8) - seems_rateable (1.0.13) - jquery-rails - rails sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -112,4 +109,3 @@ DEPENDENCIES rails (= 3.2.13) rdoc (>= 2.4.2) ruby-openid (~> 2.1.4) - seems_rateable diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index cae7b8b1e..1d639726f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1567,7 +1567,8 @@ module ApplicationHelper home_link = link_to l(:field_homepage), {:controller => 'welcome', :action => 'index'} main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.course_domain} main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain} - + main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain} + course_all_course_link = link_to l(:label_course_all), {:controller => 'projects', :action => 'course', :project_type => 1, :host => Setting.course_domain} course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain} courses_link = link_to l(:label_course_practice), {:controller => 'projects', :action => 'course', :project_type => 1, :host => Setting.course_domain} @@ -1586,6 +1587,7 @@ module ApplicationHelper nav_list.push(main_project_link) if @nav_dispaly_main_project_label nav_list.push(main_course_link) if @nav_dispaly_main_course_label + nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label nav_list.push(courses_link) if @nav_dispaly_course_label nav_list.push(projects_link) if @nav_dispaly_project_label diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb index 603279fbd..71caf059c 100644 --- a/app/models/softapplication.rb +++ b/app/models/softapplication.rb @@ -1,8 +1,7 @@ class Softapplication < ActiveRecord::Base attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers acts_as_attachable - seems_rateable :allow_update => true, :dimensions => :quality - seems_rateable_rater + has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :contesting_softapplications, :dependent => :destroy belongs_to :user diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index 4c3884a05..d340ea9e9 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -13,6 +13,10 @@ @nav_dispaly_home_path_label = 1 @nav_dispaly_main_course_label = 1 @nav_dispaly_main_project_label = 1 + @nav_dispaly_main_contest_label = 1 + elsif (realUrl.match(/contest\.trustie\.net\/*/)) + @nav_dispaly_contest_label = 1 + @nav_dispaly_store_all_label = 1 else @nav_dispaly_project_all_label = 1 @nav_dispaly_course_all_label = 1 diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index c0e23bf21..190209ae4 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -10,7 +10,6 @@ <%= favicon %> <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %> <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> - <%= seems_rateable_stylesheet %> <%= javascript_heads %> <%= heads_for_theme %> <%= call_hook :view_layouts_base_html_head %> diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index fcd746776..c2cea19b5 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -35,7 +35,7 @@ - + diff --git a/public/images/android_0.jpg b/public/images/android_0.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6aadab331ac0ffc74177b2212880d4d221fb0894 GIT binary patch literal 1658 zcmbV}c{tR09LIlinK916B<$|U5k>BCgs2?3b3~LSITJ-q4H_c3_Gx+$GAe4_iglMG zGmJr*EFBoRORizYeKtF@+tWVJ{=pgXWhrR;gvaqC z_ek!Ql2+WWqCC@5^7 zCZE_*NBFrgaXGD6gv7Db$CVU*d2J^a+9$jhxko`~T#?N~`;+Y7fyMnVvhQGjb1?ux z2#C8p2nsL(c6Z8^*5WswiBMW@lM-qb@6bv#+MAmnm}ivxMWby1>tZRzhMPrF`tVwx zW26ntWDC_xlrq5qQYy_Wf*mb`CuH=;PcIf61;>Urp5)uK_#FfR#sc)w?41Cr`a#Ob zfn}E|tLaUT_<|_opBRT4*9_R$<_CnB&N`Eem}Hgm9Car7YWk(mgraRe+b>-`wh=?? zJ2}7LHXGdfG1ZIh_-M@?)wi|9^8tOIWQRVwce|4qE{4_%vU{8~D0dY!-UyrSe8Pw~ z*_)cM((&oJTPbH_*tj_p@DVwD!XyoY^vU}9LjiG)Dw(X+MNoM<8{J*tb!b^A|E92M z7fma8$zEhKWhIP=owd*R^9u?N4Wb>Szp_&vp6M@(#8ML5kA$3wVNGvOq$pQRSN9`X zi;S2xyQ+=Ev1T7H!J!!s`{vS7O7X0u9-nEJk3{O_YYB|YpI@G8L-i=h7qjb`eq${F zetgH65LQknz*ZmS;IPEl7{d9YVb3O;OR)BL8a1MwUvCIiS-J}7*pgL~Jc!xbz8f;s zNaC~eK^%Y|yF$X%tcM|tu*LS+9K4!*-Sf;2UnOQ`hfZagjtp5$KAcD#2@SqCUM*{9nM+~e3*Q@P4uE9r+>rjsVEHL64d*bQt8|4>L|T+P&Z6``RQiTA;UpjjhWlonzRoY!P#Dp?z8m{xmH4qhwesWLXVl6s{FP zcbgC)6C}q>2K`x!Nf?Uj`nsERJPPmZp1op|<9$clOO6~+t@1-kTMt57JYyJx{Wxb* z*VEP_h`;OnRt+cQv{wh$XoZ#NT^O|`McKHkErgtFINj~+fNpYnk)rFr+g+;Fd!meG zq%=-ftw60la8n&sbs8>EsaNt(8#ZrWAT_5OT;9Oi4bMF>4ow-WiD5XjGCHVHmyqHW z0~h+|XS}x(VhMhJB@Jf&zI6?m==z6L>!piC3!l_ZGD;>xWffBMhOIYWnYU3!+oDzB z)I|sOH^&ssMixE{z8XjSx<)%=b!Z{`N2$z{b*^l28Rfu9P^_$m{BGt7!O)h)e3|hK zpKjj3D!+X_FR1=QdTXe6+*GiYU(ASEr!W1UHUC*yz*rhWIZsdo9ZmKU{wlkp`@YF= z!qC%!s^>w?a+CC6?)K-D8PlnbX6sBpEMniIu&%&12bFl?dFqp!hh@|U>+KUKqEjbA zEWOwk4PP-Ns}*D2tts{SU9o`rDF4j8lXs+YJJSMhS@)sc^JxO&<`O62oWVZ;5SHHB literal 0 HcmV?d00001 From 651710929abdcafa0ed74c7bb75ce2ca775aa054 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 18 Apr 2014 17:04:29 +0800 Subject: [PATCH 42/43] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=B9=E5=87=BA?= =?UTF-8?q?=E6=96=B0=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/contests/show_softapplication.html.erb | 2 +- app/views/softapplications/new.html.erb | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/contests/show_softapplication.html.erb b/app/views/contests/show_softapplication.html.erb index f320393ea..14c907d82 100644 --- a/app/views/contests/show_softapplication.html.erb +++ b/app/views/contests/show_softapplication.html.erb @@ -68,7 +68,7 @@ diff --git a/app/views/softapplications/new.html.erb b/app/views/softapplications/new.html.erb index d7ea95799..d5ff2c9c2 100644 --- a/app/views/softapplications/new.html.erb +++ b/app/views/softapplications/new.html.erb @@ -1,6 +1,5 @@ -

    <%= l(:label_release_softapplication)%>

    From 25bbf791f9f4a18864df279e3b920931a93bde36 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 18 Apr 2014 17:53:22 +0800 Subject: [PATCH 43/43] dsfsd --- app/views/softapplications/show.html.erb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index c2cea19b5..047ecf8dc 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -28,16 +28,15 @@
    - + - - -
    <%= image_tag(url_to_avatar(@project), :class => 'avatar2') %>
    <%= @project.name %> diff --git a/lib/redmine.rb b/lib/redmine.rb index 88d6f73ee..8ecf91cc1 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -279,7 +279,7 @@ end ###new add by linchun Redmine::MenuManager.map :contest_menu do |menu| menu.push :respond, :show_contest_contest_path, :caption => :label_user_response - menu.push :project, :show_project_contest_path, :caption => :label_contest_project + # menu.push :project, :show_project_contest_path, :caption => :label_contest_project menu.push :application, :show_softapplication_contest_path, :caption => :label_contest_application # menu.push :result, { :controller => 'bids', :action => 'show_results' }, # :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p } From 8f6d9fc6a58a077eb333bea7a37f8a00628813c6 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Fri, 18 Apr 2014 10:46:29 +0800 Subject: [PATCH 39/43] 0418 --- Gemfile | 1 + Gemfile.lock | 4 ++++ app/helpers/application_helper.rb | 4 ++++ app/models/softapplication.rb | 2 ++ app/views/layouts/base_newcontest.html.erb | 5 +++-- app/views/softapplications/show.html.erb | 4 ++++ config/application.rb | 1 + public/javascripts/application.js | 1 + 8 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index dd19b4435..dc4db9c84 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source 'https://rubygems.org' +gem "seems_rateable" gem "rails", "3.2.13" gem "jquery-rails", "~> 2.0.2" gem "i18n", "~> 0.6.0" diff --git a/Gemfile.lock b/Gemfile.lock index d60847b17..42cb62272 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,6 +79,9 @@ GEM rdoc (3.12.2) json (~> 1.4) ruby-openid (2.1.8) + seems_rateable (1.0.13) + jquery-rails + rails sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -109,3 +112,4 @@ DEPENDENCIES rails (= 3.2.13) rdoc (>= 2.4.2) ruby-openid (~> 2.1.4) + seems_rateable diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9b3a672c3..dd900bf37 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1601,5 +1601,9 @@ module ApplicationHelper end content_tag :ul, content_li.html_safe end + + def current_user + User.current + end end diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb index fa90881bf..603279fbd 100644 --- a/app/models/softapplication.rb +++ b/app/models/softapplication.rb @@ -1,6 +1,8 @@ class Softapplication < ActiveRecord::Base attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers acts_as_attachable + seems_rateable :allow_update => true, :dimensions => :quality + seems_rateable_rater has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :contesting_softapplications, :dependent => :destroy belongs_to :user diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index f8c7056b6..c0e23bf21 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -8,8 +8,9 @@ <%= csrf_meta_tag %> <%= favicon %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %> <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= seems_rateable_stylesheet %> <%= javascript_heads %> <%= heads_for_theme %> <%= call_hook :view_layouts_base_html_head %> @@ -148,7 +149,7 @@
    - +
    + + + +
    <%= render :partial => 'tags/tag', :locals => {:obj => @contest, :object_flag => "7"}%> diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index 0e2ee738d..fcd746776 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -34,6 +34,10 @@ 开发人员:<%= @softapplication.application_developers %>
    rate: <%=rating_for @softapplication, :dimension => :qulity %>
    <%= l(:field_occupation) %>:<%= @user.user_extensions.school.name %><%= l(:field_occupation) %>: + <% unless @user.user_extensions.school.nil? %> + <%= @user.user_extensions.school.name %> + <% end %> +
    开发人员:<%= @softapplication.application_developers %>
    rate: <%=rating_for @softapplication, :dimension => :qulity %>

    - <%= link_to '发布应用', new_softapplication_path(:target=>'_blank'), :target=>'_blank' %> + <%= link_to '发布应用', new_softapplication_path(:target=>'_blank'), :target=>'_blank' %>

    系统支持:<%= @softapplication.android_min_version_available %>
    应用下载: + + 应用下载: <% options = {:author => true, :deletable => @softapplication.user.eql?(User.current) } %> <%= render :partial => 'attachments/app_link', :locals => {:attachments => @app_items, :options => options} %> 开发人员:<%= @softapplication.application_developers %>
    @@ -82,5 +81,5 @@
    -<%#= link_to '返回竞赛页面', show_softapplication_contest_path(contest)) %> +<%#= link_to '返回竞赛页面', show_softapplication_contest_path(@softapplication.contest) %>