diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index 3b03eb1ff..36216530b 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -1,14 +1,15 @@
# fq
class BidsController < ApplicationController
#Added by young
+ menu_item l(:label_homework), :only => [:edit, :udpate]
menu_item :respond
menu_item :project, :only => [:show_project,:show_results]
menu_item :homework_respond, :only => :homework_respond
menu_item :homework_statistics, :only => :homework_statistics
#Ended by young
- before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork,
+ before_filter :find_bid, :only => [:show, :show_project, :create, :destroy, :more, :back, :add,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork,
:show_course, :show_bid_project, :show_bid_user]
- before_filter :require_login,:only => [:set_reward]
+ before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ]
helper :watchers
helper :attachments
@@ -77,7 +78,6 @@ class BidsController < ApplicationController
end
#end
end
-
#huang
def contest
@@ -583,7 +583,31 @@ class BidsController < ApplicationController
render :action => 'new_bid'
end
end
-
+
+ def edit
+ @project_id = params[:project_id]
+ @bid = Bid.find(params[:bid_id])
+ respond_to do |format|
+ format.html {
+ @project = Project.find(params[:project_id])
+ @user= User.find(User.current.id)
+ render :layout => 'base_courses'
+ }
+ end
+ end
+
+ def update
+ @bid = Bid.find(params[:id])
+ if @bid.update_attributes(params[:bid])
+ flash[:notice] = l(:label_update_homework_succeed)
+ @project = Project.find(params[:course_id])
+ redirect_to project_homework_path(@project)
+ else
+ @bid.safe_attributes = params[:bid]
+ render :action => 'edit'
+ end
+ end
+
def add_homework
# homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id)
# homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
diff --git a/app/models/bid.rb b/app/models/bid.rb
index 0205df548..3bad65f3c 100644
--- a/app/models/bid.rb
+++ b/app/models/bid.rb
@@ -61,7 +61,10 @@ class Bid < ActiveRecord::Base
safe_attributes 'name',
'description',
'budget',
- 'deadline'
+ 'deadline',
+ 'homework_type',
+ 'reward_type'
+
# safe_attributes 'name',
# 'description',
diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb
index 78a4d6f40..66a83f1d8 100644
--- a/app/views/bids/_bid_homework_show.html.erb
+++ b/app/views/bids/_bid_homework_show.html.erb
@@ -8,14 +8,21 @@
<%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>: <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %>
-
- <%= link_to(
- l(:button_delete),
- {:action => 'homework_destroy', :controller=>'bids', :course_id => bid.id},
- :method => :post,
- :data => {:confirm => l(:text_are_you_sure)},
- :class => 'icon icon-del'
- ) if (User.current.admin?||User.current.id==bid.author_id)&&(bid.homework_type == 1)%>
+
+ <% if (User.current.admin?||User.current.id==bid.author_id)&&(bid.homework_type == 1)%>
+ <%= link_to(
+ l(:button_edit),
+ {:action => 'edit', :controller=>'bids', :project_id =>@project.id, :bid_id => bid.id},
+ :class => 'icon icon-edit'
+ ) %>
+ <%= link_to(
+ l(:button_delete),
+ {:action => 'homework_destroy', :controller=>'bids', :course_id => bid.id},
+ :method => :post,
+ :data => {:confirm => l(:text_are_you_sure)},
+ :class => 'icon icon-del'
+ ) %>
+ <% end %>
@@ -59,5 +66,4 @@
<%= pagination_links_full bid_pages %>
-
-
+
\ No newline at end of file
diff --git a/app/views/bids/_homework_form.html.erb b/app/views/bids/_homework_form.html.erb
new file mode 100644
index 000000000..fe6f35fb3
--- /dev/null
+++ b/app/views/bids/_homework_form.html.erb
@@ -0,0 +1,41 @@
+
+
+
+
+<%= error_messages_for 'bid' %>
+
+<%= l(:label_homeworks_form_new_description) %>
+<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT %>
+
+<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT %>
+
+<%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;" %><%= calendar_for('bid_deadline')%>
+
+<%= f.select :homework_type, homework_type_option %>
+
+<%= hidden_field_tag 'course_id', @project_id %>
+
+<%= l(:label_attachment_plural) %>
+<%= render :partial => 'attachments/form', :locals => {:container => @homework} %>
+
\ No newline at end of file
diff --git a/app/views/bids/edit.html.erb b/app/views/bids/edit.html.erb
new file mode 100644
index 000000000..028a1a88e
--- /dev/null
+++ b/app/views/bids/edit.html.erb
@@ -0,0 +1,9 @@
+修改作业
+
+<%= labelled_form_for @bid do |f| %>
+
+ <%= render :partial => 'homework_form', :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/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index b9ed0f1be..ac3938a0b 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -1,8 +1,7 @@
-
- <%= h html_title %>
+
<%= csrf_meta_tag %>
@@ -175,9 +174,7 @@
<% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0))%>
-
- <%= link_to l(:label_course_settings), {:controller => 'projects', :action => 'settings', :id => @project}, :class => link_class(:settings)%>
-
+
<% end %>
diff --git a/app/views/projects/homework.html.erb b/app/views/projects/homework.html.erb
index 8db482544..37c4d71bd 100644
--- a/app/views/projects/homework.html.erb
+++ b/app/views/projects/homework.html.erb
@@ -11,13 +11,6 @@
<% end %>
-
-
-
-
- <%= text_field_tag 'name', params[:name], :size => 30 %>
- <%= submit_tag l(:label_search), :class => "small", :name => nil %>
-
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index ec5ffca22..91e0e8d06 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -1653,4 +1653,5 @@ zh:
label_watch_no_projects: 没有关注任何项目
label_has_watched_project: 关注的项目
label_project_take: 参与的项目
- label_peoject_take_in: 加入了项目:
\ No newline at end of file
+ label_peoject_take_in: 加入了项目:
+ label_update_homework_succeed: 作业更新成功
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 6b2bee154..156bb8fd2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -132,7 +132,7 @@ RedmineApp::Application.routes.draw do
post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue'
delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue'
-
+ resources :bids, :only=>[:edit,:update]
resources :projects do
member do
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
@@ -147,7 +147,6 @@ RedmineApp::Application.routes.draw do
get 'new_homework', :action => 'new_homework', :as => 'new_homework'
#get 'news', :action => 'news', :as => 'news'
#end
-
post 'modules'
post 'archive'
post 'unarchive'
@@ -156,7 +155,7 @@ RedmineApp::Application.routes.draw do
match 'copy', :via => [:get, :post]
end
-
+
#by young
match '/member', :controller => 'projects', :action => 'member', :as => 'member', :via => :get
match '/file', :controller => 'projects', :action => 'file', :as => 'file', :via => :get
@@ -398,6 +397,8 @@ RedmineApp::Application.routes.draw do
get 'autocomplete_for_new_user'
end
end
+
+
match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post]
diff --git a/lib/redmine.rb b/lib/redmine.rb
index 4de558af3..e4e639f91 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -324,7 +324,7 @@ Redmine::MenuManager.map :course_menu do |menu|
# menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
# menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_new, :param => :project_id
menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil, :course => 1 }
- menu.push :settings, { :controller => 'projects', :action => 'settings', :course => 1 }, :last => true
+ # menu.push :settings, { :controller => 'projects', :action => 'settings', :course => 1 }, :last => true
end
Redmine::MenuManager.map :user_menu do |menu|