Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
8609ecbf
Commit
8609ecbf
authored
Aug 28, 2013
by
Giorgos Korfiatis
Browse files
astakos: Force a members limit in project applications
parent
f6bccb57
Changes
4
Hide whitespace changes
Inline
Side-by-side
docs/project-api-guide.rst
View file @
8609ecbf
...
...
@@ -90,7 +90,7 @@ Status Description
"end_date": date,
"join_policy": "auto" | "moderated" | "closed",
"leave_policy": "auto" | "moderated" | "closed",
"max_members":
int or null
"max_members":
natural number
"resources": {"cyclades.vm": {"project_capacity": int or null,
"member_capacity": int
}
...
...
snf-astakos-app/astakos/api/projects.py
View file @
8609ecbf
...
...
@@ -409,8 +409,7 @@ def submit_application(app_data, user, project_id=None):
raise
faults
.
BadRequest
(
"Missing end date"
)
max_members
=
app_data
.
get
(
"max_members"
)
if
max_members
is
not
None
and
\
(
not
isinstance
(
max_members
,
(
int
,
long
))
or
max_members
<
0
):
if
not
isinstance
(
max_members
,
(
int
,
long
))
or
max_members
<
0
:
raise
faults
.
BadRequest
(
"Invalid max_members"
)
homepage
=
_get_maybe_string
(
app_data
,
"homepage"
)
...
...
snf-astakos-app/astakos/im/forms.py
View file @
8609ecbf
...
...
@@ -805,7 +805,7 @@ class ProjectApplicationForm(forms.ModelForm):
label
=
max_members_label
,
help_text
=
max_members_help
,
min_value
=
0
,
required
=
Fals
e
)
required
=
Tru
e
)
class
Meta
:
model
=
ProjectApplication
...
...
snf-astakos-app/astakos/im/tests/projects.py
View file @
8609ecbf
...
...
@@ -162,6 +162,7 @@ class ProjectAPITest(TestCase):
app1
=
{
"name"
:
"test.pr"
,
"end_date"
:
"2013-5-5T20:20:20Z"
,
"join_policy"
:
"auto"
,
"max_members"
:
5
,
"resources"
:
{
"service1.resource11"
:
{
"member_capacity"
:
512
}}
}
...
...
@@ -561,6 +562,11 @@ class ProjectAPITest(TestCase):
status
,
body
=
self
.
create
(
ap
,
h_owner
)
self
.
assertEqual
(
status
,
400
)
ap
[
"name"
]
=
"domain.name"
ap
.
pop
(
"max_members"
)
status
,
body
=
self
.
create
(
ap
,
h_owner
)
self
.
assertEqual
(
status
,
400
)
filters
=
{
"filter"
:
{
"state"
:
"nonex"
}}
req
=
{
"body"
:
json
.
dumps
(
filters
)}
r
=
client
.
get
(
reverse
(
"api_projects"
),
req
,
**
h_owner
)
...
...
@@ -642,6 +648,7 @@ class TestProjects(TestCase):
'end_date'
:
dto
.
strftime
(
"%Y-%m-%d"
),
'member_join_policy'
:
2
,
'member_leave_policy'
:
1
,
'limit_on_members_number'
:
5
,
'service1.resource_uplimit'
:
100
,
'is_selected_service1.resource'
:
"1"
,
'astakos.pending_app_uplimit'
:
100
,
...
...
@@ -682,6 +689,11 @@ class TestProjects(TestCase):
}
r
=
self
.
user_client
.
post
(
post_url
,
data
=
application_data
,
follow
=
True
)
self
.
assertEqual
(
r
.
status_code
,
200
)
self
.
assertEqual
(
r
.
context
[
'form'
].
is_valid
(),
False
)
application_data
[
'limit_on_members_number'
]
=
5
r
=
self
.
user_client
.
post
(
post_url
,
data
=
application_data
,
follow
=
True
)
self
.
assertEqual
(
r
.
status_code
,
200
)
self
.
assertEqual
(
r
.
context
[
'form'
].
is_valid
(),
True
)
# confirm request
...
...
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