Пример #1
0
def events_home(request):
    user = request.user
    tasks = []
    if Organizer.objects.filter(user=user).exists():
        tasks = calculate_organizer_task(user)
    else:
        if user.is_superuser:
            tasks = calculate_super_user_task()

    return render(request, 'events_home.html', {'tasks': tasks})
Пример #2
0
    def test_calculate_organizer_tasks(
            self, organizer_has_account_data_function,
            organizer_has_complete_personal_data_function,
            not_approved_invoices_function, not_sponsor_category_function,
            incomplete_events_function):
        # Some test that can be do it, are
        # The functions _incomoplete_events, _not_sponsor_category, _not_approved_invoices
        # organizer.has_complete_personal_data and has_account_data are called
        # incomplete_events_function.return_value = [Event.objects.filter(name='MyTest01').first()]
        organizer = Organizer.objects.get(user__username='******')
        tasks = calculate_organizer_task(organizer.user)
        incomplete_events_function.assert_called_once_with(organizer)
        not_sponsor_category_function.assert_called_once_with(organizer, [])
        not_approved_invoices_function.assert_called_once_with(organizer)
        organizer_has_complete_personal_data_function.assert_called_once()
        organizer_has_account_data_function.assert_called_once()

        self.assertEqual(len(tasks), 1)