Added a slot allocation view
authorSverre Rabbelier <srabbelier@gmail.com>
Sat, 07 Mar 2009 00:33:10 +0000
changeset 1705 1dbce30b5757
parent 1704 b581fdfd6bb1
child 1706 9609e2a0d7d7
Added a slot allocation view Patch by: Sverre Rabbelier
app/soc/templates/soc/program/allocation/heading.html
app/soc/templates/soc/program/allocation/row.html
app/soc/views/models/program.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/program/allocation/heading.html	Sat Mar 07 00:33:10 2009 +0000
@@ -0,0 +1,5 @@
+<tr align="left">
+  <th>Name</th>
+  <th>Locked?</th>
+  <th>Slots</th>
+</tr>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/program/allocation/row.html	Sat Mar 07 00:33:10 2009 +0000
@@ -0,0 +1,5 @@
+<tr class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" name="name">
+  <td><div class="name">{{ list.item.name }}</div></td>
+  <td><div class="locked" id="locked_slot_count_{{ list.item.link_id }}">unlocked</div></td>
+  <td><div class="slots" id="id_slot_count_{{ list.item.link_id }}">0</div></td>
+</tr>
--- a/app/soc/views/models/program.py	Sat Mar 07 00:32:15 2009 +0000
+++ b/app/soc/views/models/program.py	Sat Mar 07 00:33:10 2009 +0000
@@ -31,6 +31,7 @@
 from soc.logic.helper import timeline as timeline_helper
 from soc.logic.models import host as host_logic
 from soc.logic.models import mentor as mentor_logic
+from soc.logic.models import organization as org_logic
 from soc.logic.models import org_admin as org_admin_logic
 from soc.logic.models import program as program_logic
 from soc.logic.models import student as student_logic
@@ -39,6 +40,7 @@
 from soc.views import out_of_band
 from soc.views.helper import access
 from soc.views.helper import decorators
+from soc.views.helper import lists
 from soc.views.helper import redirects
 from soc.views.helper import widgets
 from soc.views.models import presence
@@ -84,6 +86,16 @@
     new_params['extra_dynaexclude'] = ['timeline', 'org_admin_agreement',
         'mentor_agreement', 'student_agreement']
 
+    patterns = []
+    patterns += [
+        (r'^%(url_name)s/(?P<access_type>assign_slots)/%(key_fields)s$',
+          'soc.views.models.%(module_name)s.assign_slots',
+          'Assign slots'),
+        ]
+
+    new_params['extra_django_patterns'] = patterns
+
+
     # TODO add clean field to check for uniqueness in link_id and scope_path
     new_params['create_extra_dynaproperties'] = {
         'description': forms.fields.CharField(widget=helper.widgets.TinyMCE(
@@ -134,6 +146,29 @@
 
     super(View, self).__init__(params=params)
 
+  @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.
+    """
+
+    from soc.views.models import organization as organization_view
+    params = organization_view.view.getParams()
+    params['list_heading'] = 'soc/program/allocation/heading.html'
+    params['list_row'] = 'soc/program/allocation/row.html'
+
+    program = program_logic.logic.getFromKeyFields(kwargs)
+
+    filter = {
+        'scope': program,
+        }
+
+    content = lists.getListContent(request, params, filter=filter)
+    contents = [content]
+
+    return self._list(request, params, contents, page_name)
+
   def _editPost(self, request, entity, fields):
     """See base._editPost().
     """
@@ -333,6 +368,7 @@
 view = View()
 
 admin = decorators.view(view.admin)
+assign_slots = decorators.view(view.assignSlots)
 create = decorators.view(view.create)
 delete = decorators.view(view.delete)
 edit = decorators.view(view.edit)