add modify about homework and modify the show of toll bar

This commit is contained in:
xianbo 2013-10-30 22:17:16 +08:00
parent f55a06e76d
commit 5dfac1d8e3
10 changed files with 107 additions and 32 deletions

View File

@ -1,6 +1,7 @@
# fq # fq
class BidsController < ApplicationController class BidsController < ApplicationController
#Added by young #Added by young
menu_item l(:label_homework), :only => [:edit, :udpate]
menu_item :respond menu_item :respond
menu_item :project, :only => [:show_project,:show_results] menu_item :project, :only => [:show_project,:show_results]
menu_item :homework_respond, :only => :homework_respond menu_item :homework_respond, :only => :homework_respond
@ -8,7 +9,7 @@ class BidsController < ApplicationController
#Ended by young #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] :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 :watchers
helper :attachments helper :attachments
@ -77,7 +78,6 @@ class BidsController < ApplicationController
end end
#end #end
end end
#huang #huang
def contest def contest
@ -584,6 +584,30 @@ class BidsController < ApplicationController
end end
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 def add_homework
# homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id) # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id)
# homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))

View File

@ -61,7 +61,10 @@ class Bid < ActiveRecord::Base
safe_attributes 'name', safe_attributes 'name',
'description', 'description',
'budget', 'budget',
'deadline' 'deadline',
'homework_type',
'reward_type'
# safe_attributes 'name', # safe_attributes 'name',
# 'description', # 'description',

View File

@ -8,14 +8,21 @@
<table width="100%" border="0"> <table width="100%" border="0">
<tr> <tr>
<td colspan="2" valign="top"><strong><span><%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>: &nbsp;<%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %></span> <td colspan="2" valign="top"><strong><span><%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author), :class => 'bid_user') %>: &nbsp;<%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %></span>
<span style="float: right">
<span style="float: right"><%= link_to( <% 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), l(:button_delete),
{:action => 'homework_destroy', :controller=>'bids', :course_id => bid.id}, {:action => 'homework_destroy', :controller=>'bids', :course_id => bid.id},
:method => :post, :method => :post,
:data => {:confirm => l(:text_are_you_sure)}, :data => {:confirm => l(:text_are_you_sure)},
:class => 'icon icon-del' :class => 'icon icon-del'
) if (User.current.admin?||User.current.id==bid.author_id)&&(bid.homework_type == 1)%></span></td> ) %></span></td>
<% end %>
</strong></td> </strong></td>
</tr> </tr>
<tr> <tr>
@ -60,4 +67,3 @@
<%= pagination_links_full bid_pages %> <%= pagination_links_full bid_pages %>
<ul> <ul>
</div> </div>
<!--end-->

View File

@ -0,0 +1,41 @@
<!-- fq -->
<script type="text/javascript" language="javascript">
function show(id, id_t, label_reward, label_money, label_credit, label_content) {
var text = $('#' + id);
var text_t = $('#' + id_t);
if (text.val() == 0) {
text_t.attr("placeholder", label_reward);
}
if (text.val() == 1) {
text_t.attr("placeholder", label_money);
}
if (text.val() == 3) {
text_t.attr("placeholder", label_credit);
}
if (text.val() == 2) {
text_t.attr("placeholder", label_content);
}
return content;
}
</script>
<%= error_messages_for 'bid' %>
<!--[form:project]-->
<p><%= l(:label_homeworks_form_new_description) %></p>
<p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT %></p>
<p 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;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT %></p>
<!-- <p><%= select_tag 'bid_reward_type', "<option value = '0'>#{l(:label_choose_reward)}</option><option value = '1'>#{l(:label_money)}</option><option value = '3'>#{l(:label_bids_credit)}</option><option value = '2'>#{l(:label_reward_1)}</option>".html_safe,
:onChange => "show('bid_reward_type', 'bid_budget', '"+l(:label_bids_reward_what)+"','"+l(:label_bids_new_money)+"','"+l(:label_bids_new_credit)+"','"+l(:label_bids_new_content)+"')" %>
<%= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %>
</p> -->
<p><%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;" %><%= calendar_for('bid_deadline')%>
</p>
<p><%= f.select :homework_type, homework_type_option %>
</p>
<p><%= hidden_field_tag 'course_id', @project_id %>
</p>
<fieldset><legend><%= l(:label_attachment_plural) %></legend>
<p><%= render :partial => 'attachments/form', :locals => {:container => @homework} %></p>
</fieldset>

View File

@ -0,0 +1,9 @@
<h3>修改作业</h3>
<%= labelled_form_for @bid do |f| %>
<div class="box tabular">
<%= render :partial => 'homework_form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<%= javascript_tag "$('#bid_name').focus();" %>
<% end %>
</div>

View File

@ -1,8 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8">
<title><%= h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" /> <meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" /> <meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %> <%= csrf_meta_tag %>
@ -175,9 +174,7 @@
</li> </li>
<!-- <li><%= link_to(l(:label_course_repository), {:controller => 'repositories', :action => 'show', :id => @project, :repository_id => nil, :path => nil, :rev => nil, :course => 1 })%></li> --> <!-- <li><%= link_to(l(:label_course_repository), {:controller => 'repositories', :action => 'show', :id => @project, :repository_id => nil, :path => nil, :rev => nil, :course => 1 })%></li> -->
<% 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))%> <% 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))%>
<li>
<%= link_to l(:label_course_settings), {:controller => 'projects', :action => 'settings', :id => @project}, :class => link_class(:settings)%>
</li>
</ul> </ul>
<% end %> <% end %>
</div> </div>

View File

@ -11,13 +11,6 @@
<!-- <%= toggle_link l(:label_new_call), 'put-bid-form', {:focus => 'project_id'} %> --> <!-- <%= toggle_link l(:label_new_call), 'put-bid-form', {:focus => 'project_id'} %> -->
<!-- </div> --> <!-- </div> -->
<% end %></td> <% end %></td>
<td align="right">
<div class="project-search">
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= submit_tag l(:label_search), :class => "small", :name => nil %>
</div></td>
</tr></table> </tr></table>
</div> </div>

View File

@ -1654,3 +1654,4 @@ zh:
label_has_watched_project: 关注的项目 label_has_watched_project: 关注的项目
label_project_take: 参与的项目 label_project_take: 参与的项目
label_peoject_take_in: 加入了项目: label_peoject_take_in: 加入了项目:
label_update_homework_succeed: 作业更新成功

View File

@ -132,7 +132,7 @@ RedmineApp::Application.routes.draw do
post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue' post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue'
delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue' delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue'
resources :bids, :only=>[:edit,:update]
resources :projects do resources :projects do
member do member do
get 'settings(/:tab)', :action => 'settings', :as => 'settings' 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 'new_homework', :action => 'new_homework', :as => 'new_homework'
#get 'news', :action => 'news', :as => 'news' #get 'news', :action => 'news', :as => 'news'
#end #end
post 'modules' post 'modules'
post 'archive' post 'archive'
post 'unarchive' post 'unarchive'
@ -399,6 +398,8 @@ RedmineApp::Application.routes.draw do
end end
end end
match 'workflows', :controller => 'workflows', :action => 'index', :via => :get match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post] match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post]
match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post] match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post]

View File

@ -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 :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 :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 :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 end
Redmine::MenuManager.map :user_menu do |menu| Redmine::MenuManager.map :user_menu do |menu|