aa-bulletin-board 1.10.1__py3-none-any.whl → 1.11.0__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.
- aa_bulletin_board/__init__.py +1 -1
- aa_bulletin_board/auth_hooks.py +15 -6
- aa_bulletin_board/forms.py +6 -4
- aa_bulletin_board/helpers.py +15 -6
- aa_bulletin_board/locale/de/LC_MESSAGES/django.mo +0 -0
- aa_bulletin_board/locale/de/LC_MESSAGES/django.po +25 -30
- aa_bulletin_board/locale/django.pot +21 -24
- aa_bulletin_board/locale/es/LC_MESSAGES/django.po +21 -24
- aa_bulletin_board/locale/fr_FR/LC_MESSAGES/django.po +21 -24
- aa_bulletin_board/locale/it_IT/LC_MESSAGES/django.po +21 -24
- aa_bulletin_board/locale/ja/LC_MESSAGES/django.po +21 -24
- aa_bulletin_board/locale/ko_KR/LC_MESSAGES/django.po +21 -24
- aa_bulletin_board/locale/ru/LC_MESSAGES/django.mo +0 -0
- aa_bulletin_board/locale/ru/LC_MESSAGES/django.po +28 -33
- aa_bulletin_board/locale/uk/LC_MESSAGES/django.po +21 -24
- aa_bulletin_board/locale/zh_Hans/LC_MESSAGES/django.po +21 -24
- aa_bulletin_board/managers.py +7 -2
- aa_bulletin_board/models.py +17 -3
- aa_bulletin_board/static/aa_bulletin_board/css/aa-bootstrap-fix.css +5 -5
- aa_bulletin_board/static/aa_bulletin_board/css/aa-bootstrap-fix.min.css +1 -1
- aa_bulletin_board/templates/aa_bulletin_board/base.html +1 -1
- aa_bulletin_board/templates/aa_bulletin_board/partials/footer/app-translation-footer.html +11 -0
- aa_bulletin_board/templatetags/aa_bulletin_board_versioned_static.py +2 -1
- aa_bulletin_board/tests/test_access.py +61 -37
- aa_bulletin_board/tests/test_auth_hooks.py +18 -9
- aa_bulletin_board/tests/test_bulletins.py +80 -47
- aa_bulletin_board/tests/test_templatetags.py +9 -6
- aa_bulletin_board/tests/test_user_interface.py +85 -43
- aa_bulletin_board/tests/utils.py +24 -3
- aa_bulletin_board/urls.py +7 -5
- aa_bulletin_board/views.py +86 -33
- {aa_bulletin_board-1.10.1.dist-info → aa_bulletin_board-1.11.0.dist-info}/METADATA +1 -1
- {aa_bulletin_board-1.10.1.dist-info → aa_bulletin_board-1.11.0.dist-info}/RECORD +35 -35
- aa_bulletin_board/templates/aa_bulletin_board/partials/app-translation-footer.html +0 -11
- {aa_bulletin_board-1.10.1.dist-info → aa_bulletin_board-1.11.0.dist-info}/WHEEL +0 -0
- {aa_bulletin_board-1.10.1.dist-info → aa_bulletin_board-1.11.0.dist-info}/licenses/LICENSE +0 -0
@@ -8,7 +8,7 @@ msgid ""
|
|
8
8
|
msgstr ""
|
9
9
|
"Project-Id-Version: PACKAGE VERSION\n"
|
10
10
|
"Report-Msgid-Bugs-To: \n"
|
11
|
-
"POT-Creation-Date: 2023-
|
11
|
+
"POT-Creation-Date: 2023-08-02 15:50+0200\n"
|
12
12
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
13
13
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14
14
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
@@ -38,37 +38,37 @@ msgid ""
|
|
38
38
|
"place, everyone who has access to this module can read this bulletin."
|
39
39
|
msgstr ""
|
40
40
|
|
41
|
-
#: models.py:
|
41
|
+
#: models.py:81
|
42
42
|
msgid "Title"
|
43
43
|
msgstr ""
|
44
44
|
|
45
|
-
#: models.py:
|
45
|
+
#: models.py:83
|
46
46
|
msgid "Content"
|
47
47
|
msgstr ""
|
48
48
|
|
49
49
|
#. Translators: This is the date and time the bulletin has been created
|
50
|
-
#: models.py:
|
50
|
+
#: models.py:88
|
51
51
|
msgid "Created"
|
52
52
|
msgstr ""
|
53
53
|
|
54
54
|
#. Translators: This is the date and time the bulletin has been updated
|
55
|
-
#: models.py:
|
55
|
+
#: models.py:94
|
56
56
|
msgid "Updated"
|
57
57
|
msgstr ""
|
58
58
|
|
59
|
-
#: models.py:
|
59
|
+
#: models.py:103
|
60
60
|
msgid "User"
|
61
61
|
msgstr ""
|
62
62
|
|
63
|
-
#: models.py:
|
63
|
+
#: models.py:109
|
64
64
|
msgid "Group restrictions"
|
65
65
|
msgstr ""
|
66
66
|
|
67
|
-
#: models.py:
|
67
|
+
#: models.py:120
|
68
68
|
msgid "Bulletin"
|
69
69
|
msgstr ""
|
70
70
|
|
71
|
-
#: models.py:
|
71
|
+
#: models.py:121
|
72
72
|
msgid "Bulletins"
|
73
73
|
msgstr ""
|
74
74
|
|
@@ -116,44 +116,41 @@ msgstr ""
|
|
116
116
|
msgid "Create Bulletin"
|
117
117
|
msgstr ""
|
118
118
|
|
119
|
-
#: templates/aa_bulletin_board/partials/app-translation-footer.html:
|
120
|
-
msgid "
|
119
|
+
#: templates/aa_bulletin_board/partials/footer/app-translation-footer.html:5
|
120
|
+
msgid ""
|
121
|
+
"Do you want to help translate this app into your language or improve the "
|
122
|
+
"existing translation?"
|
121
123
|
msgstr ""
|
122
124
|
|
123
|
-
#: templates/aa_bulletin_board/partials/app-translation-footer.html:
|
124
|
-
|
125
|
-
msgid ""
|
126
|
-
"\n"
|
127
|
-
" Do you want to help translate this app into your language or "
|
128
|
-
"improve the existing translation? - %(weblate_link)s\n"
|
129
|
-
" "
|
125
|
+
#: templates/aa_bulletin_board/partials/footer/app-translation-footer.html:8
|
126
|
+
msgid "Join our team of translators!"
|
130
127
|
msgstr ""
|
131
128
|
|
132
|
-
#: views.py:
|
129
|
+
#: views.py:80
|
133
130
|
#, python-brace-format
|
134
131
|
msgid "Bulletin \"{bulletin__title}\" created."
|
135
132
|
msgstr ""
|
136
133
|
|
137
|
-
#: views.py:
|
134
|
+
#: views.py:123
|
138
135
|
msgid ""
|
139
136
|
"The bulletin you are looking for does not exist, or you don't have access to "
|
140
137
|
"it."
|
141
138
|
msgstr ""
|
142
139
|
|
143
|
-
#: views.py:
|
140
|
+
#: views.py:165
|
144
141
|
#, python-brace-format
|
145
142
|
msgid "Bulletin \"{bulletin__title}\" updated."
|
146
143
|
msgstr ""
|
147
144
|
|
148
|
-
#: views.py:
|
145
|
+
#: views.py:184
|
149
146
|
msgid "The bulletin you are trying to edit does not exist."
|
150
147
|
msgstr ""
|
151
148
|
|
152
|
-
#: views.py:
|
149
|
+
#: views.py:208
|
153
150
|
#, python-brace-format
|
154
151
|
msgid "Bulletin \"{bulletin.title}\" deleted."
|
155
152
|
msgstr ""
|
156
153
|
|
157
|
-
#: views.py:
|
154
|
+
#: views.py:215
|
158
155
|
msgid "The bulletin you are trying to delete does not exist."
|
159
156
|
msgstr ""
|
aa_bulletin_board/managers.py
CHANGED
@@ -16,10 +16,15 @@ class BulletinQuerySet(models.QuerySet):
|
|
16
16
|
def user_has_access(self, user: User) -> models.QuerySet:
|
17
17
|
"""
|
18
18
|
Filter boards that given user has access to.
|
19
|
+
|
20
|
+
:param user:
|
21
|
+
:type user:
|
22
|
+
:return:
|
23
|
+
:rtype:
|
19
24
|
"""
|
20
25
|
|
21
26
|
# Forum managers always have access, so assign this permission wisely
|
22
|
-
if user.has_perm("aa_bulletin_board.manage_bulletins"):
|
27
|
+
if user.has_perm(perm="aa_bulletin_board.manage_bulletins"):
|
23
28
|
return self
|
24
29
|
|
25
30
|
# If not a forum manager, check if the user has access to the board
|
@@ -36,4 +41,4 @@ class BulletinManagerBase(models.Manager): # pylint: disable=too-few-public-met
|
|
36
41
|
pass # pylint: disable=unnecessary-pass
|
37
42
|
|
38
43
|
|
39
|
-
BulletinManager = BulletinManagerBase.from_queryset(BulletinQuerySet)
|
44
|
+
BulletinManager = BulletinManagerBase.from_queryset(queryset_class=BulletinQuerySet)
|
aa_bulletin_board/models.py
CHANGED
@@ -22,7 +22,9 @@ from aa_bulletin_board.managers import BulletinManager
|
|
22
22
|
def get_sentinel_user() -> User:
|
23
23
|
"""
|
24
24
|
Get the sentinel user or create one
|
25
|
+
|
25
26
|
:return:
|
27
|
+
:rtype:
|
26
28
|
"""
|
27
29
|
|
28
30
|
return User.objects.get_or_create(username="deleted")[0]
|
@@ -31,17 +33,22 @@ def get_sentinel_user() -> User:
|
|
31
33
|
def get_bulletin_slug_from_title(bulletin_title: str) -> str:
|
32
34
|
"""
|
33
35
|
Get the slug from the title
|
36
|
+
|
34
37
|
:param bulletin_title:
|
38
|
+
:type bulletin_title:
|
35
39
|
:return:
|
40
|
+
:rtype:
|
36
41
|
"""
|
37
42
|
|
38
43
|
run = 0
|
39
|
-
bulletin_slug = slugify(
|
44
|
+
bulletin_slug = slugify(
|
45
|
+
value=unidecode.unidecode(bulletin_title), allow_unicode=True
|
46
|
+
)
|
40
47
|
|
41
48
|
while Bulletin.objects.filter(slug=bulletin_slug).exists():
|
42
49
|
run += 1
|
43
50
|
bulletin_slug = slugify(
|
44
|
-
unidecode.unidecode(f"{bulletin_title}-{run}"), allow_unicode=True
|
51
|
+
value=unidecode.unidecode(f"{bulletin_title}-{run}"), allow_unicode=True
|
45
52
|
)
|
46
53
|
|
47
54
|
return bulletin_slug
|
@@ -120,9 +127,16 @@ class Bulletin(models.Model):
|
|
120
127
|
def save(self, *args, **kwargs) -> None:
|
121
128
|
"""
|
122
129
|
Add the slug on save
|
130
|
+
|
131
|
+
:param args:
|
132
|
+
:type args:
|
133
|
+
:param kwargs:
|
134
|
+
:type kwargs:
|
135
|
+
:return:
|
136
|
+
:rtype:
|
123
137
|
"""
|
124
138
|
|
125
|
-
self.content = string_cleanup(self.content)
|
139
|
+
self.content = string_cleanup(string=self.content)
|
126
140
|
|
127
141
|
if self.slug == "":
|
128
142
|
bulletin_slug = get_bulletin_slug_from_title(bulletin_title=self.title)
|
@@ -1,13 +1,13 @@
|
|
1
|
-
/*
|
1
|
+
/* Attempting to fix AA's wrong usage of bootstrap classes
|
2
2
|
------------------------------------------------------------------------------------- */
|
3
3
|
@media all {
|
4
|
-
|
5
|
-
margin-left:
|
4
|
+
#site-body-wrapper.row {
|
5
|
+
margin-left: 0;
|
6
6
|
}
|
7
7
|
}
|
8
8
|
|
9
9
|
@media all and (min-width: 768px) {
|
10
|
-
|
11
|
-
margin-left:
|
10
|
+
#site-body-wrapper.row {
|
11
|
+
margin-left: -15px;
|
12
12
|
}
|
13
13
|
}
|
@@ -1 +1 @@
|
|
1
|
-
@media all{
|
1
|
+
@media all{#site-body-wrapper.row{margin-left:0}}@media all and (min-width:768px){#site-body-wrapper.row{margin-left:-15px}}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{% load i18n %}
|
2
|
+
|
3
|
+
<div class="app-translation-footer text-muted">
|
4
|
+
<p>
|
5
|
+
{% translate "Do you want to help translate this app into your language or improve the existing translation?" %}
|
6
|
+
-
|
7
|
+
<a href="https://weblate.ppfeufer.de/engage/alliance-auth-apps/" target="_blank" rel="noopener noreferer">
|
8
|
+
{% translate "Join our team of translators!" %}
|
9
|
+
</a>
|
10
|
+
</p>
|
11
|
+
</div>
|
@@ -14,13 +14,14 @@ from aa_bulletin_board import __version__
|
|
14
14
|
def aa_bulletin_board_static(path: str) -> str:
|
15
15
|
"""
|
16
16
|
Versioned static URL
|
17
|
+
|
17
18
|
:param path:
|
18
19
|
:type path:
|
19
20
|
:return:
|
20
21
|
:rtype:
|
21
22
|
"""
|
22
23
|
|
23
|
-
static_url = static(path)
|
24
|
+
static_url = static(path=path)
|
24
25
|
versioned_url = static_url + "?v=" + __version__
|
25
26
|
|
26
27
|
return versioned_url
|
@@ -1,6 +1,8 @@
|
|
1
1
|
"""
|
2
2
|
Testing access to bulletins
|
3
3
|
"""
|
4
|
+
# Standard Library
|
5
|
+
from http import HTTPStatus
|
4
6
|
|
5
7
|
# Third Party
|
6
8
|
from faker import Faker
|
@@ -26,48 +28,57 @@ class TestAccess(TestCase):
|
|
26
28
|
def setUpClass(cls) -> None:
|
27
29
|
"""
|
28
30
|
Set up groups and users
|
31
|
+
|
32
|
+
:return:
|
33
|
+
:rtype:
|
29
34
|
"""
|
30
35
|
|
31
36
|
super().setUpClass()
|
32
37
|
cls.group = Group.objects.create(name="Superhero")
|
33
38
|
|
34
39
|
# User cannot access bulletins
|
35
|
-
cls.user_1001 = create_fake_user(
|
40
|
+
cls.user_1001 = create_fake_user(
|
41
|
+
character_id=1001, character_name="Peter Parker"
|
42
|
+
)
|
36
43
|
|
37
44
|
# User can access bulletins
|
38
45
|
cls.user_1002 = create_fake_user(
|
39
|
-
1002,
|
46
|
+
character_id=1002,
|
47
|
+
character_name="Bruce Wayne",
|
48
|
+
permissions=["aa_bulletin_board.basic_access"],
|
40
49
|
)
|
41
50
|
|
42
51
|
# User can manage bulletins
|
43
52
|
cls.user_1003 = create_fake_user(
|
44
|
-
1003,
|
45
|
-
"Clark Kent",
|
53
|
+
character_id=1003,
|
54
|
+
character_name="Clark Kent",
|
46
55
|
permissions=[
|
47
56
|
"aa_bulletin_board.basic_access",
|
48
57
|
"aa_bulletin_board.manage_bulletins",
|
49
58
|
],
|
50
59
|
)
|
51
60
|
|
52
|
-
def test_should_show_dashboard(self):
|
61
|
+
def test_should_show_dashboard(self) -> None:
|
53
62
|
"""
|
54
63
|
Test that a user with basic_access can see the bulletin board
|
64
|
+
|
55
65
|
:return:
|
56
66
|
:rtype:
|
57
67
|
"""
|
58
68
|
|
59
69
|
# given
|
60
|
-
self.client.force_login(self.user_1002)
|
70
|
+
self.client.force_login(user=self.user_1002)
|
61
71
|
|
62
72
|
# when
|
63
|
-
res = self.client.get(reverse("aa_bulletin_board:dashboard"))
|
73
|
+
res = self.client.get(path=reverse(viewname="aa_bulletin_board:dashboard"))
|
64
74
|
|
65
75
|
# then
|
66
|
-
self.assertEqual(res.status_code,
|
76
|
+
self.assertEqual(first=res.status_code, second=HTTPStatus.OK)
|
67
77
|
|
68
|
-
def test_should_show_bulletin(self):
|
78
|
+
def test_should_show_bulletin(self) -> None:
|
69
79
|
"""
|
70
80
|
Test that a user with basic_access can see the bulletin
|
81
|
+
|
71
82
|
:return:
|
72
83
|
:rtype:
|
73
84
|
"""
|
@@ -78,37 +89,42 @@ class TestAccess(TestCase):
|
|
78
89
|
content=f"<p>{fake.sentence()}</p>",
|
79
90
|
created_by=self.user_1001,
|
80
91
|
)
|
81
|
-
self.client.force_login(self.user_1002)
|
92
|
+
self.client.force_login(user=self.user_1002)
|
82
93
|
|
83
94
|
# when
|
84
95
|
res = self.client.get(
|
85
|
-
reverse(
|
96
|
+
path=reverse(
|
97
|
+
viewname="aa_bulletin_board:view_bulletin",
|
98
|
+
kwargs={"slug": bulletin.slug},
|
99
|
+
)
|
86
100
|
)
|
87
|
-
result = Bulletin.objects.user_has_access(self.user_1002)
|
101
|
+
result = Bulletin.objects.user_has_access(user=self.user_1002)
|
88
102
|
|
89
103
|
# then
|
90
|
-
self.assertEqual(res.status_code,
|
91
|
-
self.assertIn(bulletin, result)
|
104
|
+
self.assertEqual(first=res.status_code, second=HTTPStatus.OK)
|
105
|
+
self.assertIn(member=bulletin, container=result)
|
92
106
|
|
93
|
-
def test_should_not_show_dashboard(self):
|
107
|
+
def test_should_not_show_dashboard(self) -> None:
|
94
108
|
"""
|
95
109
|
Test that a user without basic_access can't see the bulletin board
|
110
|
+
|
96
111
|
:return:
|
97
112
|
:rtype:
|
98
113
|
"""
|
99
114
|
|
100
115
|
# given
|
101
|
-
self.client.force_login(self.user_1001)
|
116
|
+
self.client.force_login(user=self.user_1001)
|
102
117
|
|
103
118
|
# when
|
104
|
-
res = self.client.get(reverse("aa_bulletin_board:dashboard"))
|
119
|
+
res = self.client.get(path=reverse(viewname="aa_bulletin_board:dashboard"))
|
105
120
|
|
106
121
|
# then
|
107
|
-
self.assertIsNot(res.status_code,
|
122
|
+
self.assertIsNot(expr1=res.status_code, expr2=HTTPStatus.OK)
|
108
123
|
|
109
|
-
def test_should_not_show_bulletin(self):
|
124
|
+
def test_should_not_show_bulletin(self) -> None:
|
110
125
|
"""
|
111
126
|
Test that a user without basic_access can't see the bulletin
|
127
|
+
|
112
128
|
:return:
|
113
129
|
:rtype:
|
114
130
|
"""
|
@@ -119,19 +135,23 @@ class TestAccess(TestCase):
|
|
119
135
|
content=f"<p>{fake.sentence()}</p>",
|
120
136
|
created_by=self.user_1001,
|
121
137
|
)
|
122
|
-
self.client.force_login(self.user_1001)
|
138
|
+
self.client.force_login(user=self.user_1001)
|
123
139
|
|
124
140
|
# when
|
125
141
|
res = self.client.get(
|
126
|
-
reverse(
|
142
|
+
path=reverse(
|
143
|
+
viewname="aa_bulletin_board:view_bulletin",
|
144
|
+
kwargs={"slug": bulletin.slug},
|
145
|
+
)
|
127
146
|
)
|
128
147
|
|
129
148
|
# then
|
130
|
-
self.assertIsNot(res.status_code,
|
149
|
+
self.assertIsNot(expr1=res.status_code, expr2=HTTPStatus.OK)
|
131
150
|
|
132
|
-
def test_should_return_bulletin_for_user_with_perm_manage_bulletins(self):
|
151
|
+
def test_should_return_bulletin_for_user_with_perm_manage_bulletins(self) -> None:
|
133
152
|
"""
|
134
153
|
Test that a user with "aa_bulletin_board.manage_bulletins" can see all bulletins
|
154
|
+
|
135
155
|
:return:
|
136
156
|
:rtype:
|
137
157
|
"""
|
@@ -144,17 +164,18 @@ class TestAccess(TestCase):
|
|
144
164
|
)
|
145
165
|
|
146
166
|
# when
|
147
|
-
result = Bulletin.objects.user_has_access(self.user_1003)
|
167
|
+
result = Bulletin.objects.user_has_access(user=self.user_1003)
|
148
168
|
|
149
169
|
# then
|
150
|
-
self.assertIn(bulletin, result)
|
170
|
+
self.assertIn(member=bulletin, container=result)
|
151
171
|
|
152
172
|
def test_should_return_restricted_bulletin_for_user_with_perm_manage_bulletins(
|
153
173
|
self,
|
154
|
-
):
|
174
|
+
) -> None:
|
155
175
|
"""
|
156
176
|
Test that a user with "aa_bulletin_board.manage_bulletins"
|
157
177
|
can see all bulletins, even restricted
|
178
|
+
|
158
179
|
:return:
|
159
180
|
:rtype:
|
160
181
|
"""
|
@@ -168,14 +189,15 @@ class TestAccess(TestCase):
|
|
168
189
|
bulletin.groups.add(self.group)
|
169
190
|
|
170
191
|
# when
|
171
|
-
result = Bulletin.objects.user_has_access(self.user_1003)
|
192
|
+
result = Bulletin.objects.user_has_access(user=self.user_1003)
|
172
193
|
|
173
194
|
# then
|
174
|
-
self.assertIn(bulletin, result)
|
195
|
+
self.assertIn(member=bulletin, container=result)
|
175
196
|
|
176
|
-
def test_should_return_bulletin_with_no_groups(self):
|
197
|
+
def test_should_return_bulletin_with_no_groups(self) -> None:
|
177
198
|
"""
|
178
199
|
Test that any user with access can se non-restricted bulletins
|
200
|
+
|
179
201
|
:return:
|
180
202
|
:rtype:
|
181
203
|
"""
|
@@ -188,14 +210,15 @@ class TestAccess(TestCase):
|
|
188
210
|
)
|
189
211
|
|
190
212
|
# when
|
191
|
-
result = Bulletin.objects.user_has_access(self.user_1002)
|
213
|
+
result = Bulletin.objects.user_has_access(user=self.user_1002)
|
192
214
|
|
193
215
|
# then
|
194
|
-
self.assertIn(bulletin, result)
|
216
|
+
self.assertIn(member=bulletin, container=result)
|
195
217
|
|
196
|
-
def test_should_return_bulletin_for_group_member(self):
|
218
|
+
def test_should_return_bulletin_for_group_member(self) -> None:
|
197
219
|
"""
|
198
220
|
Test that group restricted bulletins are visible for users who have this group
|
221
|
+
|
199
222
|
:return:
|
200
223
|
:rtype:
|
201
224
|
"""
|
@@ -210,15 +233,16 @@ class TestAccess(TestCase):
|
|
210
233
|
self.user_1001.groups.add(self.group)
|
211
234
|
|
212
235
|
# when
|
213
|
-
result = Bulletin.objects.user_has_access(self.user_1001)
|
236
|
+
result = Bulletin.objects.user_has_access(user=self.user_1001)
|
214
237
|
|
215
238
|
# then
|
216
|
-
self.assertIn(bulletin, result)
|
239
|
+
self.assertIn(member=bulletin, container=result)
|
217
240
|
|
218
|
-
def test_should_not_return_bulletin_for_non_group_member(self):
|
241
|
+
def test_should_not_return_bulletin_for_non_group_member(self) -> None:
|
219
242
|
"""
|
220
243
|
Test that group restricted bulletins are not visible for
|
221
244
|
users who don't have this group
|
245
|
+
|
222
246
|
:return:
|
223
247
|
:rtype:
|
224
248
|
"""
|
@@ -232,7 +256,7 @@ class TestAccess(TestCase):
|
|
232
256
|
bulletin.groups.add(self.group)
|
233
257
|
|
234
258
|
# when
|
235
|
-
result = Bulletin.objects.user_has_access(self.user_1002)
|
259
|
+
result = Bulletin.objects.user_has_access(user=self.user_1002)
|
236
260
|
|
237
261
|
# then
|
238
|
-
self.assertNotIn(bulletin, result)
|
262
|
+
self.assertNotIn(member=bulletin, container=result)
|
@@ -22,51 +22,60 @@ class TestHooks(TestCase):
|
|
22
22
|
def setUpClass(cls) -> None:
|
23
23
|
"""
|
24
24
|
Set up groups and users
|
25
|
+
|
26
|
+
:return:
|
27
|
+
:rtype:
|
25
28
|
"""
|
26
29
|
|
27
30
|
super().setUpClass()
|
28
31
|
|
29
32
|
# User cannot access bulletins
|
30
|
-
cls.user_1001 = create_fake_user(
|
33
|
+
cls.user_1001 = create_fake_user(
|
34
|
+
character_id=1001, character_name="Peter Parker"
|
35
|
+
)
|
31
36
|
|
32
37
|
# User can access bulletins
|
33
38
|
cls.user_1002 = create_fake_user(
|
34
|
-
1002,
|
39
|
+
character_id=1002,
|
40
|
+
character_name="Bruce Wayne",
|
41
|
+
permissions=["aa_bulletin_board.basic_access"],
|
35
42
|
)
|
36
43
|
|
37
44
|
cls.html_menu = f"""
|
38
45
|
<li>
|
39
|
-
<a class href="{reverse('aa_bulletin_board:dashboard')}">
|
46
|
+
<a class href="{reverse(viewname='aa_bulletin_board:dashboard')}">
|
40
47
|
<i class="fas fa-clipboard-list fa-fw"></i> Bulletin Board
|
41
48
|
</a>
|
42
49
|
</li>
|
43
50
|
"""
|
44
51
|
|
45
|
-
def test_render_hook_success(self):
|
52
|
+
def test_render_hook_success(self) -> None:
|
46
53
|
"""
|
47
54
|
Test should show the link to the app in the navigation to user with access
|
55
|
+
|
48
56
|
:return:
|
49
57
|
:rtype:
|
50
58
|
"""
|
51
59
|
|
52
|
-
self.client.force_login(self.user_1002)
|
60
|
+
self.client.force_login(user=self.user_1002)
|
53
61
|
|
54
|
-
response = self.client.get(reverse("authentication:dashboard"))
|
62
|
+
response = self.client.get(path=reverse(viewname="authentication:dashboard"))
|
55
63
|
|
56
64
|
self.assertEqual(response.status_code, HTTPStatus.OK)
|
57
65
|
self.assertContains(response, self.html_menu, html=True)
|
58
66
|
|
59
|
-
def test_render_hook_fail(self):
|
67
|
+
def test_render_hook_fail(self) -> None:
|
60
68
|
"""
|
61
69
|
Test should not show the link to the app in the
|
62
70
|
navigation to user without access
|
71
|
+
|
63
72
|
:return:
|
64
73
|
:rtype:
|
65
74
|
"""
|
66
75
|
|
67
|
-
self.client.force_login(self.user_1001)
|
76
|
+
self.client.force_login(user=self.user_1001)
|
68
77
|
|
69
|
-
response = self.client.get(reverse("authentication:dashboard"))
|
78
|
+
response = self.client.get(path=reverse(viewname="authentication:dashboard"))
|
70
79
|
|
71
80
|
self.assertEqual(response.status_code, HTTPStatus.OK)
|
72
81
|
self.assertNotContains(response, self.html_menu, html=True)
|