parent
5a5db45af2
commit
104ee13ac7
|
@ -0,0 +1,16 @@
|
||||||
|
class AppliedProjectController < ApplicationController
|
||||||
|
|
||||||
|
#申请加入项目
|
||||||
|
def applied_join_project
|
||||||
|
AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
|
||||||
|
redirect_to_referer_or {render :text => ( 'applied success.'), :layout => true}
|
||||||
|
end
|
||||||
|
|
||||||
|
#取消申请
|
||||||
|
def unapplied_join_project
|
||||||
|
@applied = AppliedProject.find(params[:id])
|
||||||
|
@applied.destroy
|
||||||
|
redirect_to_referer_or {render :text => ( 'unsubscribe success.'), :layout => true}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,21 @@
|
||||||
|
module AppliedProjectHelper
|
||||||
|
|
||||||
|
def applied_link(project, user, options=[])
|
||||||
|
return '' unless user && user.logged?
|
||||||
|
applied = project.applied_projects.find_by_user_id(user.id)
|
||||||
|
text = applied ? l(:label_unapply_project) : l(:label_apply_project)
|
||||||
|
|
||||||
|
if applied
|
||||||
|
appliedid = applied.id
|
||||||
|
end
|
||||||
|
|
||||||
|
url = appliedproject_path(
|
||||||
|
:id=>appliedid,
|
||||||
|
:user_id => user.id,
|
||||||
|
:project_id => project.id
|
||||||
|
)
|
||||||
|
method = applied ? 'delete' : 'post'
|
||||||
|
|
||||||
|
link_to text, url, :remote => true, :method => method
|
||||||
|
end
|
||||||
|
end
|
|
@ -187,4 +187,23 @@ module WatchersHelper
|
||||||
:class => "floating"
|
:class => "floating"
|
||||||
end.join.html_safe
|
end.join.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def applied_link(project, user, options=[])
|
||||||
|
return '' unless user && user.logged?
|
||||||
|
applied = project.applied_projects.find_by_user_id(user.id)
|
||||||
|
text = applied ? l(:label_unapply_project) : l(:label_apply_project)
|
||||||
|
|
||||||
|
if applied
|
||||||
|
appliedid = applied.id
|
||||||
|
end
|
||||||
|
|
||||||
|
url = appliedproject_path(
|
||||||
|
:id=>appliedid,
|
||||||
|
:user_id => user.id,
|
||||||
|
:project_id => project.id
|
||||||
|
)
|
||||||
|
method = applied ? 'delete' : 'post'
|
||||||
|
|
||||||
|
link_to text, url, :remote => true, :method => method
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AppliedProject < ActiveRecord::Base
|
||||||
|
attr_accessible :project_id, :user_id
|
||||||
|
|
||||||
|
belongs_to :user
|
||||||
|
belongs_to :project
|
||||||
|
end
|
|
@ -64,6 +64,7 @@ class Project < ActiveRecord::Base
|
||||||
# has_many :students_for_courses, :dependent => :destroy
|
# has_many :students_for_courses, :dependent => :destroy
|
||||||
has_many :student, :through => :students_for_courses, :source => :user
|
has_many :student, :through => :students_for_courses, :source => :user
|
||||||
has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy
|
has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy
|
||||||
|
has_many :applied_projects
|
||||||
|
|
||||||
# end
|
# end
|
||||||
#ADDED BY NIE
|
#ADDED BY NIE
|
||||||
|
|
|
@ -103,6 +103,14 @@
|
||||||
<span class="icon-fav icon"></span><%= watcher_link(@project, User.current) %>
|
<span class="icon-fav icon"></span><%= watcher_link(@project, User.current) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<!--添加项目申请-->
|
||||||
|
<div style="margin-left: 20px;">
|
||||||
|
|
||||||
|
<% if ( !(User.current.member_of? @project) && User.current.login?) %> <!--added by linchun-->
|
||||||
|
<span class="icon-fav icon"></span><%= applied_link(@project, User.current) %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -1165,6 +1165,8 @@ en:
|
||||||
label_tags_bid_description: call description
|
label_tags_bid_description: call description
|
||||||
label_tags_issue_description: issue description
|
label_tags_issue_description: issue description
|
||||||
label_tags_all_objects: all objects
|
label_tags_all_objects: all objects
|
||||||
|
label_apply_project: Apply Project
|
||||||
|
label_unapply_project: Unsubscribe
|
||||||
|
|
||||||
#fq
|
#fq
|
||||||
button_leave_meassge: Submit
|
button_leave_meassge: Submit
|
||||||
|
|
|
@ -1326,7 +1326,8 @@ zh:
|
||||||
label_tags_bid_description: 需求描述
|
label_tags_bid_description: 需求描述
|
||||||
label_tags_issue_description: 问题描述
|
label_tags_issue_description: 问题描述
|
||||||
label_tags_all_objects: 所有
|
label_tags_all_objects: 所有
|
||||||
|
label_apply_project: 申请加入
|
||||||
|
label_unapply_project: 取消申请
|
||||||
|
|
||||||
#fq
|
#fq
|
||||||
button_leave_meassge: 留言
|
button_leave_meassge: 留言
|
||||||
|
|
|
@ -247,6 +247,9 @@ 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'
|
||||||
|
|
||||||
|
post 'appliedproject/applied', :to => 'applied_project#applied_join_project', :as => 'appliedproject'
|
||||||
|
delete 'appliedproject/applied', :to => 'applied_project#unapplied_join_project'
|
||||||
|
|
||||||
resources :bids, :only=>[:edit,:update,:show] do
|
resources :bids, :only=>[:edit,:update,:show] do
|
||||||
member do
|
member do
|
||||||
match 'homework_ajax_modal'
|
match 'homework_ajax_modal'
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
class CreateAppliedProjects < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
create_table :applied_projects do |t|
|
||||||
|
t.column :project_id, :integer, :null => false
|
||||||
|
t.column :user_id, :integer, :null => false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
drop_table :applied_projects
|
||||||
|
end
|
||||||
|
end
|
18
db/schema.rb
18
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140519070751) do
|
ActiveRecord::Schema.define(:version => 20140521072851) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -23,6 +23,11 @@ ActiveRecord::Schema.define(:version => 20140519070751) do
|
||||||
add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type"
|
add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type"
|
||||||
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
|
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
|
||||||
|
|
||||||
|
create_table "applied_projects", :force => true do |t|
|
||||||
|
t.integer "project_id", :null => false
|
||||||
|
t.integer "user_id", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "apply_project_masters", :force => true do |t|
|
create_table "apply_project_masters", :force => true do |t|
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.string "apply_type"
|
t.string "apply_type"
|
||||||
|
@ -52,11 +57,14 @@ ActiveRecord::Schema.define(:version => 20140519070751) do
|
||||||
add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type"
|
add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type"
|
||||||
add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on"
|
add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on"
|
||||||
|
|
||||||
create_table "attachmentstypes", :force => true do |t|
|
create_table "attachmentstypes", :id => false, :force => true do |t|
|
||||||
t.integer "typeId", :null => false
|
t.integer "id", :null => false
|
||||||
|
t.integer "typeId"
|
||||||
t.string "typeName", :limit => 50
|
t.string "typeName", :limit => 50
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "attachmentstypes", ["id"], :name => "id"
|
||||||
|
|
||||||
create_table "auth_sources", :force => true do |t|
|
create_table "auth_sources", :force => true do |t|
|
||||||
t.string "type", :limit => 30, :default => "", :null => false
|
t.string "type", :limit => 30, :default => "", :null => false
|
||||||
t.string "name", :limit => 60, :default => "", :null => false
|
t.string "name", :limit => 60, :default => "", :null => false
|
||||||
|
@ -675,6 +683,9 @@ ActiveRecord::Schema.define(:version => 20140519070751) do
|
||||||
t.integer "viewed_count_crawl", :default => 0
|
t.integer "viewed_count_crawl", :default => 0
|
||||||
t.integer "viewed_count_local", :default => 0
|
t.integer "viewed_count_local", :default => 0
|
||||||
t.string "url"
|
t.string "url"
|
||||||
|
t.string "username"
|
||||||
|
t.string "userhomeurl"
|
||||||
|
t.date "date_collected"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "repositories", :force => true do |t|
|
create_table "repositories", :force => true do |t|
|
||||||
|
@ -763,6 +774,7 @@ ActiveRecord::Schema.define(:version => 20140519070751) do
|
||||||
t.integer "softapplication_id"
|
t.integer "softapplication_id"
|
||||||
t.integer "is_public"
|
t.integer "is_public"
|
||||||
t.string "application_developers"
|
t.string "application_developers"
|
||||||
|
t.string "deposit_project_url"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "students_for_courses", :force => true do |t|
|
create_table "students_for_courses", :force => true do |t|
|
||||||
|
|
Loading…
Reference in New Issue