From d021dbb52292eaac94dbf90dee95a762e8dbc696 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 16 Mar 2017 17:32:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=20=E4=B8=8A=E7=A7=BB=20?= =?UTF-8?q?=E4=B8=8B=E7=A7=BB=E5=8A=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/challenges_controller.rb | 21 ++++++- app/models/challenge.rb | 8 +++ app/views/challenges/_content_list.html.erb | 68 +++++++++++---------- app/views/challenges/edit.html.erb | 35 +++++++++++ app/views/challenges/index.html.erb | 40 +----------- app/views/challenges/index_down.js.erb | 1 + app/views/challenges/index_up.js.erb | 0 config/routes.rb | 2 + 8 files changed, 106 insertions(+), 69 deletions(-) create mode 100644 app/views/challenges/edit.html.erb create mode 100644 app/views/challenges/index_down.js.erb create mode 100644 app/views/challenges/index_up.js.erb diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index bca595e73..6084f3511 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -2,7 +2,7 @@ class ChallengesController < ApplicationController layout "base_shixun" before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build] - before_filter :find_challenge, :only => [:show, :update, :challenge_build] + before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down] before_filter :authorize_tpi, :only => [:new, :create] before_filter :build_challege_from_params, :only => [:new, :create] before_filter :tpi_manager_allowed, :only => [:challenge_build] @@ -71,6 +71,25 @@ class ChallengesController < ApplicationController end end + def edit + + end + + def update + + end + + def index_down + @challenges = @shixun.challenges + position = @challenge.position + @challenge.update_attribute(:position, (position + 1)) + + end + + def index_up + @challenges = @shixun.challenges + end + # build job 只负责发送请求 def challenge_build gitUrl = git_repository_url(@shixun, "Shixun") diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 4e2efa526..4b14feb29 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -9,4 +9,12 @@ class Challenge < ActiveRecord::Base validates_presence_of :task_pass validates_length_of :subject, :maximum => 255 + def next_challenge + + end + + def last_challenge + + end + end diff --git a/app/views/challenges/_content_list.html.erb b/app/views/challenges/_content_list.html.erb index 3f76ae90a..0ac56e92d 100644 --- a/app/views/challenges/_content_list.html.erb +++ b/app/views/challenges/_content_list.html.erb @@ -1,32 +1,38 @@ -<% challenges.each do |challenge| -%> - - - <% if challenge.status == 1 %> -
- <% else %> -
- <% end %> -
-
- - step<%= challenge.position %> - <%= challenge.subject.to_s %> - - <% if challenge.status == 1 %> - 已解决 - <% else %> - 正在解决中 - <% end %> -
-
-
-

<%= format_time(challenge.created_at) %>发布

-

<%= format_time(challenge.updated_at) %>更新

-
+
+
+

全部任务

<%= @challenges.count %> + 新建阶段 +
+
+ <% @challenges.each_with_index do |challenge, index| -%> +
+

第<%= challenge.position %>关<%= challenge.subject %>

+ +
+

+ 正在挑战:129 + 完成挑战:1.6万 + 最佳表现:98分 + 测评次数:3次 + 平均表现:80分 +

- - - - - -<% end %> \ No newline at end of file + + <% end %> +
+
\ No newline at end of file diff --git a/app/views/challenges/edit.html.erb b/app/views/challenges/edit.html.erb new file mode 100644 index 000000000..12b581694 --- /dev/null +++ b/app/views/challenges/edit.html.erb @@ -0,0 +1,35 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> +<% end %> + +
+
+
+

编辑阶段

+
+
+
    + <%= labelled_form_for @challenge, :url => shixun_challenges_path(@shixun) do |f| %> + <%= render :partial => "form", :locals => {:f => f} %> + <% end %> +
+
+ +
+
+ +<% if false %> + +
+
+ <%#= call_hook(:view_issues_new_top, {:training_task => @training_task}) %> + <%= labelled_form_for @challenge, :url => shixun_challenges_path(@shixun) do |f| %> + <%= error_messages_for 'training_task' %> +
+ <%= render :partial => 'form', :locals => {:f => f} %> +
+ <% end %> +
+
+<% end %> + diff --git a/app/views/challenges/index.html.erb b/app/views/challenges/index.html.erb index d013f4452..0a2ac688a 100644 --- a/app/views/challenges/index.html.erb +++ b/app/views/challenges/index.html.erb @@ -14,42 +14,8 @@
-
-
-

全部任务

<%= @challenges.count %> - 新建阶段 -
-
- <% @challenges.each_with_index do |challenge, index| -%> -
-

第<%= challenge.position %>关<%= challenge.subject %>

- -
-

- 正在挑战:129 - 完成挑战:1.6万 - 最佳表现:98分 - 测评次数:3次 - 平均表现:80分 -

-
- - <% end %> -
+
+ <%= render :partial => "content_list" %>
+
\ No newline at end of file diff --git a/app/views/challenges/index_down.js.erb b/app/views/challenges/index_down.js.erb new file mode 100644 index 000000000..88841bc2f --- /dev/null +++ b/app/views/challenges/index_down.js.erb @@ -0,0 +1 @@ +$("#challenge_list").html('<%= escape_javascript( render :partial => 'resource_search_form', :locals => {:user => @user, :type => @type} ) %>'); \ No newline at end of file diff --git a/app/views/challenges/index_up.js.erb b/app/views/challenges/index_up.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/config/routes.rb b/config/routes.rb index afcfeb0a5..07482335e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -45,6 +45,8 @@ RedmineApp::Application.routes.draw do member do match 'challenge_build', :via => [:get, :post] match 'game_build_result', :via => [:get, :post] + get 'index_up' + get 'index_down' end end