Skip to content

Commit

Permalink
clearer closed messages (#322)
Browse files Browse the repository at this point in the history
* update closed message on attendee reg

* add to dealers and staff

* fix existing tests

* new tests for index

* add tests to dealers

* add staff tests

* add test to onsite
  • Loading branch information
meanderfox authored Jul 2, 2024
1 parent 5c36b04 commit b2f933f
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 27 deletions.
3 changes: 2 additions & 1 deletion registration/templates/registration/closed.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<div role="tabpanel" class="tab-pane fade in active" id="personal">
<h1>Registration - {{ event }}</h1>
<hr>
<p>Registration for {{ event }} is closed. If you have any questions please contact
<p>Registration for {{ event }} {{ message }}</p>
<p>If you have any questions please contact
<a href="mailto:{{ event.registrationEmail }}">{{ event.registrationEmail }}</a>
</p>
<p style="float:right;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<div role="tabpanel" class="tab-pane fade in active" id="personal">
<h1>Dealer Registration - {{ event }}</h1>
<hr>
<p>Dealer registration for {{ event }} is closed. If you have any questions please contact
<p>Dealer registration for {{ event }} {{ message }}</p>
<p>If you have any questions please contact
<a href='mailto:{{ event.dealerEmail }}'>{{ event.dealerEmail }}</a></p>
<p style='float:right;'><a href='/'>Back to Main Page</a></p>
</div>
Expand Down
3 changes: 2 additions & 1 deletion registration/templates/registration/staff/staff-closed.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<div role="tabpanel" class="tab-pane fade in active" id="personal">
<h1>Staff Registration - {{ event }}</h1>
<hr>
<p>Staff Registration for {{ event }} is closed. If you have any questions please contact
<p>Staff Registration for {{ event }} {{ message }}>/p>
<p>If you have any questions please contact
<a href="mailto:{{ event.staffEmail }}">{{ event.staffEmail }}</a>
</p>
<p style="float:right;">
Expand Down
16 changes: 12 additions & 4 deletions registration/tests/test_dealers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.http import HttpRequest
from django.test import Client, TestCase
from django.urls import reverse
from django.utils import timezone
from datetime import timedelta
from freezegun import freeze_time

from registration.models import Attendee, Dealer, DealerAsst, Event
Expand Down Expand Up @@ -51,13 +53,19 @@ def test_doneDealer(self):
def test_addNewDealer_open(self) -> None:
response = self.client.get(reverse("registration:new_dealer"))
self.assertEqual(response.status_code, 200)
self.assertNotIn(b"closed", response.content)
self.assertNotIn(b"not yet open", response.content)

@freeze_time("2020-01-01")
def test_addNewDealer_closed(self) -> None:
@freeze_time(timezone.now() - timedelta(days=20))
def test_addNewDealer_closed_upcoming(self) -> None:
response = self.client.get(reverse("registration:new_dealer"))
self.assertEqual(response.status_code, 200)
self.assertIn(b"closed", response.content)
self.assertIn(b"not yet open", response.content)

@freeze_time(timezone.now() + timedelta(days=20))
def test_addNewDealer_closed_ended(self) -> None:
response = self.client.get(reverse("registration:new_dealer"))
self.assertEqual(response.status_code, 200)
self.assertIn(b"has ended", response.content)

def test_find_dealer_to_add_assistant(self):
response = self.client.get(
Expand Down
18 changes: 14 additions & 4 deletions registration/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ def TestIndex(self):
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Welcome to the registration system")

def TestIndexClosed(self):
def TestIndexClosedUpcoming(self):
response = self.client.get(reverse("registration:index"))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "is closed. If you have any")
self.assertContains(response, "not yet open")

def TestIndexClosedEnded(self):
response = self.client.get(reverse("registration:index"))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "has ended")

def TestIndexNoEvent(self):
response = self.client.get(reverse("registration:index"))
Expand All @@ -36,9 +41,14 @@ def test_index(self):
self.event = Event(**DEFAULT_EVENT_ARGS)
self.event.save()
self.TestIndex()
self.event.attendeeRegEnd = now - ten_days
self.event.attendeeRegStart = now + one_day
self.event.attendeeRegEnd = now + ten_days
self.event.save()
self.TestIndexClosedUpcoming()
self.event.attendeeRegStart = now - ten_days
self.event.attendeeRegEnd = now - one_day
self.event.save()
self.TestIndexClosed()
self.TestIndexClosedEnded()


class TestTemplateTags(TestCase):
Expand Down
12 changes: 10 additions & 2 deletions registration/tests/test_onsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,21 @@ def test_onsite_open(self):
self.assertEqual(response.context["event"], self.event)
self.assertIn(b"Onsite Registration", response.content)

def test_onsite_closed(self):
def test_onsite_closed_upcoming(self):
self.event.onsiteRegStart = now + one_day
self.event.save()
response = self.client.get(reverse("registration:onsite"))
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context["event"], self.event)
self.assertIn(b"is closed", response.content)
self.assertIn(b"not yet open", response.content)

def test_onsite_closed_ended(self):
self.event.onsiteRegEnd = now - one_day
self.event.save()
response = self.client.get(reverse("registration:onsite"))
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context["event"], self.event)
self.assertIn(b"has ended", response.content)

def test_onsite_checkout_cost(self):
options = [
Expand Down
38 changes: 29 additions & 9 deletions registration/tests/test_staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,24 @@ def test_new_staff_invite_good(self):
content_type="application/json",
)
self.assertEqual(response.status_code, 200)
self.assertNotIn(b"closed", response.content)
self.assertNotIn(b"not yet open", response.content)

