From cf527d9087ce9d29318206d328847a9cee1ad1ba Mon Sep 17 00:00:00 2001 From: Yang Zhao Date: Mon, 2 Jan 2017 14:51:27 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8A=9F=E8=83=BD=E5=BC=80?= =?UTF-8?q?=E5=8F=91=E5=AE=8C=E6=88=90=EF=BC=9Bv1.0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BA=A7=E7=94=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/missions_controller.rb | 46 +-- config/routes.rb | 4 +- public/pages/inform.html | 4 +- public/pages/task.html | 390 ++++++++++++++++--------- 4 files changed, 286 insertions(+), 158 deletions(-) diff --git a/app/controllers/missions_controller.rb b/app/controllers/missions_controller.rb index ac9ca3d..5a83388 100644 --- a/app/controllers/missions_controller.rb +++ b/app/controllers/missions_controller.rb @@ -1,7 +1,13 @@ class MissionsController < ApplicationController before_action :authenticate - + skip_before_action :verify_authenticity_token, :only => [ + :create, + :getlist, + :detail, + :update, + :commentPublish + ] #======================================>获取当前项目某状态的任务列表 def getlist @@ -82,24 +88,24 @@ class MissionsController < ApplicationController #Todo params_mission = {name: params[:name],project_id: params[:project_id],content: params[:content],deadline: params[:deadline],priority: params[:priority],status: params[:status]} mission = Mission.new(params_mission) - mission.save - #puts mission.inspect - #puts mission.id - usernames = params[:users] - usernames.each do |name| - - user_enties = User.find_by(name: name) + if mission.save + render :json => {:code => 0} + else + render json: mission.errors, status: :unprocessable_entity + end + userids = params[:users] + userids.each do |id| + user_enties = User.find_by(id: id) #puts user_enties.inspect params_mu = {mission_id: mission.id,user_id: user_enties.id} missions_user = Missions_user.new(params_mu) missions_user.save - content = "有新任务:"+mission.name + content = "有新任务 "+mission.name+"" params_note = {content: content,user_id: user_enties.id,category: 3,project_id: mission.project_id} note = Note.new(params_note) note.save end - render :json => {:code => 0} end #======================================>修改任务信息 @@ -110,18 +116,18 @@ class MissionsController < ApplicationController id = params[:id] #now = Datetime.now mission = Mission.find_by(id: id) - params_mission = {name: params[:name],content: params[:content],deadline: params[:deadline],priority: params[:priority],status: params[:status]} + params_mission = {name: params[:name],content: params[:content],deadline: params[:deadline],priority: params[:priority]} #puts params_mission mission.update(params_mission) mission.save Missions_user.delete_all(["mission_id = ?",id]) - usernames = params[:users] - usernames.each do |name| - user_enties = User.find_by(name: name) + userids = params[:users] + userids.each do |name| + user_enties = User.find_by(id: id) params = {mission_id: id,user_id: user_enties.id} missions_user = Missions_user.new(params) missions_user.save - content = mission.name + "——任务信息发生了变化" + content = ""+mission.name + " 任务信息发生了变化" params_note = {content: content,user_id: user_enties.id,category: 3,project_id: mission.project_id} note = Note.new(params_note) @@ -139,10 +145,10 @@ class MissionsController < ApplicationController user_id = session[:user_id] params = {content: content, mission_id: mission_id, user_id: user_id} comment = Comment.new(params) - comment.save - render :json => {:code => 0} + if comment.save + render :json => {:code => 0} + else + render json: mission.errors, status: :unprocessable_entity + end end - - - end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 39c3e46..8062b06 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -75,10 +75,10 @@ Rails.application.routes.draw do get 'notes/list' => 'notes#getNotesList' - get 'missions/project/status' => 'missions#getlist' + get 'missions' => 'missions#getlist' get 'missions/detail' => 'missions#detail' post 'missions/comments' => 'missions#commentPublish' - post 'missions/create' => 'missions#create' + post 'missions' => 'missions#create' patch 'missions/detail' => 'missions#update' end diff --git a/public/pages/inform.html b/public/pages/inform.html index b17e884..6678010 100644 --- a/public/pages/inform.html +++ b/public/pages/inform.html @@ -81,9 +81,9 @@ for(var j=0;j\ + \
\ - '+informs[j].time.substring(0,5)+'\ + '+informs[j].time.substring(0,5)+'\

'+informs[j].content+'

\
\ '; diff --git a/public/pages/task.html b/public/pages/task.html index 4d63ace..c1dc04b 100644 --- a/public/pages/task.html +++ b/public/pages/task.html @@ -81,7 +81,7 @@

未开始

- +
@@ -103,7 +103,7 @@

进行中

- +
@@ -119,7 +119,7 @@

已完成

- +
@@ -135,7 +135,7 @@

已测试

- +
@@ -157,6 +157,7 @@ + @@ -171,21 +172,19 @@
任务名称 -

- 前端原型开发 +


任务内容 -

开发出项目的前端原型。

+


- 截止时间 2016年12月8日 + 截止时间
优先级 -
紧急
+

参与人员 -

- 杨诏 陈翊 +

@@ -200,53 +199,17 @@
-
- - - -
@@ -256,7 +219,7 @@
@@ -266,15 +229,20 @@ + + @@ -377,7 +337,8 @@
Copyright © 2016 Ambition Inc.. All rights reserved.
- + + @@ -390,6 +351,152 @@