Added a slots JSON call
authorSverre Rabbelier <srabbelier@gmail.com>
Sat, 07 Mar 2009 00:33:39 +0000
changeset 1706 9609e2a0d7d7
parent 1705 1dbce30b5757
child 1707 2e7b76f20878
Added a slots JSON call Patch by: Sverre Rabbelier
app/soc/views/models/program.py
--- a/app/soc/views/models/program.py	Sat Mar 07 00:33:10 2009 +0000
+++ b/app/soc/views/models/program.py	Sat Mar 07 00:33:39 2009 +0000
@@ -91,6 +91,9 @@
         (r'^%(url_name)s/(?P<access_type>assign_slots)/%(key_fields)s$',
           'soc.views.models.%(module_name)s.assign_slots',
           'Assign slots'),
+        (r'^%(url_name)s/(?P<access_type>slots)/%(key_fields)s$',
+          'soc.views.models.%(module_name)s.slots',
+          'Assign slots'),
         ]
 
     new_params['extra_django_patterns'] = patterns
@@ -148,6 +151,30 @@
 
   @decorators.merge_params
   @decorators.check_access
+  def slots(self, request, acces_type, page_name=None, params=None, **kwargs):
+    """Returns a JSON object with all orgs allocation.
+
+    Args:
+      request: the standard Django HTTP request object
+      access_type : the name of the access type which should be checked
+      page_name: the page name displayed in templates as page and header title
+      params: a dict with params for this View, not used
+    """
+
+    program = program_logic.logic.getFromKeyFields(kwargs)
+
+    filter = {
+        'scope': program,
+        }
+
+    query = org_logic.logic.getQueryForFields(filter=filter)
+    entities = org_logic.logic.getAll(query)
+    data = [i.toDict() for i in entities]
+
+    return self.json(request, data)
+
+  @decorators.merge_params
+  @decorators.check_access
   def assignSlots(self, request, access_type, page_name=None,
            params=None, **kwargs):
     """View that allows to assign slots to orgs.
@@ -375,5 +402,6 @@
 list = decorators.view(view.list)
 public = decorators.view(view.public)
 export = decorators.view(view.export)
+slots = decorators.view(view.slots)
 home = decorators.view(view.home)
 pick = decorators.view(view.pick)