Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
strass
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hub
strass
Commits
ccc5240e
Commit
ccc5240e
authored
3 months ago
by
Bryan BRANCOTTE
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix-pending-jm' into 'master'
take jury manager into account when looking for pending user. Closes
#172
See merge request
!239
parents
9215c10c
3f16a021
No related branches found
No related tags found
1 merge request
!239
take jury manager into account when looking for pending user.
Pipeline
#150145
passed
3 months ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/strass/strass_app/templatetags/strass_tags.py
+6
-2
6 additions, 2 deletions
src/strass/strass_app/templatetags/strass_tags.py
src/strass/strass_app/tests/test_strass_tags.py
+45
-0
45 additions, 0 deletions
src/strass/strass_app/tests/test_strass_tags.py
with
51 additions
and
2 deletions
src/strass/strass_app/templatetags/strass_tags.py
+
6
−
2
View file @
ccc5240e
...
...
@@ -167,7 +167,11 @@ def has_pending_user(request):
qs
=
models
.
User
.
objects
.
filter
(
is_active
=
True
)
qs
=
business_logic
.
annotate_is_juror
(
qs
,
pending_to_become_one
=
True
)
qs
=
business_logic
.
annotate_is_reviewer
(
qs
,
pending_to_become_one
=
True
)
return
request
is
not
None
and
qs
.
filter
(
Q
(
is_pending_juror
=
True
)
|
Q
(
is_pending_reviewer
=
True
)).
exists
()
qs
=
business_logic
.
annotate_is_jury_manager
(
qs
,
pending_to_become_one
=
True
)
return
(
request
is
not
None
and
qs
.
filter
(
Q
(
is_pending_juror
=
True
)
|
Q
(
is_pending_reviewer
=
True
)
|
Q
(
is_pending_jury_manager
=
True
)).
exists
()
)
def
cleanup_line_starts
(
value
):
...
...
@@ -233,7 +237,7 @@ def my_progress_bar(value, total=100, color_class='primary', as_ratio=False, sec
if
over_all_value
>
0
:
limit
=
int
(
10000
*
value
/
over_all_value
)
/
100
style
=
f
"
background: linear-gradient( to right, #0000
{
limit
}
%, #fff3
{
limit
}
% 40% );
"
style
+=
f
"
width:
{
0
if
total
==
0
else
int
(
100.0
*
over_all_value
/
total
)
}
%;
"
style
+=
f
"
width:
{
0
if
total
==
0
else
int
(
100.0
*
over_all_value
/
total
)
}
%;
"
low
=
total
==
0
or
(
1.0
*
over_all_value
/
total
<
0.3
)
bar
=
(
'
<div class=
"
progress position-relative
"
style=
"
height: 2em;
"
>
'
...
...
This diff is collapsed.
Click to expand it.
src/strass/strass_app/tests/test_strass_tags.py
+
45
−
0
View file @
ccc5240e
from
html.parser
import
HTMLParser
from
django.contrib.auth
import
get_user_model
from
django.test
import
RequestFactory
from
django.utils
import
timezone
from
freezegun
import
freeze_time
from
live_settings
import
live_settings
from
strass_app
import
business_logic
from
strass_app.templatetags
import
strass_tags
from
strass_app.templatetags.strass_tags
import
my_progress_bar
,
get_timer_before
,
markdown
from
strass_app.tests.test_base_test_case
import
TooledTestCase
...
...
@@ -110,3 +113,45 @@ class AllTestCase(TooledTestCase):
self
.
assertIn
(
'
<a href
'
,
markdown
(
"
[toto](https://aa.bb.com)
"
))
self
.
assertNotIn
(
'
<a href
'
,
markdown
(
"
[toto](javascript:alert(
'
Hi
'
))
"
))
self
.
assertNotIn
(
'
<a href
'
,
markdown
(
"
[toto](script://a=1;)
"
))
def
test_has_pending_user
(
self
):
# jury_manager = get_user_model().objects.create(
# username="jury_manager",
# first_name="jury",
# last_name="manager",
# email="jury_manager@pasteur.fr",
# )
u
=
get_user_model
().
objects
.
create
(
username
=
"
user
"
,
first_name
=
"
usery
"
,
last_name
=
"
user
"
,
email
=
"
user@pasteur.fr
"
,
)
# business_logic.set_jury_manager(jury_manager, True)
req
=
RequestFactory
().
get
(
'
/blabla
'
)
# req.user = jury_manager
self
.
assertFalse
(
strass_tags
.
has_pending_user
(
req
))
business_logic
.
set_reviewer
(
u
,
True
,
pending_to_become_one
=
True
)
self
.
assertTrue
(
strass_tags
.
has_pending_user
(
req
))
business_logic
.
set_reviewer
(
u
,
True
)
self
.
assertFalse
(
strass_tags
.
has_pending_user
(
req
))
business_logic
.
set_reviewer
(
u
,
False
)
self
.
assertFalse
(
strass_tags
.
has_pending_user
(
req
))
self
.
assertFalse
(
strass_tags
.
has_pending_user
(
req
))
business_logic
.
set_juror
(
u
,
True
,
pending_to_become_one
=
True
)
self
.
assertTrue
(
strass_tags
.
has_pending_user
(
req
))
business_logic
.
set_juror
(
u
,
True
)
self
.
assertFalse
(
strass_tags
.
has_pending_user
(
req
))
business_logic
.
set_juror
(
u
,
False
)
self
.
assertFalse
(
strass_tags
.
has_pending_user
(
req
))
self
.
assertFalse
(
strass_tags
.
has_pending_user
(
req
))
business_logic
.
set_jury_manager
(
u
,
True
,
pending_to_become_one
=
True
)
self
.
assertTrue
(
strass_tags
.
has_pending_user
(
req
))
business_logic
.
set_jury_manager
(
u
,
True
)
self
.
assertFalse
(
strass_tags
.
has_pending_user
(
req
))
business_logic
.
set_jury_manager
(
u
,
False
)
self
.
assertFalse
(
strass_tags
.
has_pending_user
(
req
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment