wbcore 1.59.5__py2.py3-none-any.whl → 1.59.6__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wbcore/cache/registry.py +1 -1
- wbcore/configs/__init__.py +0 -1
- wbcore/configs/configs.py +0 -5
- wbcore/configurations/configurations/wbcore.py +0 -2
- wbcore/contrib/agenda/factories/calendar_item.py +1 -0
- wbcore/contrib/authentication/factories/users.py +1 -0
- wbcore/contrib/directory/factories/entries.py +1 -0
- wbcore/contrib/directory/migrations/0014_alter_entry_relationship_managers_and_more.py +28 -0
- wbcore/contrib/example_app/factories/person.py +1 -0
- wbcore/contrib/example_app/factories/team.py +1 -0
- wbcore/contrib/example_app/models.py +7 -6
- wbcore/contrib/example_app/tests/e2e/test_league.py +2 -2
- wbcore/contrib/example_app/tests/e2e/test_person.py +1 -1
- wbcore/contrib/example_app/tests/e2e/test_teams.py +1 -1
- wbcore/contrib/example_app/tests/test_filters.py +13 -13
- wbcore/contrib/example_app/tests/test_models/test_event.py +15 -13
- wbcore/contrib/example_app/tests/test_models/test_match.py +23 -23
- wbcore/contrib/example_app/tests/test_models/test_others.py +20 -18
- wbcore/contrib/example_app/tests/test_serializers/test_league_serializer.py +4 -4
- wbcore/contrib/example_app/tests/test_serializers/test_match_serializer.py +9 -4
- wbcore/contrib/example_app/tests/test_serializers/test_team_result_serializer.py +3 -3
- wbcore/contrib/example_app/tests/test_serializers/test_team_serializer.py +10 -10
- wbcore/contrib/example_app/tests/test_utils.py +8 -8
- wbcore/contrib/example_app/tests/test_viewsets/test_event_viewset.py +167 -162
- wbcore/contrib/example_app/tests/test_viewsets/test_league_viewset.py +9 -9
- wbcore/contrib/example_app/tests/test_viewsets/test_match_viewset.py +8 -8
- wbcore/contrib/example_app/tests/test_viewsets/test_person_viewset.py +16 -16
- wbcore/contrib/example_app/tests/test_viewsets/test_role_viewset.py +9 -9
- wbcore/contrib/example_app/tests/test_viewsets/test_sport_viewset.py +9 -9
- wbcore/contrib/example_app/tests/test_viewsets/test_stadium_viewset.py +9 -9
- wbcore/contrib/example_app/tests/test_viewsets/test_team_viewset.py +12 -12
- wbcore/contrib/example_app/tests/test_viewsets/test_teamresult_viewset.py +6 -6
- wbcore/contrib/geography/migrations/0002_geography_geography_geography_tree_i739a.py +17 -0
- wbcore/contrib/guardian/tests/test_utils.py +1 -1
- wbcore/contrib/guardian/utils.py +1 -1
- wbcore/contrib/icons/icons.py +2 -2
- wbcore/contrib/io/factories.py +2 -0
- wbcore/contrib/io/models.py +3 -3
- wbcore/contrib/io/viewsets.py +2 -2
- wbcore/contrib/tags/factories.py +1 -0
- wbcore/contrib/workflow/factories/step.py +1 -0
- wbcore/contrib/workflow/models/step.py +1 -1
- wbcore/docs/__init__.py +0 -2
- wbcore/filters/mixins.py +2 -2
- wbcore/markdown/views.py +0 -17
- wbcore/metadata/configs/buttons/__init__.py +1 -1
- wbcore/metadata/configs/buttons/bases.py +1 -6
- wbcore/metadata/configs/buttons/buttons.py +1 -7
- wbcore/metadata/configs/buttons/enums.py +0 -7
- wbcore/metadata/tests/test_buttons.py +1 -13
- wbcore/serializers/fields/fields.py +4 -2
- wbcore/serializers/fields/types.py +1 -0
- wbcore/test/tests.py +1 -1
- wbcore/tests/test_configs.py +0 -5
- wbcore/urls.py +0 -2
- wbcore/utils/figures.py +4 -8
- {wbcore-1.59.5.dist-info → wbcore-1.59.6.dist-info}/METADATA +26 -27
- {wbcore-1.59.5.dist-info → wbcore-1.59.6.dist-info}/RECORD +59 -57
- {wbcore-1.59.5.dist-info → wbcore-1.59.6.dist-info}/WHEEL +0 -0
|
@@ -29,7 +29,7 @@ from wbcore.contrib.example_app.viewsets import (
|
|
|
29
29
|
@pytest.mark.django_db
|
|
30
30
|
class TestSportPersonModelViewSet(TestCase):
|
|
31
31
|
def setUp(self):
|
|
32
|
-
self.user = SuperUserFactory()
|
|
32
|
+
self.user = SuperUserFactory.create()
|
|
33
33
|
self.client = Client()
|
|
34
34
|
self.client.force_login(user=self.user)
|
|
35
35
|
self.list_url = reverse("example_app:person-list")
|
|
@@ -40,19 +40,19 @@ class TestSportPersonModelViewSet(TestCase):
|
|
|
40
40
|
self.assertEqual(response.status_code, 200)
|
|
41
41
|
|
|
42
42
|
def test_create_view(self):
|
|
43
|
-
person = SportPersonFactory()
|
|
43
|
+
person = SportPersonFactory.create()
|
|
44
44
|
response = get_create_view(self.client, person, self.user, self.list_url, SportPersonModelViewSet)
|
|
45
45
|
self.assertEqual(response.status_code, 201)
|
|
46
46
|
self.assertTrue(SportPerson.objects.filter(last_name=person.last_name).exists())
|
|
47
47
|
|
|
48
48
|
def test_detail_view(self):
|
|
49
|
-
instance = SportPersonFactory()
|
|
49
|
+
instance = SportPersonFactory.create()
|
|
50
50
|
response = get_detail_view(self.client, instance.pk, self.detail_url_str)
|
|
51
51
|
self.assertEqual(response.status_code, 200)
|
|
52
52
|
self.assertEqual(response.data["instance"]["last_name"], instance.last_name)
|
|
53
53
|
|
|
54
54
|
def test_update_view(self):
|
|
55
|
-
instance = SportPersonFactory()
|
|
55
|
+
instance = SportPersonFactory.create()
|
|
56
56
|
instance.last_name = "Updated Instance"
|
|
57
57
|
instance.profile_image = None
|
|
58
58
|
response = get_update_view(self.client, instance, SportPersonModelSerializer, self.detail_url_str)
|
|
@@ -61,22 +61,22 @@ class TestSportPersonModelViewSet(TestCase):
|
|
|
61
61
|
self.assertEqual(response.data["instance"]["last_name"], instance.last_name)
|
|
62
62
|
|
|
63
63
|
def test_partial_update_view(self):
|
|
64
|
-
instance = SportPersonFactory()
|
|
64
|
+
instance = SportPersonFactory.create()
|
|
65
65
|
response = get_partial_view(self.client, instance.id, {"last_name": "Updated Instance"}, self.detail_url_str)
|
|
66
66
|
instance.refresh_from_db()
|
|
67
67
|
self.assertEqual(response.status_code, 200)
|
|
68
68
|
self.assertEqual(response.data["instance"]["last_name"], instance.last_name)
|
|
69
69
|
|
|
70
70
|
def test_delete_view(self):
|
|
71
|
-
instance = SportPersonFactory()
|
|
71
|
+
instance = SportPersonFactory.create()
|
|
72
72
|
response = get_delete_view(self.client, self.detail_url_str, instance.pk)
|
|
73
73
|
self.assertEqual(response.status_code, 204)
|
|
74
74
|
self.assertFalse(SportPerson.objects.filter(pk=instance.pk).exists())
|
|
75
75
|
|
|
76
76
|
def test_ordering_fields(self):
|
|
77
|
-
person_a = SportPersonFactory(first_name="Hans", last_name="Brecht")
|
|
78
|
-
person_b = SportPersonFactory(first_name="Hans", last_name="Ahrens")
|
|
79
|
-
person_c = SportPersonFactory(first_name="Ralf", last_name="Christ")
|
|
77
|
+
person_a = SportPersonFactory.create(first_name="Hans", last_name="Brecht")
|
|
78
|
+
person_b = SportPersonFactory.create(first_name="Hans", last_name="Ahrens")
|
|
79
|
+
person_c = SportPersonFactory.create(first_name="Ralf", last_name="Christ")
|
|
80
80
|
|
|
81
81
|
response = self.client.get(self.list_url)
|
|
82
82
|
self.assertEqual(response.status_code, 200)
|
|
@@ -89,7 +89,7 @@ class TestSportPersonModelViewSet(TestCase):
|
|
|
89
89
|
@pytest.mark.django_db
|
|
90
90
|
class TestPlayerModelViewSet(TestCase):
|
|
91
91
|
def setUp(self):
|
|
92
|
-
self.user = SuperUserFactory()
|
|
92
|
+
self.user = SuperUserFactory.create()
|
|
93
93
|
self.client = Client()
|
|
94
94
|
self.client.force_login(user=self.user)
|
|
95
95
|
self.detail_url_str = "example_app:player-detail"
|
|
@@ -100,19 +100,19 @@ class TestPlayerModelViewSet(TestCase):
|
|
|
100
100
|
self.assertEqual(response.status_code, 200)
|
|
101
101
|
|
|
102
102
|
def test_create_view(self):
|
|
103
|
-
player = PlayerFactory()
|
|
103
|
+
player = PlayerFactory.create()
|
|
104
104
|
response = get_create_view(self.client, player, self.user, self.list_url, PlayerModelViewSet)
|
|
105
105
|
self.assertEqual(response.status_code, 201)
|
|
106
106
|
self.assertTrue(Player.objects.filter(last_name=player.last_name).exists())
|
|
107
107
|
|
|
108
108
|
def test_detail_view(self):
|
|
109
|
-
instance = PlayerFactory()
|
|
109
|
+
instance = PlayerFactory.create()
|
|
110
110
|
response = get_detail_view(self.client, instance.pk, self.detail_url_str)
|
|
111
111
|
self.assertEqual(response.status_code, 200)
|
|
112
112
|
self.assertEqual(response.data["instance"]["last_name"], instance.last_name)
|
|
113
113
|
|
|
114
114
|
def test_update_view(self):
|
|
115
|
-
instance = PlayerFactory()
|
|
115
|
+
instance = PlayerFactory.create()
|
|
116
116
|
instance.last_name = "Updated Instance"
|
|
117
117
|
response = get_update_view(self.client, instance, PlayerModelSerializer, self.detail_url_str)
|
|
118
118
|
instance.refresh_from_db()
|
|
@@ -120,20 +120,20 @@ class TestPlayerModelViewSet(TestCase):
|
|
|
120
120
|
self.assertEqual(response.data["instance"]["last_name"], instance.last_name)
|
|
121
121
|
|
|
122
122
|
def test_partial_update_view(self):
|
|
123
|
-
instance = PlayerFactory()
|
|
123
|
+
instance = PlayerFactory.create()
|
|
124
124
|
response = get_partial_view(self.client, instance.id, {"last_name": "Updated Instance"}, self.detail_url_str)
|
|
125
125
|
instance.refresh_from_db()
|
|
126
126
|
self.assertEqual(response.status_code, 200)
|
|
127
127
|
self.assertEqual(response.data["instance"]["last_name"], instance.last_name)
|
|
128
128
|
|
|
129
129
|
def test_delete_view(self):
|
|
130
|
-
instance = PlayerFactory()
|
|
130
|
+
instance = PlayerFactory.create()
|
|
131
131
|
response = get_delete_view(self.client, self.detail_url_str, instance.pk)
|
|
132
132
|
self.assertEqual(response.status_code, 204)
|
|
133
133
|
self.assertFalse(Player.objects.filter(pk=instance.pk).exists())
|
|
134
134
|
|
|
135
135
|
def test_ordering_fields(self):
|
|
136
|
-
team_a, team_b = TeamFactory(name="Team A"), TeamFactory(name="Team B")
|
|
136
|
+
team_a, team_b = TeamFactory.create(name="Team A"), TeamFactory(name="Team B")
|
|
137
137
|
person_a = PlayerFactory(first_name="Hans", last_name="Ahrens", current_team=team_b)
|
|
138
138
|
person_b = PlayerFactory(first_name="Hans", last_name="Ahrens", current_team=team_a)
|
|
139
139
|
person_c = PlayerFactory(first_name="Ralf", last_name="Brecht")
|
|
@@ -18,7 +18,7 @@ from wbcore.contrib.example_app.viewsets import RoleModelViewSet
|
|
|
18
18
|
@pytest.mark.django_db
|
|
19
19
|
class TestRoleModelViewSet(TestCase):
|
|
20
20
|
def setUp(self):
|
|
21
|
-
self.user = SuperUserFactory()
|
|
21
|
+
self.user = SuperUserFactory.create()
|
|
22
22
|
self.client = Client()
|
|
23
23
|
self.client.force_login(user=self.user)
|
|
24
24
|
self.list_url = reverse("example_app:role-list")
|
|
@@ -29,19 +29,19 @@ class TestRoleModelViewSet(TestCase):
|
|
|
29
29
|
self.assertEqual(response.status_code, 200)
|
|
30
30
|
|
|
31
31
|
def test_create_view(self):
|
|
32
|
-
role = RoleFactory()
|
|
32
|
+
role = RoleFactory.create()
|
|
33
33
|
response = get_create_view(self.client, role, self.user, self.list_url, RoleModelViewSet)
|
|
34
34
|
self.assertEqual(response.status_code, 201)
|
|
35
35
|
self.assertTrue(Role.objects.filter(title=role.title).exists())
|
|
36
36
|
|
|
37
37
|
def test_detail_view(self):
|
|
38
|
-
instance = RoleFactory()
|
|
38
|
+
instance = RoleFactory.create()
|
|
39
39
|
response = get_detail_view(self.client, instance.pk, self.detail_url_str)
|
|
40
40
|
self.assertEqual(response.status_code, 200)
|
|
41
41
|
self.assertEqual(response.data["instance"]["title"], instance.title)
|
|
42
42
|
|
|
43
43
|
def test_update_view(self):
|
|
44
|
-
instance = RoleFactory()
|
|
44
|
+
instance = RoleFactory.create()
|
|
45
45
|
instance.title = "Updated Instance"
|
|
46
46
|
response = get_update_view(self.client, instance, RoleModelSerializer, self.detail_url_str)
|
|
47
47
|
instance.refresh_from_db()
|
|
@@ -49,23 +49,23 @@ class TestRoleModelViewSet(TestCase):
|
|
|
49
49
|
self.assertEqual(response.data["instance"]["title"], instance.title)
|
|
50
50
|
|
|
51
51
|
def test_partial_update_view(self):
|
|
52
|
-
instance = RoleFactory()
|
|
52
|
+
instance = RoleFactory.create()
|
|
53
53
|
response = get_partial_view(self.client, instance.id, {"title": "Patched Title"}, self.detail_url_str)
|
|
54
54
|
instance.refresh_from_db()
|
|
55
55
|
self.assertEqual(response.status_code, 200)
|
|
56
56
|
self.assertEqual(response.data["instance"]["title"], instance.title)
|
|
57
57
|
|
|
58
58
|
def test_delete_view(self):
|
|
59
|
-
instance = RoleFactory()
|
|
59
|
+
instance = RoleFactory.create()
|
|
60
60
|
response = get_delete_view(self.client, self.detail_url_str, instance.pk)
|
|
61
61
|
self.assertEqual(response.status_code, 204)
|
|
62
62
|
self.assertFalse(Role.objects.filter(pk=instance.pk).exists())
|
|
63
63
|
|
|
64
64
|
def test_ordering_fields(self):
|
|
65
65
|
first_role, second_role, third_role = "Role A", "Role B", "Role C"
|
|
66
|
-
RoleFactory(title=second_role)
|
|
67
|
-
RoleFactory(title=first_role)
|
|
68
|
-
RoleFactory(title=third_role)
|
|
66
|
+
RoleFactory.create(title=second_role)
|
|
67
|
+
RoleFactory.create(title=first_role)
|
|
68
|
+
RoleFactory.create(title=third_role)
|
|
69
69
|
|
|
70
70
|
response = self.client.get(self.list_url)
|
|
71
71
|
self.assertEqual(response.status_code, 200)
|
|
@@ -18,7 +18,7 @@ from wbcore.contrib.example_app.viewsets import SportModelViewSet
|
|
|
18
18
|
@pytest.mark.django_db
|
|
19
19
|
class TestSportModelViewSet(TestCase):
|
|
20
20
|
def setUp(self):
|
|
21
|
-
self.user = SuperUserFactory()
|
|
21
|
+
self.user = SuperUserFactory.create()
|
|
22
22
|
self.client = Client()
|
|
23
23
|
self.client.force_login(user=self.user)
|
|
24
24
|
self.list_url = reverse("example_app:sport-list")
|
|
@@ -29,19 +29,19 @@ class TestSportModelViewSet(TestCase):
|
|
|
29
29
|
self.assertEqual(response.status_code, 200)
|
|
30
30
|
|
|
31
31
|
def test_create_view(self):
|
|
32
|
-
sport = SportFactory()
|
|
32
|
+
sport = SportFactory.create()
|
|
33
33
|
response = get_create_view(self.client, sport, self.user, self.list_url, SportModelViewSet)
|
|
34
34
|
self.assertEqual(response.status_code, 201)
|
|
35
35
|
self.assertTrue(Sport.objects.filter(name=sport.name).exists())
|
|
36
36
|
|
|
37
37
|
def test_detail_view(self):
|
|
38
|
-
instance = SportFactory()
|
|
38
|
+
instance = SportFactory.create()
|
|
39
39
|
response = get_detail_view(self.client, instance.pk, self.detail_url_str)
|
|
40
40
|
self.assertEqual(response.status_code, 200)
|
|
41
41
|
self.assertEqual(response.data["instance"]["name"], instance.name)
|
|
42
42
|
|
|
43
43
|
def test_update_view(self):
|
|
44
|
-
instance = SportFactory()
|
|
44
|
+
instance = SportFactory.create()
|
|
45
45
|
instance.name = "Updated Instance"
|
|
46
46
|
response = get_update_view(self.client, instance, SportModelSerializer, self.detail_url_str)
|
|
47
47
|
instance.refresh_from_db()
|
|
@@ -49,23 +49,23 @@ class TestSportModelViewSet(TestCase):
|
|
|
49
49
|
self.assertEqual(response.data["instance"]["name"], instance.name)
|
|
50
50
|
|
|
51
51
|
def test_partial_update_view(self):
|
|
52
|
-
instance = SportFactory()
|
|
52
|
+
instance = SportFactory.create()
|
|
53
53
|
response = get_partial_view(self.client, instance.id, {"name": "Patched name"}, self.detail_url_str)
|
|
54
54
|
instance.refresh_from_db()
|
|
55
55
|
self.assertEqual(response.status_code, 200)
|
|
56
56
|
self.assertEqual(response.data["instance"]["name"], instance.name)
|
|
57
57
|
|
|
58
58
|
def test_delete_view(self):
|
|
59
|
-
instance = SportFactory()
|
|
59
|
+
instance = SportFactory.create()
|
|
60
60
|
response = get_delete_view(self.client, self.detail_url_str, instance.pk)
|
|
61
61
|
self.assertEqual(response.status_code, 204)
|
|
62
62
|
self.assertFalse(Sport.objects.filter(pk=instance.pk).exists())
|
|
63
63
|
|
|
64
64
|
def test_ordering_fields(self):
|
|
65
65
|
first_name, second_name, third_name = "Team A", "Team B", "Team C"
|
|
66
|
-
SportFactory(name=second_name)
|
|
67
|
-
SportFactory(name=first_name)
|
|
68
|
-
SportFactory(name=third_name)
|
|
66
|
+
SportFactory.create(name=second_name)
|
|
67
|
+
SportFactory.create(name=first_name)
|
|
68
|
+
SportFactory.create(name=third_name)
|
|
69
69
|
|
|
70
70
|
response = self.client.get(self.list_url)
|
|
71
71
|
self.assertEqual(response.status_code, 200)
|
|
@@ -18,7 +18,7 @@ from wbcore.contrib.example_app.viewsets import StadiumModelViewSet
|
|
|
18
18
|
@pytest.mark.django_db
|
|
19
19
|
class TestStadiumModelViewSet(TestCase):
|
|
20
20
|
def setUp(self):
|
|
21
|
-
self.user = SuperUserFactory()
|
|
21
|
+
self.user = SuperUserFactory.create()
|
|
22
22
|
self.client = Client()
|
|
23
23
|
self.client.force_login(user=self.user)
|
|
24
24
|
self.list_url = reverse("example_app:stadium-list")
|
|
@@ -29,19 +29,19 @@ class TestStadiumModelViewSet(TestCase):
|
|
|
29
29
|
self.assertEqual(response.status_code, 200)
|
|
30
30
|
|
|
31
31
|
def test_create_view(self):
|
|
32
|
-
stadium = StadiumFactory()
|
|
32
|
+
stadium = StadiumFactory.create()
|
|
33
33
|
response = get_create_view(self.client, stadium, self.user, self.list_url, StadiumModelViewSet)
|
|
34
34
|
self.assertEqual(response.status_code, 201)
|
|
35
35
|
self.assertTrue(Stadium.objects.filter(name=stadium.name).exists())
|
|
36
36
|
|
|
37
37
|
def test_detail_view(self):
|
|
38
|
-
instance = StadiumFactory()
|
|
38
|
+
instance = StadiumFactory.create()
|
|
39
39
|
response = get_detail_view(self.client, instance.pk, self.detail_url_str)
|
|
40
40
|
self.assertEqual(response.status_code, 200)
|
|
41
41
|
self.assertEqual(response.data["instance"]["name"], instance.name)
|
|
42
42
|
|
|
43
43
|
def test_update_view(self):
|
|
44
|
-
instance = StadiumFactory()
|
|
44
|
+
instance = StadiumFactory.create()
|
|
45
45
|
instance.name = "Updated Instance"
|
|
46
46
|
response = get_update_view(self.client, instance, StadiumModelSerializer, self.detail_url_str)
|
|
47
47
|
instance.refresh_from_db()
|
|
@@ -49,23 +49,23 @@ class TestStadiumModelViewSet(TestCase):
|
|
|
49
49
|
self.assertEqual(response.data["instance"]["name"], instance.name)
|
|
50
50
|
|
|
51
51
|
def test_partial_update_view(self):
|
|
52
|
-
instance = StadiumFactory()
|
|
52
|
+
instance = StadiumFactory.create()
|
|
53
53
|
response = get_partial_view(self.client, instance.id, {"name": "Updated Instance"}, self.detail_url_str)
|
|
54
54
|
instance.refresh_from_db()
|
|
55
55
|
self.assertEqual(response.status_code, 200)
|
|
56
56
|
self.assertEqual(response.data["instance"]["name"], instance.name)
|
|
57
57
|
|
|
58
58
|
def test_delete_view(self):
|
|
59
|
-
instance = StadiumFactory()
|
|
59
|
+
instance = StadiumFactory.create()
|
|
60
60
|
response = get_delete_view(self.client, self.detail_url_str, instance.pk)
|
|
61
61
|
self.assertEqual(response.status_code, 204)
|
|
62
62
|
self.assertFalse(Stadium.objects.filter(pk=instance.pk).exists())
|
|
63
63
|
|
|
64
64
|
def test_ordering_fields(self):
|
|
65
65
|
first_name, second_name, third_name = "Stadium A", "Stadium B", "Stadium C"
|
|
66
|
-
StadiumFactory(name=second_name)
|
|
67
|
-
StadiumFactory(name=first_name)
|
|
68
|
-
StadiumFactory(name=third_name)
|
|
66
|
+
StadiumFactory.create(name=second_name)
|
|
67
|
+
StadiumFactory.create(name=first_name)
|
|
68
|
+
StadiumFactory.create(name=third_name)
|
|
69
69
|
|
|
70
70
|
response = self.client.get(self.list_url)
|
|
71
71
|
self.assertEqual(response.status_code, 200)
|
|
@@ -19,7 +19,7 @@ from wbcore.contrib.example_app.viewsets import TeamModelViewSet
|
|
|
19
19
|
@pytest.mark.django_db
|
|
20
20
|
class TestTeamModelViewSet(TestCase):
|
|
21
21
|
def setUp(self):
|
|
22
|
-
self.user = SuperUserFactory()
|
|
22
|
+
self.user = SuperUserFactory.create()
|
|
23
23
|
self.client = Client()
|
|
24
24
|
self.client.force_login(user=self.user)
|
|
25
25
|
self.list_url = reverse("example_app:team-list")
|
|
@@ -30,41 +30,41 @@ class TestTeamModelViewSet(TestCase):
|
|
|
30
30
|
self.assertEqual(response.status_code, 200)
|
|
31
31
|
|
|
32
32
|
def test_create_view(self):
|
|
33
|
-
team = TeamFactory()
|
|
33
|
+
team = TeamFactory.create()
|
|
34
34
|
response = get_create_view(self.client, team, self.user, self.list_url, TeamModelViewSet)
|
|
35
35
|
self.assertEqual(response.status_code, 201)
|
|
36
36
|
self.assertTrue(Team.objects.filter(name=team.name).exists())
|
|
37
37
|
|
|
38
38
|
def test_detail_view(self):
|
|
39
|
-
team = TeamFactory()
|
|
39
|
+
team = TeamFactory.create()
|
|
40
40
|
response = get_detail_view(self.client, team.pk, self.detail_url_str)
|
|
41
41
|
self.assertEqual(response.status_code, 200)
|
|
42
42
|
self.assertEqual(response.data["instance"]["name"], team.name)
|
|
43
43
|
|
|
44
44
|
def test_update_view(self):
|
|
45
|
-
instance = TeamFactory()
|
|
45
|
+
instance = TeamFactory.create()
|
|
46
46
|
instance.name = "Updated Instance"
|
|
47
47
|
response = get_update_view(self.client, instance, TeamModelSerializer, self.detail_url_str)
|
|
48
48
|
self.assertEqual(response.status_code, 200)
|
|
49
49
|
self.assertEqual(response.data["instance"]["name"], instance.name)
|
|
50
50
|
|
|
51
51
|
def test_partial_update_view(self):
|
|
52
|
-
instance = TeamFactory()
|
|
52
|
+
instance = TeamFactory.create()
|
|
53
53
|
response = get_partial_view(self.client, instance.id, {"name": "Updated Instance"}, self.detail_url_str)
|
|
54
54
|
instance.refresh_from_db()
|
|
55
55
|
self.assertEqual(response.status_code, 200)
|
|
56
56
|
self.assertEqual(response.data["instance"]["name"], instance.name)
|
|
57
57
|
|
|
58
58
|
def test_delete_view(self):
|
|
59
|
-
team = TeamFactory()
|
|
59
|
+
team = TeamFactory.create()
|
|
60
60
|
response = get_delete_view(self.client, self.detail_url_str, team.pk)
|
|
61
61
|
self.assertEqual(response.status_code, 204)
|
|
62
62
|
self.assertFalse(Team.objects.filter(pk=team.pk).exists())
|
|
63
63
|
|
|
64
64
|
def test_ordering_fields(self):
|
|
65
|
-
team_a = TeamFactory(name="BBB", order=1)
|
|
66
|
-
team_b = TeamFactory(name="AAA", order=0)
|
|
67
|
-
team_c = TeamFactory(name="CCC", order=2)
|
|
65
|
+
team_a = TeamFactory.create(name="BBB", order=1)
|
|
66
|
+
team_b = TeamFactory.create(name="AAA", order=0)
|
|
67
|
+
team_c = TeamFactory.create(name="CCC", order=2)
|
|
68
68
|
|
|
69
69
|
response = self.client.get(self.list_url)
|
|
70
70
|
self.assertEqual(response.status_code, 200)
|
|
@@ -74,9 +74,9 @@ class TestTeamModelViewSet(TestCase):
|
|
|
74
74
|
self.assertEqual(response.data["results"][2]["id"], team_c.id)
|
|
75
75
|
|
|
76
76
|
def test_team_stadium(self):
|
|
77
|
-
team_a = TeamFactory()
|
|
78
|
-
team_b = TeamFactory(home_stadium=team_a.home_stadium)
|
|
79
|
-
team_c = TeamFactory()
|
|
77
|
+
team_a = TeamFactory.create()
|
|
78
|
+
team_b = TeamFactory.create(home_stadium=team_a.home_stadium)
|
|
79
|
+
team_c = TeamFactory.create()
|
|
80
80
|
expected_number_of_teams = Team.objects.filter(home_stadium=team_a.home_stadium).count()
|
|
81
81
|
team_stadium_url = reverse("example_app:team-stadium-list", args=[team_a.home_stadium.id])
|
|
82
82
|
response = self.client.get(team_stadium_url)
|
|
@@ -17,7 +17,7 @@ from wbcore.contrib.example_app.viewsets import TeamResultsModelViewSet
|
|
|
17
17
|
@pytest.mark.django_db
|
|
18
18
|
class TestTeamResultsModelViewSet(TestCase):
|
|
19
19
|
def setUp(self):
|
|
20
|
-
self.user = SuperUserFactory()
|
|
20
|
+
self.user = SuperUserFactory.create()
|
|
21
21
|
self.client = Client()
|
|
22
22
|
self.client.force_login(user=self.user)
|
|
23
23
|
self.list_url = reverse("example_app:teamresults-list")
|
|
@@ -28,31 +28,31 @@ class TestTeamResultsModelViewSet(TestCase):
|
|
|
28
28
|
self.assertEqual(response.status_code, 200)
|
|
29
29
|
|
|
30
30
|
def test_create_view(self):
|
|
31
|
-
team_result = TeamResultsFactory()
|
|
31
|
+
team_result = TeamResultsFactory.create()
|
|
32
32
|
response = get_create_view(self.client, team_result, self.user, self.list_url, TeamResultsModelViewSet)
|
|
33
33
|
# It is not possible to create an team results, since the get_endpoint_url returns None.
|
|
34
34
|
self.assertEqual(response.status_code, 405)
|
|
35
35
|
|
|
36
36
|
def test_detail_view(self):
|
|
37
|
-
instance = TeamResultsFactory()
|
|
37
|
+
instance = TeamResultsFactory.create()
|
|
38
38
|
response = get_detail_view(self.client, instance.pk, self.detail_url_str)
|
|
39
39
|
self.assertEqual(response.status_code, 200)
|
|
40
40
|
self.assertEqual(response.data["instance"]["id"], instance.id)
|
|
41
41
|
|
|
42
42
|
def test_update_view(self):
|
|
43
|
-
instance = TeamResultsFactory()
|
|
43
|
+
instance = TeamResultsFactory.create()
|
|
44
44
|
instance.points = 5
|
|
45
45
|
response = get_update_view(self.client, instance, TeamResultsModelSerializer, self.detail_url_str)
|
|
46
46
|
# It is not possible to update an team results, since the get_endpoint_url returns None.
|
|
47
47
|
self.assertEqual(response.status_code, 405)
|
|
48
48
|
|
|
49
49
|
def test_partial_update_view(self):
|
|
50
|
-
instance = TeamResultsFactory()
|
|
50
|
+
instance = TeamResultsFactory.create()
|
|
51
51
|
response = get_partial_view(self.client, instance.id, {"points": 5}, self.detail_url_str)
|
|
52
52
|
self.assertEqual(response.status_code, 405)
|
|
53
53
|
|
|
54
54
|
def test_delete_view(self):
|
|
55
|
-
instance = TeamResultsFactory()
|
|
55
|
+
instance = TeamResultsFactory.create()
|
|
56
56
|
response = get_delete_view(self.client, self.detail_url_str, instance.pk)
|
|
57
57
|
# It is not possible to delete an team results, since the get_endpoint_url returns None.
|
|
58
58
|
self.assertEqual(response.status_code, 405)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Generated by Django 5.2.9 on 2025-12-09 08:50
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('geography', '0001_initial'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AddIndex(
|
|
14
|
+
model_name='geography',
|
|
15
|
+
index=models.Index(fields=['tree_id', 'lft'], name='geography_geography_tree_i739a'),
|
|
16
|
+
),
|
|
17
|
+
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from django.contrib.contenttypes.models import ContentType
|
|
3
|
-
from guardian.shortcuts import UserObjectPermission
|
|
4
3
|
from wbcore.contrib.authentication.models.users import Permission
|
|
4
|
+
from wbcore.contrib.guardian.models import UserObjectPermission
|
|
5
5
|
from wbcore.contrib.guardian.models.mixins import PermissionObjectModelMixin
|
|
6
6
|
from wbcore.contrib.guardian.utils import (
|
|
7
7
|
assign_permissions,
|
wbcore/contrib/guardian/utils.py
CHANGED
|
@@ -9,7 +9,7 @@ from django.utils import timezone
|
|
|
9
9
|
from guardian.shortcuts import assign_perm, get_anonymous_user
|
|
10
10
|
from psycopg.errors import InvalidCursorName
|
|
11
11
|
from wbcore.contrib.authentication.models import User
|
|
12
|
-
from wbcore.contrib.guardian.models
|
|
12
|
+
from wbcore.contrib.guardian.models import UserObjectPermission
|
|
13
13
|
from wbcore.permissions.shortcuts import get_internal_users
|
|
14
14
|
|
|
15
15
|
if TYPE_CHECKING:
|
wbcore/contrib/icons/icons.py
CHANGED
|
@@ -4,7 +4,7 @@ from types import DynamicClassAttribute
|
|
|
4
4
|
|
|
5
5
|
from django.conf import settings
|
|
6
6
|
from django.db.models import TextChoices
|
|
7
|
-
from django.db.models.enums import
|
|
7
|
+
from django.db.models.enums import ChoicesType
|
|
8
8
|
|
|
9
9
|
from wbcore.utils.importlib import import_from_dotted_path
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ DEFAULT_ICON_BACKEND = "wbcore.contrib.icons.backends.material.IconBackend"
|
|
|
12
12
|
FALLBACK_ICON_VALUE = "FALLBACK_ICON"
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
class WBIconMeta(
|
|
15
|
+
class WBIconMeta(ChoicesType):
|
|
16
16
|
"""A metaclass for creating a enum choices."""
|
|
17
17
|
|
|
18
18
|
def __new__(cls, classname, bases, classdict, **kwds):
|
wbcore/contrib/io/factories.py
CHANGED
|
@@ -154,6 +154,7 @@ class SourceFactory(factory.django.DjangoModelFactory):
|
|
|
154
154
|
|
|
155
155
|
class Meta:
|
|
156
156
|
model = Source
|
|
157
|
+
skip_postgeneration_save = True
|
|
157
158
|
|
|
158
159
|
@factory.post_generation
|
|
159
160
|
def parser_handler(self, create, extracted, **kwargs):
|
|
@@ -192,6 +193,7 @@ class ImportModelFactory(factory.django.DjangoModelFactory):
|
|
|
192
193
|
|
|
193
194
|
class Meta:
|
|
194
195
|
model = ImportModel
|
|
196
|
+
skip_postgeneration_save = True
|
|
195
197
|
|
|
196
198
|
@factory.post_generation
|
|
197
199
|
def many_relationships(self, create, extracted, **kwargs):
|
wbcore/contrib/io/models.py
CHANGED
|
@@ -255,7 +255,7 @@ class Source(models.Model):
|
|
|
255
255
|
null=True,
|
|
256
256
|
blank=True,
|
|
257
257
|
verbose_name=_("Crontab Schedule"),
|
|
258
|
-
help_text=_("Crontab Schedule to run the task on.
|
|
258
|
+
help_text=_("Crontab Schedule to run the task on. Set only one schedule type, leave the others null."),
|
|
259
259
|
)
|
|
260
260
|
|
|
261
261
|
periodic_task = models.ForeignKey(
|
|
@@ -711,7 +711,7 @@ class ExportSource(ImportExportSource):
|
|
|
711
711
|
]
|
|
712
712
|
constraints = [
|
|
713
713
|
models.CheckConstraint(
|
|
714
|
-
|
|
714
|
+
condition=Q(query_str__isnull=False, resource_path__isnull=False) | ~Q(data__exact=dict()),
|
|
715
715
|
name="check_either_data_or_resource_isnotnull",
|
|
716
716
|
)
|
|
717
717
|
]
|
|
@@ -916,7 +916,7 @@ class ImportSource(ImportExportSource):
|
|
|
916
916
|
elif self.status == self.Status.WARNING and self.errors_log:
|
|
917
917
|
body += f"""<p><strong>Warning:</strong> Some rows were ignored during import.</p>
|
|
918
918
|
<p><strong>Ignored Rows:</strong></p>
|
|
919
|
-
<ul>{"".join([
|
|
919
|
+
<ul>{"".join(["<li>" + line + "</li>" for line in io.StringIO(self.errors_log)])}</ul>"""
|
|
920
920
|
send_notification(
|
|
921
921
|
code="io.import_done",
|
|
922
922
|
title=f"Your import finished with status {self.Status[self.status].label}",
|
wbcore/contrib/io/viewsets.py
CHANGED
|
@@ -2,8 +2,8 @@ import json
|
|
|
2
2
|
|
|
3
3
|
import tablib
|
|
4
4
|
|
|
5
|
-
from wbcore.pandas import fields as pf
|
|
6
|
-
from wbcore.pandas.views import PandasAPIViewSet
|
|
5
|
+
from wbcore.contrib.pandas import fields as pf
|
|
6
|
+
from wbcore.contrib.pandas.views import PandasAPIViewSet
|
|
7
7
|
from wbcore.viewsets import ModelViewSet, ReadOnlyModelViewSet, RepresentationViewSet
|
|
8
8
|
|
|
9
9
|
from .configs.endpoints import (
|
wbcore/contrib/tags/factories.py
CHANGED
|
@@ -352,7 +352,7 @@ class UserStep(Step):
|
|
|
352
352
|
verbose_name_plural = _("User Steps")
|
|
353
353
|
constraints = [
|
|
354
354
|
models.CheckConstraint(
|
|
355
|
-
|
|
355
|
+
condition=~Q(assignee__isnull=False, group__isnull=False),
|
|
356
356
|
name="check_not_both_assignee_group",
|
|
357
357
|
),
|
|
358
358
|
]
|
wbcore/docs/__init__.py
CHANGED
wbcore/filters/mixins.py
CHANGED
|
@@ -90,12 +90,12 @@ class WBCoreFilterMixin:
|
|
|
90
90
|
"help_text": self.get_help_text(),
|
|
91
91
|
}
|
|
92
92
|
lookup_expr = {
|
|
93
|
-
"label": get_lookup_label(self.lookup_expr) if self.lookup_label is None else self.lookup_label,
|
|
94
93
|
"icon": get_lookup_icon(self.lookup_expr) if self.lookup_icon is None else self.lookup_icon,
|
|
95
|
-
"key": name,
|
|
96
94
|
"hidden": self.hidden,
|
|
97
95
|
"allow_exclude": self.allow_exclude,
|
|
98
96
|
"input_properties": {
|
|
97
|
+
"label": get_lookup_label(self.lookup_expr) if self.lookup_label is None else self.lookup_label,
|
|
98
|
+
"key": name,
|
|
99
99
|
"type": self.filter_type,
|
|
100
100
|
},
|
|
101
101
|
}
|
wbcore/markdown/views.py
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
from blockdiag.parser import ParseException
|
|
2
1
|
from django.core.exceptions import ValidationError
|
|
3
2
|
from django.http import HttpResponse
|
|
4
3
|
from django.template import exceptions
|
|
5
|
-
from markdown_blockdiag.utils import draw_blockdiag
|
|
6
|
-
from rest_framework import status
|
|
7
|
-
from rest_framework.permissions import IsAuthenticated
|
|
8
4
|
from rest_framework.request import Request
|
|
9
5
|
from rest_framework.response import Response
|
|
10
6
|
from rest_framework.reverse import reverse
|
|
@@ -14,19 +10,6 @@ from .models import Asset
|
|
|
14
10
|
from .template import render_template_for_templatetag
|
|
15
11
|
|
|
16
12
|
|
|
17
|
-
class BlockDiag(APIView):
|
|
18
|
-
permission_classes = [IsAuthenticated]
|
|
19
|
-
|
|
20
|
-
def post(self, request: Request) -> Response:
|
|
21
|
-
try:
|
|
22
|
-
blockdiag = request.data["markdown"]
|
|
23
|
-
svg = draw_blockdiag(blockdiag, output_fmt="svg", font_antialias=True)
|
|
24
|
-
except (ParseException, KeyError):
|
|
25
|
-
return Response(status=status.HTTP_400_BAD_REQUEST)
|
|
26
|
-
else:
|
|
27
|
-
return Response(svg)
|
|
28
|
-
|
|
29
|
-
|
|
30
13
|
class TemplateTagView(APIView):
|
|
31
14
|
permission_classes = []
|
|
32
15
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
from .bases import ButtonConfig
|
|
2
2
|
from .buttons import ActionButton, DropDownButton, HyperlinkButton, WidgetButton
|
|
3
|
-
from .enums import ButtonDefaultColor, ButtonType
|
|
3
|
+
from .enums import ButtonDefaultColor, ButtonType
|
|
4
4
|
from .view_config import ButtonViewConfig
|
|
@@ -11,7 +11,6 @@ class ButtonConfig:
|
|
|
11
11
|
label: Optional[str] = None
|
|
12
12
|
icon: Optional[str] = None
|
|
13
13
|
title: Optional[str] = None
|
|
14
|
-
style: Optional[dict] = None
|
|
15
14
|
color: ButtonDefaultColor | str = ButtonDefaultColor.PRIMARY
|
|
16
15
|
weight: int = 100
|
|
17
16
|
disabled: bool = False
|
|
@@ -31,16 +30,12 @@ class ButtonConfig:
|
|
|
31
30
|
if iter := getattr(super(), "__iter__", None):
|
|
32
31
|
yield from iter()
|
|
33
32
|
|
|
34
|
-
for key in ["label", "icon", "title"
|
|
33
|
+
for key in ["label", "icon", "title"]:
|
|
35
34
|
value = getattr(self, key, None)
|
|
36
35
|
if value:
|
|
37
36
|
yield key, value
|
|
38
37
|
color = getattr(self.color, "value", self.color)
|
|
39
38
|
yield "color", color
|
|
40
|
-
yield (
|
|
41
|
-
"level",
|
|
42
|
-
color,
|
|
43
|
-
) # TODO: we return level for backward compatibility reason. to be removed once we move to frontend version 2
|
|
44
39
|
yield "disabled", self.disabled # set to True if you want to set the css "disabled" property to that button
|
|
45
40
|
yield "always_render", self.always_render # set to True the button always needs to be rendered (even if empty)
|
|
46
41
|
yield "placeholder", self.placeholder # set to a valid string if a placeholder is needed onhover
|