Fix Host invites
authorSverre Rabbelier <srabbelier@gmail.com>
Sun, 23 Nov 2008 00:38:35 +0000
changeset 575 ba4a7e90139d
parent 574 b7b77b4c9612
child 576 6614d3f545b7
Fix Host invites This fixes the UI for Host invites by hiding the fields that are not used, and by auto-filling in the user and scope fields based on link_id and scope_path.
app/soc/models/host.py
app/soc/templates/soc/host/list/row.html
app/soc/views/models/host.py
--- a/app/soc/models/host.py	Sat Nov 22 23:34:06 2008 +0000
+++ b/app/soc/models/host.py	Sun Nov 23 00:38:35 2008 +0000
@@ -32,8 +32,4 @@
   """Host details for a specific Program.
   """
 
-  #: A 1:1 relationship associating a Host with specific
-  #: Sponsor details and capabilities. The back-reference in
-  #: the Sponsor model is a Query named 'host'.  
-  sponsor = db.ReferenceProperty(reference_class=soc.models.sponsor.Sponsor,
-                                 required=True, collection_name='hosts')
+  pass
--- a/app/soc/templates/soc/host/list/row.html	Sat Nov 22 23:34:06 2008 +0000
+++ b/app/soc/templates/soc/host/list/row.html	Sun Nov 23 00:38:35 2008 +0000
@@ -1,7 +1,7 @@
 <tr class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" 
 onclick="document.location.href='{{ list.redirect }}'" name="name">
   <td align="right"><div class="user_link_id"><a class="noul"
-         href="{{ list.redirect }}">{{ list.item.user.link_id }}</a>
+         href="{{ list.redirect }}">{{ list.item.link_id }}</a>
      </div>
   </td>
   <td><div class="sponsor_name">{{ list.item.sponsor.name }}</div></td>
--- a/app/soc/views/models/host.py	Sat Nov 22 23:34:06 2008 +0000
+++ b/app/soc/views/models/host.py	Sun Nov 23 00:38:35 2008 +0000
@@ -22,9 +22,12 @@
   ]
 
 
+from django import forms
 from django.utils.translation import ugettext_lazy
 
 from soc.logic import dicts
+from soc.logic.models import user as user_logic
+from soc.logic.models import sponsor as sponsor_logic
 from soc.views import helper
 from soc.views.models import base
 from soc.views.models import role
@@ -47,7 +50,7 @@
     model = soc.models.host.Host
 
     #: list of model fields which will *not* be gathered by the form
-    exclude = ['scope']
+    exclude = ['scope', 'user']
 
   def clean_empty(self, field):
     data = self.cleaned_data.get(field)
@@ -105,6 +108,22 @@
 
     role.RoleView.__init__(self, original_params=params)
 
+  def _editSeed(self, request, seed):
+    """See base.View._editGet().
+    """
+
+  def _editPost(self, request, entity, fields):
+    """See base.View._editPost().
+    """
+
+    user = user_logic.logic.getForFields(
+        {'link_id': fields['link_id']}, unique=True)
+    fields['user'] = user
+
+    sponsor = sponsor_logic.logic.getForFields(
+        {'link_id': fields['scope_path']}, unique=True)
+    fields['scope'] = sponsor
+
 
 view = View()