...
 
Commits (2)
from random import random
from django.shortcuts import get_object_or_404, render
from django.utils import timezone
from partners.models import Partner, Vacancy, VacancyCategory
......@@ -37,8 +36,7 @@ def partner(request, slug):
def vacancies(request):
"""View to show vacancies."""
context = {
'vacancies': Vacancy.objects.exclude(
expiration_date__lte=timezone.now().date()).order_by('?'),
'vacancies': Vacancy.objects.order_by('?'),
'categories': VacancyCategory.objects.all(),
}
......
......@@ -491,7 +491,8 @@ class BaseRegistrationFormViewTest(TestCase):
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse('registrations:renew'))
def test_form_valid(self):
@mock.patch('registrations.emails.send_registration_email_confirmation')
def test_form_valid(self, send_mail):
mock_form = MagicMock()
return_value = self.view.form_valid(mock_form)
......@@ -501,6 +502,8 @@ class BaseRegistrationFormViewTest(TestCase):
self.assertEqual(return_value.url,
reverse('registrations:register-success'))
send_mail.assert_called_once_with(mock_form.instance)
class MemberRegistrationFormViewTest(TestCase):
......@@ -523,22 +526,6 @@ class MemberRegistrationFormViewTest(TestCase):
self.assertEqual(request.POST['language'], 'nl')
self.assertEqual(request.POST['membership_type'], Membership.MEMBER)
@mock.patch('registrations.emails.send_registration_email_confirmation')
def test_form_valid(self, send_email):
mock_form = MagicMock()
mock_form.instance = {
'hello': 'world'
}
return_value = self.view.form_valid(mock_form)
mock_form.save.assert_called_once_with()
self.assertEqual(return_value.status_code, 302)
self.assertEqual(return_value.url,
reverse('registrations:register-success'))
send_email.assert_called_once_with(mock_form.instance)
class BenefactorRegistrationFormViewTest(TestCase):
......
......@@ -141,6 +141,7 @@ class BaseRegistrationFormView(FormView):
def form_valid(self, form):
form.save()
emails.send_registration_email_confirmation(form.instance)
return redirect('registrations:register-success')
......@@ -157,11 +158,6 @@ class MemberRegistrationFormView(BaseRegistrationFormView):
request.POST['membership_type'] = Membership.MEMBER
return super().post(request, *args, **kwargs)
def form_valid(self, form):
response = super().form_valid(form)
emails.send_registration_email_confirmation(form.instance)
return response
class BenefactorRegistrationFormView(BaseRegistrationFormView):
"""
......