添加了提交作业
This commit is contained in:
parent
9221d1b376
commit
805ad6600b
|
@ -121,7 +121,9 @@ private
|
|||
@attachment = Attachment.find(params[:id])
|
||||
# Show 404 if the filename in the url is wrong
|
||||
raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename
|
||||
@project = @attachment.project
|
||||
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach'
|
||||
@project = @attachment.project
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
|
|
@ -3,10 +3,13 @@ class BidsController < ApplicationController
|
|||
#Added by young
|
||||
menu_item :respond
|
||||
menu_item :project, :only => :show_project
|
||||
menu_item :homework_respond, :only => :homework_respond
|
||||
#Ended by young
|
||||
before_filter :find_bid, :only => [:show, :show_project, :create, :destroy, :more, :back, :add, :new]
|
||||
before_filter :find_bid, :only => [:show, :show_project, :create, :destroy, :more, :back, :add, :new, :homework_respond, :add_homework]
|
||||
|
||||
helper :watchers
|
||||
helper :attachments
|
||||
include AttachmentsHelper
|
||||
def index
|
||||
# Modified by nie
|
||||
# @requirement_title = "4"
|
||||
|
@ -117,6 +120,10 @@ class BidsController < ApplicationController
|
|||
# @project = Project.where("id in []", a)
|
||||
@user = @bid.author
|
||||
@bidding_project = @bid.biding_projects
|
||||
if @bid.homework_type == 1
|
||||
@homework = HomeworkAttach.new
|
||||
@homework_list = @bid.homeworks
|
||||
end
|
||||
respond_to do |format|
|
||||
if @bid.reward_type == 3
|
||||
format.html {
|
||||
|
@ -329,6 +336,8 @@ class BidsController < ApplicationController
|
|||
@bid.budget = 0
|
||||
@bid.author_id = User.current.id
|
||||
@bid.commit = 0
|
||||
@bid.homework_type = params[:bid][:homework_type]
|
||||
@bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
|
||||
# @bid.
|
||||
if @bid.save
|
||||
HomeworkForCourse.create(:project_id => params[:course_id], :bid_id => @bid.id)
|
||||
|
@ -342,8 +351,24 @@ class BidsController < ApplicationController
|
|||
@bid.safe_attributes = params[:bid]
|
||||
render :action => 'new_bid'
|
||||
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]))
|
||||
@homework = HomeworkAttach.new
|
||||
@homework.bid_id = @bid.id
|
||||
@homework.user_id = User.current.id
|
||||
@homework.save_attachments(params[:attachments])
|
||||
@homework.save
|
||||
@homework_list = @bid.homeworks
|
||||
|
||||
end
|
||||
|
||||
def homework_respond
|
||||
@user = @bid.author
|
||||
render :layout => 'base_homework'
|
||||
end
|
||||
|
||||
def more
|
||||
@jour = @bid.journals_for_messages
|
||||
|
|
|
@ -6,7 +6,7 @@ class CoursesController < ApplicationController
|
|||
def join
|
||||
if User.current.logged?
|
||||
course = Project.find(params[:object_id])
|
||||
if params[:course_password] == '123'
|
||||
if params[:course_password].to_i == Course.find_by_extra(course.identifier).state
|
||||
members = []
|
||||
members << Member.new(:role_ids => [5], :user_id => User.current.id)
|
||||
course.members << members
|
||||
|
|
|
@ -39,6 +39,8 @@ class ProjectsController < ApplicationController
|
|||
before_filter :authorize_global, :only => [:new, :create]
|
||||
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
|
||||
#by young
|
||||
# before_filter :member, :file, :statistics, :watcherlist
|
||||
# modified by fq
|
||||
before_filter :file, :statistics, :watcherlist
|
||||
#
|
||||
accept_rss_auth :index
|
||||
|
@ -518,6 +520,9 @@ class ProjectsController < ApplicationController
|
|||
# end
|
||||
|
||||
def file
|
||||
# if @project.project_type == 1
|
||||
# render :layout => 'base_courses'
|
||||
# end
|
||||
# @course_tag = params[:course]
|
||||
# if @course_tag == '1'
|
||||
# render :layout => 'base_courses'
|
||||
|
|
|
@ -132,5 +132,18 @@ module ProjectsHelper
|
|||
def get_projects_by_tag(tag_name)
|
||||
Project.tagged_with(tag_name).order('updated_on desc')
|
||||
end
|
||||
|
||||
# added by fq
|
||||
def homework_type_option
|
||||
type = []
|
||||
option1 = []
|
||||
option2 = []
|
||||
option1 << '提交附件'
|
||||
option1 << 1
|
||||
option2 << '提交项目'
|
||||
option2 << 2
|
||||
type << option1
|
||||
type << option2
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -46,9 +46,10 @@ module WatchersHelper
|
|||
link_to text, url, :remote => true, :method => method, :class => css
|
||||
end
|
||||
|
||||
# added by fq
|
||||
def join_in_course(course, user)
|
||||
return '' unless user && user.logged?
|
||||
joined = user.join_in?(course)
|
||||
joined = user.member_of?(course)
|
||||
text = joined ? '退出课程' : '加入课程'
|
||||
url_t = join_path(:object_id => course.id)
|
||||
url_f = try_join_path(:object_id => course.id)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
####by fq
|
||||
class Bid < ActiveRecord::Base
|
||||
#attr_accessible :author_id, :budget, :deadline, :name, :description
|
||||
attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type
|
||||
include Redmine::SafeAttributes
|
||||
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => :author_id
|
||||
|
@ -11,6 +11,9 @@ class Bid < ActiveRecord::Base
|
|||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
has_many :homework_for_courses, :dependent => :destroy
|
||||
has_many :courses, :through => :homework_for_courses, :source => :project
|
||||
has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy
|
||||
|
||||
acts_as_attachable
|
||||
|
||||
NAME_LENGTH_LIMIT = 60
|
||||
DESCRIPTION_LENGTH_LIMIT = 250
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class HomeworkAttach < ActiveRecord::Base
|
||||
attr_accessible :bid_id, :user_id
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :bid
|
||||
|
||||
acts_as_attachable
|
||||
|
||||
end
|
|
@ -57,6 +57,7 @@ class Project < ActiveRecord::Base
|
|||
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
||||
has_many :students_for_courses, :dependent => :destroy
|
||||
has_many :student, :through => :students_for_courses, :source => :user
|
||||
# has_one :cour, :class_name => 'Course', :foreign_key => :extra, :dependent => :destroy
|
||||
|
||||
# end
|
||||
#ADDED BY NIE
|
||||
|
@ -1040,6 +1041,7 @@ class Project < ActiveRecord::Base
|
|||
def update_position_under_parent
|
||||
set_or_update_position_under(parent)
|
||||
end
|
||||
|
||||
def course
|
||||
@course
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<% elsif bid.reward_type == 2%>
|
||||
<strong><%= l(:label_bids_reward_method) %><span style="color: #15bccf;font-family: 14px; font-family: 微软雅黑"><%= bid.budget%></span></strong>
|
||||
<% else %>
|
||||
<strong><%= l(:label_bids_reward_method) %><span style="color: #00aa83;font-family: 14px; font-family: 微软雅黑"><%= l(:label_bids_credit) %> <%= bid.budget%> <%= l(:label_bids_credit_number) %></span></strong>
|
||||
<!-- <strong><%= l(:label_bids_reward_method) %><span style="color: #00aa83;font-family: 14px; font-family: 微软雅黑"><%= l(:label_bids_credit) %> <%= bid.budget%> <%= l(:label_bids_credit_number) %></span></strong> -->
|
||||
<% end %>
|
||||
|
||||
<!-- <td style="color: rgb(255, 0, 0);"><strong><%= l(:label_price) %><%= l(:label_RMB_sign) %><%= bid.budget%></strong></td> -->
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<div id="put-bid-form" style="display: none">
|
||||
<%= form_for "bid_for_save", :remote=>true, :url => {:controller => 'bids', :action => 'add_homework'},
|
||||
:update => "bidding_project_list",
|
||||
:complete => '$("#put-bid-form").hide();' do |f| %>
|
||||
<fieldset><legend><%= l(:label_attachment_plural) %></legend>
|
||||
<p><%= render :partial => 'attachments/form', :locals => {:container => @homework} %></p>
|
||||
</fieldset>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class='icon icon-add'>
|
||||
<%= toggle_link l(:button_bidding), 'put-bid-form' %>
|
||||
</div>
|
||||
|
||||
<div id='bidding_project_list'>
|
||||
<%= render :partial => 'homework_list', :locals => {:homework => @homework_list} %>
|
||||
</div>
|
|
@ -0,0 +1,30 @@
|
|||
<!-- fq -->
|
||||
<%= render_flash_messages %>
|
||||
|
||||
<% @homework_list.each do |homework|%>
|
||||
<% if homework.attachments.any?%>
|
||||
|
||||
<table width="660px" border="0" align="center">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(homework.user), :class => "avatar"), user_path(homework.user), :class => "avatar" %></td>
|
||||
<td>
|
||||
<table width="580px" border="0">
|
||||
<tr>
|
||||
<td colspan="2" valign="top"><strong> <%= link_to homework.user, user_path(homework.user)%></strong> <span class="font_lighter">提交了作业</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580px" >
|
||||
<p class="font_description">
|
||||
<% options = {:author => true} %>
|
||||
<%= render :partial => 'attachments/links',
|
||||
:locals => {:attachments => homework.attachments, :options => options} %>
|
||||
<% end %>
|
||||
</p></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="line_under"></div>
|
||||
|
||||
|
||||
<% end %>
|
|
@ -0,0 +1,4 @@
|
|||
$('#bidding_project_list').html('<%= escape_javascript(render(:partial => 'homework_list', :locals => {:homework => @homework_list})) %>');
|
||||
$("#project_id").val("请选择项目");
|
||||
$("#bid_message").val("#{l(:label_bid_reason)} ");
|
||||
$("#put-bid-form").hide();
|
|
@ -20,7 +20,6 @@
|
|||
<% elsif @bid.reward_type == 2%>
|
||||
<td><strong><%= l(:label_bids_reward_method) %><span style="color: #15bccf;font-family: 14px; font-family: 微软雅黑"><%= @bid.budget%></span></strong></td>
|
||||
<% else %>
|
||||
<td><strong><%= l(:label_bids_reward_method) %><span style="color: #00aa83;font-family: 14px; font-family: 微软雅黑"><%= l(:label_bids_credit) %> <%= @bid.budget%> <%= l(:label_bids_credit_number) %></span></strong></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</table></td>
|
||||
|
@ -31,7 +30,13 @@
|
|||
<tr>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr><td style="font-size: 13px; color: rgb(0,0,0);"><%= @bid.description %></td></tr>
|
||||
<tr><td style="font-size: 13px; color: rgb(0,0,0);"><%= @bid.description %>
|
||||
<% if @bid.attachments.any?%>
|
||||
<% options = {:author => true} %>
|
||||
<%= render :partial => 'attachments/links',
|
||||
:locals => {:attachments => @bid.attachments, :options => options} %>
|
||||
<% end %>
|
||||
</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<!-- fq -->
|
||||
<% if @bid.homework_type == 1%>
|
||||
<%= render :partial => 'homework' %>
|
||||
<% else %>
|
||||
<style>
|
||||
input[type="submit"].bid_btn {
|
||||
vertical-align: middle;
|
||||
|
@ -84,3 +87,4 @@
|
|||
<div id='bidding_project_list'>
|
||||
<%= render :partial => 'project_list', :locals => {:bidding_project => @bidding_project} %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -111,6 +111,7 @@
|
|||
<ul>
|
||||
<li><%= link_to(l(:label_question_student), { :controller => 'bids', :action => 'show' })%></li>
|
||||
<li><%= link_to(l(:label_homework_commit), { :controller => 'bids', :action => 'show_project' })%></li>
|
||||
<li><%= link_to(l(:label_homework_respond), { :controller => 'bids', :action => 'homework_respond' })%></li>
|
||||
<ul>
|
||||
</div>
|
||||
<%= yield %>
|
||||
|
|
|
@ -32,5 +32,10 @@
|
|||
</p> -->
|
||||
<p><%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;", :placeholder => "#{l(:label_deadline)}" %><%= calendar_for('bid_deadline')%>
|
||||
</p>
|
||||
<p><%= f.select :homework_type, homework_type_option%>
|
||||
</p>
|
||||
<p><%= hidden_field_tag 'course_id', @project.id%>
|
||||
</p>
|
||||
</p>
|
||||
<fieldset><legend><%= l(:label_attachment_plural) %></legend>
|
||||
<p><%= render :partial => 'attachments/form', :locals => {:container => @homework} %></p>
|
||||
</fieldset>
|
|
@ -59,10 +59,10 @@ border-top: 1px solid #acaeb1; border-bottom: 1px solid #acaeb1; margin-top: 30p
|
|||
<td colspan="2"><div class="tableline"></div></td>
|
||||
</tr>
|
||||
<!-- <tr>
|
||||
<td width="22%"><%= select_tag 'bid_reward_type', "<option value = '0'>#{l(:label_choose_reward)}</option><option value = '1'>#{l(:label_money)}</option><option value = '2'>#{l(:label_reward_1)}</option><option value = '3'>#{l(:label_bids_credit)}</option>".html_safe, :class => 'noline' %></td>
|
||||
<td><%= text_field_tag 'bid_budget', "#{l(:label_requirement_bargain_money)}", :class => 'noline', :required => true,
|
||||
:onfocus => "clearInfo('bid_budget', '#{l(:label_requirement_bargain_money)}')", :onblur => "showInfo('bid_budget', '#{l(:label_requirement_bargain_money)}')" %>
|
||||
</td>
|
||||
<td width="22%"><%= select_tag 'bid_reward_type', "<option value = '0'>#{l(:label_choose_reward)}</option><option value = '1'>#{l(:label_money)}</option><option value = '2'>#{l(:label_reward_1)}</option><option value = '3'>#{l(:label_bids_credit)}</option>".html_safe, :class => 'noline' %></td>
|
||||
<td><%= text_field_tag 'bid_budget', "#{l(:label_requirement_bargain_money)}", :class => 'noline', :required => true,
|
||||
:onfocus => "clearInfo('bid_budget', '#{l(:label_requirement_bargain_money)}')", :onblur => "showInfo('bid_budget', '#{l(:label_requirement_bargain_money)}')" %>
|
||||
</td>
|
||||
</tr> -->
|
||||
<tr>
|
||||
<td colspan="2"><div class="tableline"></div></td>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<%= text_field_tag 'course_password', nil%>
|
||||
|
||||
<p class="buttons">
|
||||
<%= submit_tag l(:button_add), :name => nil, :onclick => "hideModal(this);" %>
|
||||
<%= submit_tag '加入', :name => nil, :onclick => "hideModal(this);" %>
|
||||
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "hideModal(this);", :type => 'button' %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
|
|
@ -15,13 +15,6 @@
|
|||
<td width="500">
|
||||
<table border="0">
|
||||
<tr><td>
|
||||
<% if bid.reward_type.nil? or bid.reward_type == 1%>
|
||||
<strong><%= l(:label_bids_reward_method) %><span style="color: #ed8924;font-family: 14px; font-family: 微软雅黑"><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %><%= bid.budget%></span></strong>
|
||||
<% elsif bid.reward_type == 2%>
|
||||
<strong><%= l(:label_bids_reward_method) %><span style="color: #15bccf;font-family: 14px; font-family: 微软雅黑"><%= bid.budget%></span></strong>
|
||||
<% else %>
|
||||
<strong><%= l(:label_bids_reward_method) %><span style="color: #00aa83;font-family: 14px; font-family: 微软雅黑"><%= l(:label_bids_credit) %> <%= bid.budget%> <%= l(:label_bids_credit_number) %></span></strong>
|
||||
<% end %>
|
||||
|
||||
<!-- <td style="color: rgb(255, 0, 0);"><strong><%= l(:label_price) %><%= l(:label_RMB_sign) %><%= bid.budget%></strong></td> -->
|
||||
</td>
|
||||
|
|
|
@ -1251,6 +1251,8 @@ zh:
|
|||
label_user_response: 用户反馈
|
||||
label_bidding_project: 参与项目
|
||||
button_bidding: 我要参加
|
||||
field_homework_type: 作业类型
|
||||
label_homework_respond: 作业情况
|
||||
|
||||
label_new_call: 发布需求
|
||||
label_user_information: "与我相关"
|
||||
|
@ -1418,6 +1420,7 @@ zh:
|
|||
label_welcome_trustie: Trustie
|
||||
label_welcome_trustie_description: 面向有创意和激情的高校大学生与创业者,提供社交化的项目管理、协同研究、软件开发和众包平台。
|
||||
label_user_project: 项目
|
||||
label_user_course: 课程
|
||||
label_bid_respond_quote: 回复
|
||||
label_bid_if_agreement: 如果喜欢我,请点击我
|
||||
label_bid_respond_delete: 删除
|
||||
|
|
|
@ -437,10 +437,12 @@ RedmineApp::Application.routes.draw do
|
|||
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' # by huang
|
||||
match 'calls/:id/add', :controller => 'bids', :action => 'add'
|
||||
match 'calls/:id/add_homework', :controller => 'bids', :action => 'add_homework'
|
||||
match 'words/add_project_respond', :controller => 'words', :action => 'add_project_respond'
|
||||
match 'projects/:id/feedback', :to => 'projects#feedback', :via => :get, :as => 'project_feedback'
|
||||
match 'calls/create_bid', :to => 'bids#create_bid'
|
||||
match 'calls/create_homework', :to => 'bids#create_homework'
|
||||
match 'calls/:id/homework_respond', :to => 'bids#homework_respond'
|
||||
|
||||
post 'join_in/join', :to => 'courses#join', :as => 'join'
|
||||
delete 'join_in/join', :to => 'courses#unjoin'
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddHomeworkTypeToBid < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :bids, :homework_type, :integer
|
||||
end
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
class CreateHomeworkAttaches < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :homework_attaches do |t|
|
||||
t.integer :bid_id
|
||||
t.integer :user_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
16
db/schema.rb
16
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130911005626) do
|
||||
ActiveRecord::Schema.define(:version => 20130913125835) do
|
||||
|
||||
create_table "a_user_watchers", :force => true do |t|
|
||||
t.string "name"
|
||||
|
@ -82,14 +82,15 @@ ActiveRecord::Schema.define(:version => 20130911005626) do
|
|||
|
||||
create_table "bids", :force => true do |t|
|
||||
t.string "name"
|
||||
t.string "budget", :null => false
|
||||
t.string "budget", :null => false
|
||||
t.integer "author_id"
|
||||
t.date "deadline"
|
||||
t.string "description"
|
||||
t.datetime "created_on", :null => false
|
||||
t.datetime "updated_on", :null => false
|
||||
t.datetime "created_on", :null => false
|
||||
t.datetime "updated_on", :null => false
|
||||
t.integer "commit"
|
||||
t.integer "reward_type"
|
||||
t.integer "homework_type"
|
||||
end
|
||||
|
||||
create_table "boards", :force => true do |t|
|
||||
|
@ -259,6 +260,13 @@ ActiveRecord::Schema.define(:version => 20130911005626) do
|
|||
|
||||
add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true
|
||||
|
||||
create_table "homework_attaches", :force => true do |t|
|
||||
t.integer "bid_id"
|
||||
t.integer "user_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "homework_for_courses", :force => true do |t|
|
||||
t.integer "project_id"
|
||||
t.integer "bid_id"
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -218,6 +218,7 @@ end
|
|||
Redmine::MenuManager.map :bid_menu do |menu|
|
||||
menu.push :respond, { :controller => 'bids', :action => 'show' }, :caption => :label_user_response
|
||||
menu.push :project, { :controller => 'bids', :action => 'show_project' }, :caption => :label_bidding_project
|
||||
# menu.push :homework_respond, {:controller => 'bids', :action => 'homework_respond'}
|
||||
end
|
||||
Redmine::MenuManager.map :application_menu do |menu|
|
||||
# Empty
|
||||
|
|
Loading…
Reference in New Issue