[refs #90] choose project

This commit is contained in:
Alexander Machehin 2012-05-14 23:09:18 +06:00
parent bd2bb2b91f
commit ff016efe1c
5 changed files with 21 additions and 4 deletions

View File

@ -40,4 +40,9 @@ class Projects::PullRequestsController < Projects::BaseController
def update
end
def autocomplete_base_project_name
items = Project.accessible_by(current_ability, :membered)
render :json => json_for_autocomplete(items, 'full_name')
end
end

View File

@ -60,6 +60,7 @@ class Ability
can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin')}
can :remove_user, Project
can :pull, Project #FIXME!
can [:autocomplete_base_project_name, :autocomplete_head_project_name], Project
can [:read, :owned], BuildList, :user_id => user.id
can [:read, :related], BuildList, :project => {:owner_type => 'User', :owner_id => user.id}

View File

@ -67,7 +67,7 @@ class Project < ActiveRecord::Base
find_by_owner_and_name(owner_name, project_name) or raise ActiveRecord::RecordNotFound
end
def build_for(platform, user, arch = 'i586', priority = 0)
def build_for(platform, user, arch = 'i586', priority = 0)
# Select main and project platform repository(contrib, non-free and etc)
# If main does not exist, will connect only project platform repository
# If project platform repository is main, only main will be connect
@ -232,6 +232,10 @@ class Project < ActiveRecord::Base
I18n.t("layout.projects.human_average_build_time", {:hours => (time/3600).to_i, :minutes => (time%3600/60).to_i})
end
def full_name
"#{owner.uname}/#{name}"
end
protected
def build_path(dir)

View File

@ -9,13 +9,16 @@
#discussion.tab-pane.active
=form_for @pull, :url => project_pull_requests_path, :html => {:class => 'well well-large'} do |f|
.leftlist=f.label :base_project, t('.base_project'), :class => :label
.rightlist=f.text_field :base_project_id
.rightlist
=f.autocomplete_field :base_project, autocomplete_base_project_name_project_pull_requests_path, :value => @pull.base_project.full_name, :id_element => '#pull_request_base_project_id'
=f.hidden_field :base_project_id
.both
.leftlist=f.label :base_ref, "#{t '.base_ref'} #{t '.refs'}", :class => :label
.rightlist=select_tag :base_ref, branch_selector_options(@project), :id => 'branch_selector'
.both
.leftlist=f.label :head_project, t('.head_project'), :class => :label
.rightlist=f.text_field :head_project_id
=f.autocomplete_field :head_project, autocomplete_head_project_name_project_pull_requests_path, :value => @pull.head_project.full_name, :id_element => '#pull_request_head_project_id'
=f.hidden_field :head_project_id
.both
.leftlist=f.label :head_ref, "#{t '.head_ref'} #{t '.refs'}", :class => :label
.rightlist=select_tag :head_ref, branch_selector_options(@pull.head_project), :id => 'branch_selector'

View File

@ -164,7 +164,11 @@ Rosa::Application.routes.draw do
get :find, :on => :collection
end
resources :pull_requests, :except => [:destroy, :new] do
post '/new' => 'pull_requests#new', :on => :collection
collection do
post '/new' => 'pull_requests#new'
get :autocomplete_base_project_name
get :autocomplete_head_project_name
end
end
end