diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 7ceb575f..7741333a 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -4,7 +4,8 @@ class ContestsController < ApplicationController menu_item :respond menu_item :project, :only => :show_project menu_item :application, :only => :show_softapplication - before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward, + menu_item :attendingcontest, :only => :show_attendingcontest + before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :show_attendingcontest, :create,:destroy,:more,:back,:add,:add_softapplication,: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 @@ -252,6 +253,7 @@ class ContestsController < ApplicationController ############ ##显示参赛的应用 def show_softapplication + # @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) # @option = [] @@ -288,6 +290,66 @@ class ContestsController < ApplicationController end end + + ###我要参赛 + def show_attendingcontest +##取出参赛项目 + @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| + 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 +##取出参赛应用 + @softapplication = Softapplication.all + @contesting_softapplication = @contest.contesting_softapplications.reverse + @contesting_softapplication = paginateHelper @contesting_softapplication, 10 + + +##引用base_newcontest整体样式 + @contest = Contest.find_by_id(params[:id]) + respond_to do |format| + format.html { + render :layout => 'base_newcontest' + } + format.api + end + end + + ###end ###添加已创建的参赛项目 def add project = Project.find(params[:contest]) @@ -500,9 +562,9 @@ class ContestsController < ApplicationController @contest = Contest.find(params[:id]) @user = @contest.author end - rescue + rescue render_404 - end + end end diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index 3aba819e..9ede5248 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -106,11 +106,13 @@ class SoftapplicationsController < ApplicationController @softapplication.save_attachments(params[:attachments]) respond_to do |format| if @softapplication.save + format.js format.html { redirect_to @softapplication, notice: 'Softapplication was successfully created.' } - format.json { render json: @softapplication, status: :created, location: @softapplication } + # format.json { render json: @softapplication, status: :created, location: @softapplication } else + format.js { render status: 406 } format.html { render action: "new" } - format.json { render json: @softapplication.errors, status: :unprocessable_entity } + # format.json { render json: @softapplication.errors, status: :unprocessable_entity } end end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f6855505..dff26ce1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -737,8 +737,9 @@ class UsersController < ApplicationController User.current.admin? ? 'base_admin' : default_base end + # 必填自己的工作单位,其实就是学校 def auth_user_extension - if @user.user_extensions.school.nil? + if @user == User.current && @user.user_extensions.school.nil? flash[:error] = l(:error_complete_occupation) redirect_to my_account_path end diff --git a/app/views/contests/_contest_list.html.erb b/app/views/contests/_contest_list.html.erb index 6ffac831..8b5e3497 100644 --- a/app/views/contests/_contest_list.html.erb +++ b/app/views/contests/_contest_list.html.erb @@ -18,9 +18,14 @@ - <%= l(:label_contest_project, :count => contest.contesting_projects.count) %>(<%= link_to(contest.contesting_projects.count, show_project_contest_path(contest), :target => "_blank") %>) - <%= l(:label_contest_softapplication, :count => contest.contesting_softapplications.count) %>(<%= link_to(contest.contesting_softapplications.count, show_softapplication_contest_path(contest), :target => "_blank") %>) - + + + <% if contest.id == 2 or contest.id == 3 or contest.id == 6 %> + <%= l(:label_contest_work, :count => contest.contesting_projects.count) %>(<%= link_to(contest.projects.where('is_public=1').count, show_attendingcontest_contest_path(contest), :target => "_blank") %>) + <% else %> + <%= l(:label_contest_work, :count => contest.contesting_softapplications.count) %>(<%= link_to(contest.contesting_softapplications.count, show_attendingcontest_contest_path(contest), :target => "_blank") %>) + <% end %> diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb new file mode 100644 index 00000000..8a00f12a --- /dev/null +++ b/app/views/contests/show_attendingcontest.html.erb @@ -0,0 +1,246 @@ + + + + + +
+ 温馨提示:如果您希望在我们平台托管参赛数据和代码,请按下面参赛步骤参赛! +
+<% if User.current.logged? %> + +
+
+ 参赛步骤: +
+
+ 步骤1: + <%#= link_to '新建参赛作品', new_softapplication_path(:target=>'_blank'), :target=>'_blank' %> + <%= link_to '新建参赛作品', "javascript:void(0);", onclick: "$('#put-project-form').toggle();" %> + (先点击“新建参赛作品”,然后刷新页面,再继续步骤2。) +
+
+ 步骤2: + <%= link_to '关联参赛作品', "javascript:void(0);", onclick: "$('#put-bid-form').toggle();" %> +
+
+ + + + + + + +<% end %> + +
+ + + +<% if @contest.id == 2 or @contest.id == 3 or @contest.id == 6 %> + +<% @contesting_project.sort.reverse.each do |c_project|%> +<% if c_project.project %> +
+
+ + 参赛作品: + <%= link_to(c_project.project.name, project_path(c_project.project), :target => '_blank') %> +
+
+
+ + 简介: + <%= c_project.project.description.truncate(90, omission: '...') %> +
+
+
+ + 发布时间: + <%= format_time c_project.created_at%> + + +
+
+<% end %> +
+<% end %> +<% else %> +<% @contesting_softapplication.each do |c_softapplication|%> +<% if c_softapplication.softapplication %> +
+
+ + 参赛作品: + <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication), :target => '_blank') %> +
+
+
+ + 简介: + <%= c_softapplication.softapplication.description.truncate(90, omission: '...') %> +
+
+
+ + 发布时间: + <%= format_time c_softapplication.created_at %> + + +
+
+<% end %> +
+<% end %> +<% end %> + + + diff --git a/app/views/layouts/_base_softapplication_index_top_content.html.erb b/app/views/layouts/_base_softapplication_index_top_content.html.erb index 93b177b9..d029d27e 100644 --- a/app/views/layouts/_base_softapplication_index_top_content.html.erb +++ b/app/views/layouts/_base_softapplication_index_top_content.html.erb @@ -15,7 +15,7 @@ <%=link_to request.host()+"/softapplications", :controller=>'softapplications', :action=>'index' %> <%=link_to l(:field_homepage), home_path %> > - <%=link_to l(:label_contest_softapplication), :controller=>'softapplications', :action=>'index' %> + <%=link_to l(:label_contest_work), :controller=>'softapplications', :action=>'index' %> diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index 07654edd..e621f2f8 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -98,19 +98,26 @@ + --> + - <%=link_to "#{@contest.projects.where('is_public=1').count}", :controller => 'contests', :action => 'show_project' %> - - - <%=link_to "#{@contest.contesting_softapplications.count}", :controller => 'contests', :action => 'show_softapplication' %> + + <%=link_to "#{@contest.watcher_users.count}", :controller => 'contests', :action => 'show_project' %> + + + + <% if @contest.id == 2 or @contest.id == 3 or @contest.id == 6 %> + <%=link_to "#{@contest.projects.where('is_public=1').count}" %> + <% else %> + <%=link_to "#{@contest.contesting_softapplications.count}", :controller => 'contests', :action => 'show_attendingcontest' %> + <% end %> - <%= l(:label_contest_project) %> - <%= l(:label_contest_application) %> + <%= l(:label_contest_watchers) %> + <%= l(:label_contest_work) %> @@ -178,9 +185,9 @@
<%= l(:label_x_followers, :count => @contest.watcher_users.count) %> - <% if show_more_fans?(@contest) %> +
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 7158037e..f9b4e9ac 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -218,39 +218,39 @@ <% unless @user.user_extensions.identity == 2 %> -

