Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mélanie Chauvel
funkwhale
Commits
177f06cf
Verified
Commit
177f06cf
authored
5 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
See #890: Ensure report handled_date is populated automatically when handling the report
parent
b659eec4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/funkwhale_api/moderation/models.py
+10
-1
10 additions, 1 deletion
api/funkwhale_api/moderation/models.py
api/tests/moderation/test_models.py
+22
-0
22 additions, 0 deletions
api/tests/moderation/test_models.py
with
32 additions
and
1 deletion
api/funkwhale_api/moderation/models.py
+
10
−
1
View file @
177f06cf
...
...
@@ -6,13 +6,14 @@ from django.contrib.contenttypes.fields import GenericForeignKey
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.postgres.fields
import
JSONField
from
django.db
import
models
from
django.db.models.signals
import
pre_save
from
django.dispatch
import
receiver
from
django.urls
import
reverse
from
django.utils
import
timezone
from
funkwhale_api.federation
import
models
as
federation_models
from
funkwhale_api.federation
import
utils
as
federation_utils
class
InstancePolicyQuerySet
(
models
.
QuerySet
):
def
active
(
self
):
return
self
.
filter
(
is_active
=
True
)
...
...
@@ -160,3 +161,11 @@ class Report(federation_models.FederationMixin):
self
.
fid
=
self
.
get_federation_id
()
return
super
().
save
(
**
kwargs
)
@receiver
(
pre_save
,
sender
=
Report
)
def
set_handled_date
(
sender
,
instance
,
**
kwargs
):
if
instance
.
is_handled
is
True
and
not
instance
.
handled_date
:
instance
.
handled_date
=
timezone
.
now
()
elif
not
instance
.
is_handled
:
instance
.
handled_date
=
None
\ No newline at end of file
This diff is collapsed.
Click to expand it.
api/tests/moderation/test_models.py
0 → 100644
+
22
−
0
View file @
177f06cf
def
test_setting_report_handled_to_true_sets_handled_date
(
factories
,
now
):
target
=
factories
[
"
music.Artist
"
]()
report
=
factories
[
"
moderation.Report
"
](
target
=
target
)
assert
report
.
is_handled
is
False
assert
report
.
handled_date
is
None
report
.
is_handled
=
True
report
.
save
()
assert
report
.
handled_date
==
now
def
test_setting_report_handled_to_false_sets_handled_date_to_null
(
factories
,
now
):
target
=
factories
[
"
music.Artist
"
]()
report
=
factories
[
"
moderation.Report
"
](
target
=
target
,
is_handled
=
True
,
handled_date
=
now
)
report
.
is_handled
=
False
report
.
save
()
assert
report
.
handled_date
is
None
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