Fixed the 'New Host' link
authorSverre Rabbelier <srabbelier@gmail.com>
Tue, 02 Dec 2008 22:05:13 +0000
changeset 654 68bafa9f719f
parent 653 5105939d3bb4
child 655 9635cbaa2dcd
Fixed the 'New Host' link Also removed the 'Invite Host' button from the Sponsor view now that the link is working. Patch by: Sverre Rabbelier
app/soc/templates/soc/sponsor/edit.html
app/soc/views/helper/redirects.py
app/soc/views/models/role.py
app/soc/views/models/sponsor.py
--- a/app/soc/templates/soc/sponsor/edit.html	Tue Dec 02 22:04:38 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-{% extends "soc/models/edit.html" %}
-{% comment %}
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-{% endcomment %}
-
-{% block submit_buttons %}
-{{ block.super }}
-<td>
- <input type="button" onclick="location.href='/host/invite/{{ entity.link_id }}'" value="Invite Host"/>
-</td>
-{% endblock %}
--- a/app/soc/views/helper/redirects.py	Tue Dec 02 22:04:38 2008 +0000
+++ b/app/soc/views/helper/redirects.py	Tue Dec 02 22:05:13 2008 +0000
@@ -31,6 +31,15 @@
   
   return result
 
+def getInviteRedirect(entity, params):
+  """
+  """
+
+  result ='/%s/invite/%s' % (
+     params['url_name'], entity.link_id)
+
+  return result
+
 def getCreateRedirect(entity, params):
   """Returns the create program redirect for the specified entity.
   """
--- a/app/soc/views/models/role.py	Tue Dec 02 22:04:38 2008 +0000
+++ b/app/soc/views/models/role.py	Tue Dec 02 22:05:13 2008 +0000
@@ -33,6 +33,7 @@
 from soc.views.helper import redirects
 from soc.views.models import base
 from soc.views.models import user as user_view
+from soc.views.models import sponsor as sponsor_view
 
 import soc.models.request
 import soc.views.helper.lists
@@ -81,6 +82,25 @@
 
     base.View.__init__(self, params=params)
 
+  def create(self, request, **kwargs):
+    """Specialized create view to enforce needing a scope_path
+
+    This view simply gives control to the base.View.create if the
+    scope_path is specified in kwargs. If it is not present, it
+    instead displays the result of self.select. Refer to the
+    respective docstrings on what they do.
+
+    Args:
+      see base.View.create
+    """
+
+    if 'scope_path' in kwargs:
+      return super(View, self).create(request, **kwargs)
+
+    view = sponsor_view.view
+    redirect = redirects.getInviteRedirect
+    return self.select(request, view, redirect, **kwargs)
+
   def invite(self, request, page_name=None, params=None, **kwargs):
     """Displays the request promotion to Role page.
     """
--- a/app/soc/views/models/sponsor.py	Tue Dec 02 22:04:38 2008 +0000
+++ b/app/soc/views/models/sponsor.py	Tue Dec 02 22:05:13 2008 +0000
@@ -70,7 +70,6 @@
         }
 
     # TODO(tlarsen): Add support for Django style template lookup
-    params['edit_template'] = 'soc/sponsor/edit.html'
     params['public_template'] = 'soc/group/public.html'
 
     params['list_row'] = 'soc/group/list/row.html'