修改作业提交流程
This commit is contained in:
parent
4de089250f
commit
c7b19d8f2e
|
@ -8,22 +8,50 @@ class HomeworkAttachController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@homework = HomeworkAttach.new(params[:homework])
|
||||
def add_users users
|
||||
if users != nil && users.count > 0
|
||||
users.each do |user|
|
||||
@homework.homework_users.build(:user_id => user.id)
|
||||
@homework.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
if @homework.save
|
||||
format.html { redirect_to @homework, notice: 'Post was successfully created.' }
|
||||
format.json { render json: @homework, status: :created, location: @homework }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @homework.errors, status: :unprocessable_entity }
|
||||
def create
|
||||
if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)
|
||||
user_id = params[:user_id]
|
||||
bid_id = params[:bid_id]
|
||||
sta = 0
|
||||
name = params[:new_form][:name]
|
||||
description = params[:new_form][:description]
|
||||
options = {
|
||||
:user_id => user_id,
|
||||
:state => sta,
|
||||
:name => name,
|
||||
:description => description,
|
||||
:bid_id => bid_id
|
||||
}
|
||||
|
||||
@homework = HomeworkAttach.new(options)
|
||||
@homework.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@homework)
|
||||
|
||||
@homework.save
|
||||
respond_to do |format|
|
||||
if @homework.save
|
||||
format.html { redirect_to @homework, notice: 'Post was successfully created.' }
|
||||
format.json { render json: @homework, status: :created, location: @homework }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @homework.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@homework = HomeworkAttach.new
|
||||
@bid = Bid.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
|
@ -49,7 +77,12 @@ class HomeworkAttachController < ApplicationController
|
|||
end
|
||||
|
||||
def destroy
|
||||
|
||||
@homework = HomeworkAttach.find(params([:id]))
|
||||
@homework.destroy
|
||||
respond_to do |format|
|
||||
format.html {render @homework}
|
||||
format.json {render json: @homework}
|
||||
end
|
||||
end
|
||||
|
||||
#显示作业信息
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_new_homework)%> </p>
|
||||
<div class="box tabular">
|
||||
<%= form_for('new_form', :remote => true, :method => :post,
|
||||
:url => {:controller => 'homework_attach',
|
||||
:action => 'create',
|
||||
:user_id => User.current.id,
|
||||
:bid_id => @bid
|
||||
}) do |f|%>
|
||||
<p>
|
||||
<strong>标题:</strong>
|
||||
<%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>
|
||||
</p>
|
||||
<p>
|
||||
<strong style="vertical-align: top">描述:</strong>
|
||||
<span style="margin-left:-10px;padding-right: 20px;">
|
||||
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</span>
|
||||
</p>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<%= l(:label_attachment_plural) %>
|
||||
</legend>
|
||||
<p id="put-bid-form-partial">
|
||||
<%= render :partial => 'attachments/form' %>
|
||||
</p>
|
||||
</fieldset>
|
||||
<span style="padding-left: 60px">
|
||||
<%= submit_tag t(:label_new), :sta => 0, :class => "enterprise"%>
|
||||
<%= submit_tag t(:label_memo_create), :sta => 1, :class => "enterprise"%>
|
||||
</span>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
|
@ -580,6 +580,10 @@ zh:
|
|||
label_course_done: 已结束的课程
|
||||
label_homework_response: 作业咨询
|
||||
label_bidding_homework: 提交作业
|
||||
label_add_homework: 添加作业
|
||||
label_edit_homework: 修改作业
|
||||
label_delete_homework: 删除作业
|
||||
label_new_homework: 创建作业
|
||||
|
||||
#end
|
||||
label_my_page: 我的工作台
|
||||
|
@ -962,6 +966,7 @@ zh:
|
|||
button_edit_associated_wikipage: "编辑相关wiki页面: %{page_title}"
|
||||
button_add: 新增
|
||||
button_change: 修改
|
||||
button_ok_and_submit: 确定并提交
|
||||
|
||||
button_apply: 查询
|
||||
button_clear: 清除留言
|
||||
|
|
|
@ -562,7 +562,7 @@ RedmineApp::Application.routes.draw do
|
|||
match 'calls/new_bid', :controller => 'bids', :action => 'new_bid'
|
||||
match 'contest/new_contest', :controller => 'bids', :action => 'new_contest' #huang
|
||||
match 'calls/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid'
|
||||
match 'calls/:id/show_project_homework', :controller => 'bids', :action => 'show_project_homework', :as => 'project_for_bid_homework' # by huang
|
||||
match 'calls/:id/new_homework', :controller => 'homework_attach', :action => 'new', :as => 'new_homework_attach'
|
||||
match 'calls/:id/add', :controller => 'bids', :action => 'add'
|
||||
match 'calls/:id/delete', :controller => 'bids', :action => 'delete'
|
||||
match 'calls/:id/add_homework', :controller => 'bids', :action => 'add_homework', via: :post
|
||||
|
|
Loading…
Reference in New Issue