|
|
require "grit"
|
|
require "grit"
|
|
|
|
|
|
|
|
class Project < ActiveRecord::Base
|
|
class Project < ActiveRecord::Base
|
|
|
|
belongs_to :owner, :class_name => "User"
|
|
|
|
|
|
|
has_many :issues, :dependent => :destroy
|
|
has_many :issues, :dependent => :destroy
|
|
|
has_many :users_projects, :dependent => :destroy
|
|
has_many :users_projects, :dependent => :destroy
|
|
|
has_many :users, :through => :users_projects
|
|
has_many :users, :through => :users_projects
|
|
|
belongs_to :owner, :class_name => "User"
|
|
|
|
|
has_many :notes, :dependent => :destroy
|
|
has_many :notes, :dependent => :destroy
|
|
|
|
|
|
|
|
validates :name,
|
|
validates :name,
|
| ... | @@ -25,6 +26,9 @@ class Project < ActiveRecord::Base |
... | @@ -25,6 +26,9 @@ class Project < ActiveRecord::Base |
|
|
:uniqueness => true,
|
|
:uniqueness => true,
|
|
|
:length => { :within => 3..12 }
|
|
:length => { :within => 3..12 }
|
|
|
|
|
|
|
|
|
validates :owner,
|
|
|
|
:presence => true
|
|
|
|
|
|
|
validate :check_limit
|
|
validate :check_limit
|
|
|
|
|
|
|
|
before_save :format_code
|
|
before_save :format_code
|
| ... | @@ -130,8 +134,10 @@ class Project < ActiveRecord::Base |
... | @@ -130,8 +134,10 @@ class Project < ActiveRecord::Base |
|
|
|
|
|
|
|
def check_limit
|
|
def check_limit
|
|
|
unless owner.can_create_project?
|
|
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
|
|
end
|
|
|
|
rescue
|
|
|
|
errors[:base] << ("Cant check your ability to create project")
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def valid_repo?
|
|
def valid_repo?
|
| ... | |
... | |
| ... | | ... | |