This commit is contained in:
gitlabhq 2011-10-09 22:36:57 +03:00
parent 67f0c62d07
commit 035196e7a8
4 changed files with 12 additions and 3 deletions

View file

@ -35,6 +35,7 @@ class Admin::ProjectsController < ApplicationController
def create
@admin_project = Project.new(params[:project])
@admin_project.owner = current_user
respond_to do |format|
if @admin_project.save

View file

@ -1,10 +1,11 @@
require "grit"
class Project < ActiveRecord::Base
belongs_to :owner, :class_name => "User"
has_many :issues, :dependent => :destroy
has_many :users_projects, :dependent => :destroy
has_many :users, :through => :users_projects
belongs_to :owner, :class_name => "User"
has_many :notes, :dependent => :destroy
validates :name,
@ -25,6 +26,9 @@ class Project < ActiveRecord::Base
:uniqueness => true,
:length => { :within => 3..12 }
validates :owner,
:presence => true
validate :check_limit
before_save :format_code
@ -130,8 +134,10 @@ class Project < ActiveRecord::Base
def check_limit
unless owner.can_create_project?
errors[:base] << ("You can to have #{owner.projects_limit} your own projects")
errors[:base] << ("Your own projects limit is #{owner.projects_limit}! Please contact administrator to increase it")
end
rescue
errors[:base] << ("Cant check your ability to create project")
end
def valid_repo?