Commit 2bad98dc authored by Kostas Papadimitriou's avatar Kostas Papadimitriou

Explicit groups/resources order

parent 9728237f
......@@ -64,7 +64,8 @@ from astakos.im.settings import (
RECAPTCHA_ENABLED, DEFAULT_CONTACT_EMAIL, LOGGING_LEVEL,
PASSWORD_RESET_EMAIL_SUBJECT, NEWPASSWD_INVALIDATE_TOKEN,
MODERATION_ENABLED, PROJECT_MEMBER_JOIN_POLICIES,
PROJECT_MEMBER_LEAVE_POLICIES, EMAILCHANGE_ENABLED)
PROJECT_MEMBER_LEAVE_POLICIES, EMAILCHANGE_ENABLED,
RESOURCES_PRESENTATION_DATA)
from astakos.im.widgets import DummyWidget, RecaptchaWidget
from astakos.im.functions import (
send_change_email, submit_application, accept_membership_checks)
......@@ -858,6 +859,8 @@ class ProjectApplicationForm(forms.ModelForm):
d.update(dict(service=s, resource=r, uplimit=None))
append(d)
ordered_keys = RESOURCES_PRESENTATION_DATA['resources_order']
policies = sorted(policies, key=lambda r:ordered_keys.index(r['str_repr']))
return policies
def save(self, commit=True):
......
......@@ -299,7 +299,12 @@ RESOURCES_PRESENTATION_DATA = getattr(
'verbose_name':'private network'
}
}
},
'groups_order': ['storage', 'compute', 'network'],
'resources_order': ['pithos+.diskspace', 'cyclades.disk',
'cyclades.cpu', 'cyclades.ram', 'cyclades.vm',
'cyclades.network.private']
})
......
......@@ -1045,8 +1045,18 @@ def project_add(request):
)
else:
resource_catalog = [
(g, filter(lambda r: r.get('group', '') == g, result.data)) \
[g, filter(lambda r: r.get('group', '') == g, result.data)] \
for g in resource_groups]
# order resources
groups_order = RESOURCES_PRESENTATION_DATA.get('groups_order')
resources_order = RESOURCES_PRESENTATION_DATA.get('resources_order')
resource_catalog = sorted(resource_catalog, lambda g,rs:groups_order.index(g[0]))
for index, group in enumerate(resource_catalog):
resource_catalog[index][1] = sorted(resource_catalog[index][1],
key=lambda r: resources_order.index(r['str_repr']))
extra_context = {
'resource_catalog':resource_catalog,
'resource_groups':resource_groups,
......
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