mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-02-12 09:41:18 +00:00
Compare commits
No commits in common. "7ae2b152c62ea180d4668b5aaf26a11914a2c963" and "dee215261698ed0b1327f55269cc94ce257b3782" have entirely different histories.
7ae2b152c6
...
dee2152616
@ -1,46 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
|
|
||||||
from .models import Participation, Phase, Question, Team, Video
|
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Team)
|
|
||||||
class TeamAdmin(admin.ModelAdmin):
|
|
||||||
list_display = ('name', 'trigram', 'problem', 'valid',)
|
|
||||||
search_fields = ('name', 'trigram',)
|
|
||||||
list_filter = ('participation__problem', 'participation__valid',)
|
|
||||||
|
|
||||||
def problem(self, team):
|
|
||||||
return team.participation.get_problem_display()
|
|
||||||
|
|
||||||
problem.short_description = _('problem number')
|
|
||||||
|
|
||||||
def valid(self, team):
|
|
||||||
return team.participation.valid
|
|
||||||
|
|
||||||
valid.short_description = _('valid')
|
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Participation)
|
|
||||||
class ParticipationAdmin(admin.ModelAdmin):
|
|
||||||
list_display = ('team', 'problem', 'valid',)
|
|
||||||
search_fields = ('team__name', 'team__trigram',)
|
|
||||||
list_filter = ('problem', 'valid',)
|
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Video)
|
|
||||||
class VideoAdmin(admin.ModelAdmin):
|
|
||||||
list_display = ('participation', 'link',)
|
|
||||||
search_fields = ('participation__team__name', 'participation__team__trigram', 'link',)
|
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Question)
|
|
||||||
class QuestionAdmin(admin.ModelAdmin):
|
|
||||||
list_display = ('participation', 'question',)
|
|
||||||
search_fields = ('participation__team__name', 'participation__team__trigram', 'question',)
|
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Phase)
|
|
||||||
class PhaseAdmin(admin.ModelAdmin):
|
|
||||||
list_display = ('phase_number', 'start', 'end',)
|
|
||||||
ordering = ('phase_number', 'start',)
|
|
@ -1,11 +1,9 @@
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.contrib.contenttypes.models import ContentType
|
|
||||||
from django.contrib.sites.models import Site
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from registration.models import StudentRegistration
|
from registration.models import StudentRegistration
|
||||||
|
|
||||||
from .models import Participation, Question, Team, Video
|
from .models import Team
|
||||||
|
|
||||||
|
|
||||||
class TestStudentParticipation(TestCase):
|
class TestStudentParticipation(TestCase):
|
||||||
@ -29,72 +27,11 @@ class TestStudentParticipation(TestCase):
|
|||||||
access_code="azerty",
|
access_code="azerty",
|
||||||
grant_animath_access_videos=True,
|
grant_animath_access_videos=True,
|
||||||
)
|
)
|
||||||
self.question = Question.objects.create(participation=self.team.participation,
|
|
||||||
question="Pourquoi l'existence précède l'essence ?")
|
|
||||||
self.client.force_login(self.user)
|
self.client.force_login(self.user)
|
||||||
|
|
||||||
def test_admin_pages(self):
|
# TODO Remove these lines
|
||||||
"""
|
str(self.team)
|
||||||
Load Django-admin pages.
|
str(self.team.participation)
|
||||||
"""
|
|
||||||
superuser = User.objects.create_superuser(
|
|
||||||
username="admin",
|
|
||||||
email="admin@example.com",
|
|
||||||
password="toto1234",
|
|
||||||
)
|
|
||||||
self.client.force_login(superuser)
|
|
||||||
|
|
||||||
# Test team pages
|
|
||||||
response = self.client.get(reverse("admin:index") + "participation/team/")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
response = self.client.get(reverse("admin:index")
|
|
||||||
+ f"participation/team/{self.team.pk}/change/")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
response = self.client.get(reverse("admin:index") +
|
|
||||||
f"r/{ContentType.objects.get_for_model(Team).id}/"
|
|
||||||
f"{self.team.pk}/")
|
|
||||||
self.assertRedirects(response, "http://" + Site.objects.get().domain +
|
|
||||||
str(self.team.get_absolute_url()), 302, 200)
|
|
||||||
|
|
||||||
# Test participation pages
|
|
||||||
self.team.participation.valid = True
|
|
||||||
self.team.participation.save()
|
|
||||||
response = self.client.get(reverse("admin:index") + "participation/participation/")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
response = self.client.get(reverse("admin:index")
|
|
||||||
+ f"participation/participation/{self.team.participation.pk}/change/")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
response = self.client.get(reverse("admin:index") +
|
|
||||||
f"r/{ContentType.objects.get_for_model(Participation).id}/"
|
|
||||||
f"{self.team.participation.pk}/")
|
|
||||||
self.assertRedirects(response, "http://" + Site.objects.get().domain +
|
|
||||||
str(self.team.participation.get_absolute_url()), 302, 200)
|
|
||||||
|
|
||||||
# Test video pages
|
|
||||||
response = self.client.get(reverse("admin:index") + "participation/video/")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
response = self.client.get(reverse("admin:index")
|
|
||||||
+ f"participation/video/{self.team.participation.solution.pk}/change/")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
# Test question pages
|
|
||||||
response = self.client.get(reverse("admin:index") + "participation/question/")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
response = self.client.get(reverse("admin:index")
|
|
||||||
+ f"participation/question/{self.question.pk}/change/")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
# Test phase pages
|
|
||||||
response = self.client.get(reverse("admin:index") + "participation/phase/")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
response = self.client.get(reverse("admin:index")
|
|
||||||
+ f"participation/phase/1/change/")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
|
|
||||||
def test_create_team(self):
|
def test_create_team(self):
|
||||||
"""
|
"""
|
||||||
@ -125,7 +62,6 @@ class TestStudentParticipation(TestCase):
|
|||||||
trigram="TET",
|
trigram="TET",
|
||||||
grant_animath_access_videos=False,
|
grant_animath_access_videos=False,
|
||||||
))
|
))
|
||||||
self.assertEqual(response.status_code, 403)
|
|
||||||
|
|
||||||
def test_join_team(self):
|
def test_join_team(self):
|
||||||
"""
|
"""
|
||||||
|
@ -318,7 +318,7 @@ class TestRegistration(TestCase):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertTrue(response.context["object_list"])
|
self.assertTrue(response.context["object_list"])
|
||||||
|
|
||||||
def test_not_implemented_error(self):
|
def test_string_render(self):
|
||||||
# Only for coverage
|
# TODO These string field tests will be removed when used in a template
|
||||||
self.assertRaises(NotImplementedError, lambda: Registration().type)
|
self.assertRaises(NotImplementedError, lambda: Registration().type)
|
||||||
self.assertRaises(NotImplementedError, lambda: Registration().form_class)
|
self.assertRaises(NotImplementedError, lambda: Registration().form_class)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user