- <%= l(:label_identity) %> - -

- - - <% end %> - - - <% else %> - +

+ <%= l(:label_identity) %> - + + + <% end %> + + + <% else %> + + + +

<% end %> diff --git a/app/views/softapplications/create.js.erb b/app/views/softapplications/create.js.erb new file mode 100644 index 00000000..7f4ac228 --- /dev/null +++ b/app/views/softapplications/create.js.erb @@ -0,0 +1 @@ +alert('新建参赛作品成功!'); diff --git a/app/views/softapplications/index.html.erb b/app/views/softapplications/index.html.erb index 30a57b1a..841a8a20 100644 --- a/app/views/softapplications/index.html.erb +++ b/app/views/softapplications/index.html.erb @@ -14,10 +14,10 @@
<%= image_tag('/images/app1.png')%>
<%= softapplication.description.truncate(95, omission: '...') %>
-
+
<%contest = softapplication.contests.first%> -

所属竞赛:<%= contest ? link_to(contest.name.truncate(10, omission: '...'), show_softapplication_contest_path(contest), title: contest.name.to_s ) : '尚未加入竞赛'%>

-

所属类别:<%= softapplication.app_type_name.truncate(5, omission: '...') %>

+

所属竞赛:<%= contest ? link_to(contest.name.truncate(14, omission: '...'), show_attendingcontest_contest_path(contest), title: contest.name.to_s ) : '尚未加入竞赛'%>

+

所属类别:<%= softapplication.app_type_name.truncate(10, omission: '...') %>

系统支持:<%= softapplication.android_min_version_available %>