@freeze_time("2000-01-01")
def test_new_staff_invite_good_closed(self):
@freeze_time(timezone.now() - timedelta(days=20))
def test_new_staff_invite_good_closed_upcoming(self):
body = {
"email": self.token.email,
"token": self.token.token,
}
response = self.client.post(
reverse("registration:new_staff", args=(self.token.token,)),
json.dumps(body),
content_type="application/json",
)
self.assertEqual(response.status_code, 200)
self.assertIn(b"not yet open", response.content)

@freeze_time(timezone.now() + timedelta(days=20))
def test_new_staff_invite_good_closed_ended(self):
body = {
"email": self.token.email,
"token": self.token.token,
Expand All @@ -132,7 +146,7 @@ def test_new_staff_invite_good_closed(self):
content_type="application/json",
)
self.assertEqual(response.status_code, 200)
self.assertIn(b"closed", response.content)
self.assertIn(b"has ended", response.content)

@freeze_time("2000-01-01")
def test_new_staff_invite_override(self):
Expand All @@ -146,7 +160,7 @@ def test_new_staff_invite_override(self):
content_type="application/json",
)
self.assertEqual(response.status_code, 200)
self.assertNotIn(b"closed", response.content)
self.assertNotIn(b"not yet open", response.content)


class TestFindNewStaff(StaffTestCase):
Expand Down Expand Up @@ -270,13 +284,19 @@ class TestStaffIndex(StaffTestCase):
def test_staff_index(self):
response = self.client.get(reverse("registration:staff", args=("foo",)))
self.assertEqual(response.status_code, 200)
self.assertNotIn(b"closed", response.content)
self.assertNotIn(b"not yet open", response.content)

@freeze_time("2000-01-01")
def test_staff_index_closed(self):
@freeze_time(timezone.now() - timedelta(days=20))
def test_staff_index_closed_upcoming(self):
response = self.client.get(reverse("registration:staff", args=("foo",)))
self.assertEqual(response.status_code, 200)
self.assertIn(b"not yet open", response.content)

@freeze_time(timezone.now() + timedelta(days=20))
def test_staff_index_closed_ended(self):
response = self.client.get(reverse("registration:staff", args=("foo",)))
self.assertEqual(response.status_code, 200)
self.assertIn(b"closed", response.content)
self.assertIn(b"has ended", response.content)

def test_staff_done(self):
response = self.client.get(reverse("registration:staff_done"))
Expand Down
7 changes: 6 additions & 1 deletion registration/views/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,12 @@ def index(request):
context = {"event": event, "discount": discount}
if event.attendeeRegStart <= today <= event.attendeeRegEnd:
return render(request, "registration/registration-form.html", context)
return render(request, "registration/closed.html", context)
elif event.attendeeRegStart >= today:
context["message"] = "is not yet open. Please stay tuned to our social media for updates!"
return render(request, "registration/closed.html", context)
elif event.attendeeRegEnd <= today:
context["message"] = "has ended."
return render(request, "registration/closed.html", context)


@staff_member_required
Expand Down
7 changes: 6 additions & 1 deletion registration/views/dealers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ def new_dealer(request):
context = {"event": event}
if event.dealerRegStart <= today <= event.dealerRegEnd:
return render(request, "registration/dealer/dealer-form.html", context)
return render(request, "registration/dealer/dealer-closed.html", context)
elif event.dealerRegStart >= today:
context["message"] = "is not yet open. Please stay tuned to our social media for updates!"
return render(request, "registration/dealer/dealer-closed.html", context)
elif event.dealerRegEnd <= today:
context["message"] = "has ended."
return render(request, "registration/dealer/dealer-closed.html", context)


def info_dealer(request):
Expand Down
7 changes: 6 additions & 1 deletion registration/views/onsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ def onsite(request):
context = {"event": event, "onsite": True}
if event.onsiteRegStart <= today <= event.onsiteRegEnd:
return render(request, "registration/onsite.html", context)
return render(request, "registration/closed.html", context)
elif event.onsiteRegStart >= today:
context["message"] = "is not yet open. Please stay tuned to our social media for updates!"
return render(request, "registration/closed.html", context)
elif event.onsiteRegEnd <= today:
context["message"] = "has ended."
return render(request, "registration/closed.html", context)


def onsite_cart(request):
Expand Down
14 changes: 12 additions & 2 deletions registration/views/staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ def new_staff(request, guid):
context = {"token": guid, "event": event}
if event.staffRegStart <= today <= event.staffRegEnd or invite.ignore_time_window is True:
return render(request, "registration/staff/staff-new.html", context)
return render(request, "registration/staff/staff-closed.html", context)
elif event.staffRegStart >= today:
context["message"] = "is not yet open. Please stay tuned to slack and email for updates!"
return render(request, "registration/staff/staff-closed.html", context)
elif event.staffRegEnd <= today:
context["message"] = "has ended."
return render(request, "registration/staff/staff-closed.html", context)


@require_POST
Expand Down Expand Up @@ -163,7 +168,12 @@ def staff_index(request, guid):
context = {"token": guid, "event": event}
if event.staffRegStart <= today <= event.staffRegEnd:
return render(request, "registration/staff/staff-locate.html", context)
return render(request, "registration/staff/staff-closed.html", context)
elif event.staffRegStart >= today:
context["message"] = "is not yet open. Please stay tuned to slack and email for updates!"
return render(request, "registration/staff/staff-closed.html", context)
elif event.staffRegEnd <= today:
context["message"] = "has ended."
return render(request, "registration/staff/staff-closed.html", context)


def staff_done(request):
Expand Down

0 comments on commit b2f933f

Please sign in to comment.