Permalink
Browse files

Implement join community in UX2. Fix bug where status_message is not …

…preserved across redirect after form is submitted.
  • Loading branch information...
1 parent b1df906 commit 764e80bf999c997fc7f3931f3a8de3600e82a63c @chrisrossi chrisrossi committed Apr 9, 2012
Showing with 50 additions and 1 deletion.
  1. +32 −0 karl/ux2/templates/join_community.pt
  2. +7 −1 karl/views/community.py
  3. +11 −0 karl/views/tests/test_community.py
@@ -0,0 +1,32 @@
+<div xmlns="http://www.w3.org/1999/xhtml" xmlns:tal="http://xml.zope.org/namespaces/tal"
+ xmlns:metal="http://xml.zope.org/namespaces/metal"
+ metal:use-macro="main_template">
+
+ <div metal:fill-slot="content">
+
+ <header>
+ <h1>${layout.page_title}</h1>
+ </header>
+
+ <p>Type a message to the moderators of this community, below. Your
+ request to join the ${community.title} community will be sent to the
+ community's moderators.</p>
+
+ <form method="post" action="${post_url}" class="k3_genericForm"
+ id="contentform" name="save">
+ <fieldset>
+ <label>Message</label>
+ <textarea id="message" name="message" rows="5" cols="60"></textarea>
+ </fieldset>
+
+ <fieldset>
+ <div>
+ <button id="form-submit" name="form.submitted" value="submit" type="submit">submit</button>
+ <button id="form-cancel" name="form.cancel" value="cancel" type="submit">cancel</button>
+ </div>
+ </fieldset>
+
+ </form>
+ </div>
+
+</div>
View
@@ -89,7 +89,13 @@ def redirect_community_view(context, request):
default_tool = getattr(context, 'default_tool', None)
if not default_tool:
default_tool = 'view.html'
- return HTTPFound(location=resource_url(context, request, default_tool))
+ # Preserve status_message=, etc in query string
+ query = request.GET
+ if query:
+ location = resource_url(context, request, default_tool, query=query)
+ else:
+ location = resource_url(context, request, default_tool)
+ return HTTPFound(location=location)
def show_community_view(context, request):
assert ICommunity.providedBy(context), str(type(context))
@@ -43,6 +43,17 @@ def test_it(self):
response = self._callFUT(context, request)
self.assertEqual(response.location, 'http://example.com/murg')
+ def test_it_with_query(self):
+ from karl.models.interfaces import ICommunity
+ from zope.interface import directlyProvides
+ context = testing.DummyModel()
+ directlyProvides(context, ICommunity)
+ context.default_tool = 'murg'
+ request = testing.DummyRequest(GET={'status': 'married'})
+ response = self._callFUT(context, request)
+ self.assertEqual(response.location,
+ 'http://example.com/murg?status=married')
+
def test_it_notool(self):
from karl.models.interfaces import ICommunity
from zope.interface import directlyProvides

0 comments on commit 764e80b

Please sign in to comment.