@@ -36,4 +36,4 @@ -<% html_title l(:label_softapplication_list)%> \ No newline at end of file +<% html_title l(:label_contest_work_list)%> \ No newline at end of file diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index c2f260e6..4bd6871a 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -27,7 +27,7 @@
<% contest = @softapplication.contests.first %> - + @@ -35,7 +35,7 @@
所属类别:<%= @softapplication.app_type_name %>所属竞赛:<%= contest ? link_to(contest.name, show_softapplication_contest_path(contest)) : '尚未加入竞赛'%>所属竞赛:<%= contest ? link_to(contest.name, show_attendingcontest_contest_path(contest)) : '尚未加入竞赛'%>
发布人员:<%= @softapplication.user.name %>
- 应用下载: + 作品下载: <% options = {:author => true, :deletable => @softapplication.user.eql?(User.current) } %><%= render :partial => 'attachments/app_link', :locals => {:attachments => @app_items, :options => options} %> @@ -56,13 +56,13 @@
-
应用简介:
+
作品简介:
<%= @softapplication.description %>
-
应用得分:
+
作品得分:
@@ -93,7 +93,7 @@
-
软件截图:
+
作品截图:
<% @image_results.take(4).each do |attachment| %> <%= link_to_attachment_img attachment, :class => "soft-application", :download => "true" %> @@ -116,7 +116,7 @@ <% end %>
-->
-
软件评论:
+
作品评论:
评分: <%= rating_for @softapplication, dimension: :quality, class: 'rateable div_inline' %>(您可以重新打分,打分结果以最后一次打分为主!)
diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 3b645c61..e32d375d 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -152,7 +152,11 @@
<%= link_to(contest.name, show_contest_contest_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", :target => "_blank") %> - (<%= link_to("含#{contest.contesting_softapplications.count}个app", show_softapplication_contest_path(contest), :target => "_blank") %>) + <% if contest.id == 2 or contest.id == 3 or contest.id == 6 %> + (<%= link_to("含#{contest.projects.where('is_public=1').count}个app", show_attendingcontest_contest_path(contest), :target => "_blank") %>) + <% else %> + (<%= link_to("含#{contest.contesting_softapplications.count}个app", show_attendingcontest_contest_path(contest), :target => "_blank") %>) + <% end %>
@@ -201,7 +205,7 @@
-

最新参赛应用

+

最新参赛作品

<%= link_to "更多>>", {:controller => 'softapplications', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %>
<% if Softapplication.count > 0%> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 1fac59dd..774d1fbf 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1842,8 +1842,9 @@ zh: label_contest_project: 参赛项目 label_contest_softapplication: 参赛应用 label_contest_response: 用户反馈 - label_contest_watchers: 关注人员 + label_contest_watchers: 关注人数 label_contest_application: 参赛应用 + label_contest_work: 参赛作品 button_contesting_as_project: 我要参赛(新建项目) button_contesting_as_application: 我要参赛(发布应用) label_release_softapplication: 发布应用 @@ -1872,6 +1873,8 @@ zh: label_edit_softapplication: 修改应用 label_contest_delete: 删除竞赛 label_softapplication_list: 应用列表 + label_contest_work_list: 参赛作品列表 + label_attending_contest: 我要参赛 label_coursefile_sharingarea: 课程资源共享区 label_sort_by_activity: 按动态数排序 diff --git a/config/routes.rb b/config/routes.rb index e0d1f6fb..a64acb2c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -67,15 +67,16 @@ RedmineApp::Application.routes.draw do end member do match 'add_softapplication' - match 'update_contest' , via: [:put] - match 'show_contest' , via: :get - match 'show_project' , via: :get - 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] + match 'update_contest' , via: [:put] + match 'show_contest' , via: :get + match 'show_project' , via: :get + match 'show_softapplication' , via: :get + match 'show_attendingcontest' , 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 end @@ -126,7 +127,6 @@ RedmineApp::Application.routes.draw do match 'account/register', :to => 'account#register', :via => [:get, :post], :as => 'register' match 'account/lost_password', :to => 'account#lost_password', :via => [:get, :post], :as => 'lost_password' match 'account/activate', :to => 'account#activate', :via => :get - match 'account/valid_ajax', :to => 'account#valid_ajax', :via => :get match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news', :via => [:get, :post, :put] match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put] diff --git a/lib/redmine.rb b/lib/redmine.rb index 2c935074..d22feb9f 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -279,8 +279,10 @@ 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_softapplication_contest_path, :caption => :label_contest_application + #menu.push :project, :show_project_contest_path, :caption => :label_contest_project + #menu.push :application, :show_softapplication_contest_path, :caption => :label_contest_application + menu.push :attendingcontest, {:controller => 'contests', :action => 'show_attendingcontest'}, :caption => :label_attending_contest + # menu.push :attendingcontest, :show_attendingcontest_contest_path, :caption => :label_attendin,g_contest # menu.push :result, { :controller => 'bids', :action => 'show_results' }, # :caption => :label_bidding_results,:if => Proc.new{ |p| User.current.id == p } end