Skip to content

Commit

Permalink
The "Offer Talk" form now displays
Browse files Browse the repository at this point in the history
  • Loading branch information
James Polley committed May 29, 2012
1 parent d5ed558 commit d5cec76
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
5 changes: 4 additions & 1 deletion doc/hitlist.rst
Expand Up @@ -162,14 +162,17 @@ Anonymous user clicks "offers a talk"

.. py:currentmodule:: usergroup.selenium_tests.talk_offer_test
Done in func:`TestOffer.test_anonymous_user_clicks_offer_talk`
Done in func:`TestAnonymousUserClicksOffer.test_anonymous_user_clicks_offer_talk`

Logged-in user offers a talk
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* Browse the main page as a logged-in user
* Click "Offer Talk"
* A second window opens with the "Offer Talk" form

Done in func:`TestLoggedInUserClicksLogin.test_logged_in_user_clicks_offer_talk`

* Enter values into all fields
* Submit the form
* Verify that the window has redirected to "/offer/add#prevoffers"
Expand Down
26 changes: 26 additions & 0 deletions usergroup/django_tests/talk_offer_test.py
@@ -0,0 +1,26 @@
#!/usr/bin/env python
"""Tests around creating, publishing, and announcing meetings.
Does not use selenium, so cannot test client behaviour."""

import datetime
import random

import django.test

import usergroup.event_edit

#TestCases have lots of public methods
#pylint: disable=R0904

class TestTalkOfferLogin(django.test.TestCase):
"""Before we test anything else, let's see if login actually works"""
fixtures = ['test_admin_user', 'test_existing_user']

def test_offer_page(self):
"""Ensure that the offer page loads."""
self.client.login(username='existing', password='password')
offer_page = self.client.get("/offer/add")
self.assertContains(offer_page, 'input name="consent"')


14 changes: 5 additions & 9 deletions usergroup/offer_edit.py
Expand Up @@ -24,32 +24,28 @@

@auth.login_required
@method.require_http_methods(["GET", "POST"])
def handler(request):
def handler(request, key):
"""Handler for creating and editing Event objects."""

q = models.TalkOffer.objects.all()
if not request.user.is_staff():
if not request.user.is_staff:
q = q.filter(created_by__exact=request.user)
offers = q[:100]

# /offer/<key> (POST/Get)
# /offer/add (POST/Get)
try:
unused_offer, key = request.path_info.split('/')
except IndexError:
return shortcuts.redirect('/offers')

if key == 'add':
offer = models.Offer()
offer = models.TalkOffer()
else:
offer = shortcuts.get_object_or_404(models.TalkOffer, pk=key)

if request.method == 'GET':
offer_list = q[:100]

return shortcut.render(
return shortcuts.render(request,
'offertalk.html', {
'offer': offer, 'offer_list': offers, 'self': self})
'offer': offer, 'offer_list': offers})
elif request.method == 'POST':
return handler_edit(request, offer, offers)

Expand Down

0 comments on commit d5cec76

Please sign in to comment.