Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
67f0c62d
Commit
67f0c62d
authored
Oct 09, 2011
by
Valera Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #83 - Project limit
parent
98401026
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
45 additions
and
9 deletions
+45
-9
app/assets/stylesheets/projects.css.scss
app/assets/stylesheets/projects.css.scss
+4
-0
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+1
-1
app/models/project.rb
app/models/project.rb
+8
-0
app/models/user.rb
app/models/user.rb
+6
-2
app/views/admin/users/_form.html.haml
app/views/admin/users/_form.html.haml
+2
-2
app/views/admin/users/show.html.haml
app/views/admin/users/show.html.haml
+3
-0
app/views/projects/index.html.haml
app/views/projects/index.html.haml
+2
-1
db/fixtures/development/001_admin.rb
db/fixtures/development/001_admin.rb
+1
-0
db/fixtures/production/001_admin.rb
db/fixtures/production/001_admin.rb
+1
-0
db/migrate/20111009110913_add_projects_limit_to_user.rb
db/migrate/20111009110913_add_projects_limit_to_user.rb
+5
-0
db/migrate/20111009111204_remove_allow_create_repo_from_user.rb
...rate/20111009111204_remove_allow_create_repo_from_user.rb
+9
-0
db/schema.rb
db/schema.rb
+2
-2
spec/models/user_spec.rb
spec/models/user_spec.rb
+1
-1
No files found.
app/assets/stylesheets/projects.css.scss
View file @
67f0c62d
...
...
@@ -521,3 +521,7 @@ tbody tr:nth-child(2n) td, tbody tr.even td {
width
:
400px
;
}
}
#user_projects_limit
{
width
:
60px
;
}
app/controllers/admin/users_controller.rb
View file @
67f0c62d
...
...
@@ -21,7 +21,7 @@ class Admin::UsersController < ApplicationController
end
def
new
@admin_user
=
User
.
new
@admin_user
=
User
.
new
(
:projects_limit
=>
10
)
respond_to
do
|
format
|
format
.
html
# new.html.erb
...
...
app/models/project.rb
View file @
67f0c62d
...
...
@@ -25,6 +25,8 @@ class Project < ActiveRecord::Base
:uniqueness
=>
true
,
:length
=>
{
:within
=>
3
..
12
}
validate
:check_limit
before_save
:format_code
after_destroy
:destroy_gitosis_project
after_save
:update_gitosis_project
...
...
@@ -126,6 +128,12 @@ class Project < ActiveRecord::Base
path
?
(
tree
/
path
)
:
tree
end
def
check_limit
unless
owner
.
can_create_project?
errors
[
:base
]
<<
(
"You can to have
#{
owner
.
projects_limit
}
your own projects"
)
end
end
def
valid_repo?
repo
rescue
...
...
app/models/user.rb
View file @
67f0c62d
...
...
@@ -5,7 +5,7 @@ class User < ActiveRecord::Base
:recoverable
,
:rememberable
,
:trackable
,
:validatable
# Setup accessible (or protected) attributes for your model
attr_accessible
:email
,
:password
,
:password_confirmation
,
:remember_me
,
:name
attr_accessible
:email
,
:password
,
:password_confirmation
,
:remember_me
,
:name
,
:projects_limit
has_many
:users_projects
,
:dependent
=>
:destroy
has_many
:projects
,
:through
=>
:users_projects
...
...
@@ -29,6 +29,10 @@ class User < ActiveRecord::Base
def
is_admin?
admin
end
def
can_create_project?
projects_limit
>=
my_own_projects
.
count
end
end
# == Schema Information
#
...
...
@@ -49,6 +53,6 @@ end
# updated_at :datetime
# name :string(255)
# admin :boolean default(FALSE), not null
#
allowed_create_repo :boolean default(TRUE), not null
#
projects_limit :integer
#
app/views/admin/users/_form.html.haml
View file @
67f0c62d
...
...
@@ -30,8 +30,8 @@
=
f
.
check_box
:admin
=
f
.
label
:admin
.field.prepend-top
=
f
.
check_box
:allowed_create_repo
,
:disabled
=>
true
=
f
.
label
:
allowed_create_repo
=
f
.
text_field
:projects_limit
,
:class
=>
"small_input"
=
f
.
label
:
projects_limit
.clear
%br
.actions
...
...
app/views/admin/users/show.html.haml
View file @
67f0c62d
...
...
@@ -10,6 +10,9 @@
%p
%b
Admin:
=
@admin_user
.
admin
%p
%b
Projects limit:
=
@admin_user
.
projects_limit
.clear
=
link_to
'Edit'
,
edit_admin_user_path
(
@admin_user
)
...
...
app/views/projects/index.html.haml
View file @
67f0c62d
=
link_to
'New Project'
,
new_project_path
,
:class
=>
"lbutton vm"
-
if
current_user
.
can_create_project?
=
link_to
'New Project'
,
new_project_path
,
:class
=>
"lbutton vm"
%table
.round-borders
#projects-list
%tr
...
...
db/fixtures/development/001_admin.rb
View file @
67f0c62d
...
...
@@ -6,5 +6,6 @@ admin = User.create(
:password_confirmation
=>
"5iveL!fe"
)
admin
.
projects_limit
=
10000
admin
.
admin
=
true
admin
.
save!
db/fixtures/production/001_admin.rb
View file @
67f0c62d
...
...
@@ -5,5 +5,6 @@ admin = User.create(
:password_confirmation
=>
"5iveL!fe"
)
admin
.
projects_limit
=
10000
admin
.
admin
=
true
admin
.
save!
db/migrate/20111009110913_add_projects_limit_to_user.rb
0 → 100644
View file @
67f0c62d
class
AddProjectsLimitToUser
<
ActiveRecord
::
Migration
def
change
add_column
:users
,
:projects_limit
,
:integer
,
:default
=>
10
end
end
db/migrate/20111009111204_remove_allow_create_repo_from_user.rb
0 → 100644
View file @
67f0c62d
class
RemoveAllowCreateRepoFromUser
<
ActiveRecord
::
Migration
def
up
remove_column
:users
,
:allowed_create_repo
end
def
down
add_column
:users
,
:allowed_create_repo
,
:boolean
,
:default
=>
true
,
:null
=>
false
end
end
db/schema.rb
View file @
67f0c62d
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
201110091
01738
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
201110091
11204
)
do
create_table
"issues"
,
:force
=>
true
do
|
t
|
t
.
string
"title"
...
...
@@ -70,7 +70,7 @@ ActiveRecord::Schema.define(:version => 20111009101738) do
t
.
datetime
"updated_at"
t
.
string
"name"
t
.
boolean
"admin"
,
:default
=>
false
,
:null
=>
false
t
.
boolean
"allowed_create_repo"
,
:default
=>
true
,
:null
=>
false
t
.
integer
"projects_limit"
end
add_index
"users"
,
[
"email"
],
:name
=>
"index_users_on_email"
,
:unique
=>
true
...
...
spec/models/user_spec.rb
View file @
67f0c62d
...
...
@@ -38,6 +38,6 @@ end
# updated_at :datetime
# name :string(255)
# admin :boolean default(FALSE), not null
#
allowed_create_repo :boolean default(TRUE), not null
#
projects_limit :integer
#
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment