Commit 8609ecbf authored by Giorgos Korfiatis's avatar Giorgos Korfiatis

astakos: Force a members limit in project applications

parent f6bccb57
......@@ -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
}
......
......@@ -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")
......
......@@ -805,7 +805,7 @@ class ProjectApplicationForm(forms.ModelForm):
label=max_members_label,
help_text=max_members_help,
min_value=0,
required=False)
required=True)
class Meta:
model = ProjectApplication
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment