Reject rating when an abuse report gets resolved #223

Merged
Oleg-Komarov merged 2 commits from reject-rating into main 2024-07-22 13:42:56 +02:00
7 changed files with 1 additions and 33 deletions
Showing only changes of commit 8e494f81d1 - Show all commits

View File

@ -97,7 +97,6 @@ class ResolveReportTest(TestCase):
rating=rating,
type=ABUSE_TYPE_RATING,
)
notification_nr = Notification.objects.filter(recipient=some_user).count()
moderator = create_moderator()
self.client.force_login(moderator)
response = self.client.post(
@ -106,5 +105,3 @@ class ResolveReportTest(TestCase):
self.assertEqual(response.status_code, 302)
rating.refresh_from_db()
self.assertEqual(rating.status, Rating.STATUSES.REJECTED)
new_notification_nr = Notification.objects.filter(recipient=some_user).count()
self.assertEqual(new_notification_nr, notification_nr + 1)

View File

@ -150,11 +150,6 @@ class ReportView(LoginRequiredMixin, UpdateView):
rating = form.instance.rating
rating.status = Rating.STATUSES.REJECTED
rating.save(update_fields={'status'})
action.send(
self.request.user,
verb=Verb.REJECTED_RATING,
target=form.instance.rating,
)
response = super().form_valid(form)
action.send(
self.request.user,

View File

@ -7,7 +7,6 @@ class Verb:
COMMENTED = 'commented'
DISMISSED_ABUSE_REPORT = 'dismissed abuse report'
RATED_EXTENSION = 'rated extension'
REJECTED_RATING = 'rejected rating'
REPORTED_EXTENSION = 'reported extension'
REPORTED_RATING = 'reported rating'
REQUESTED_CHANGES = 'requested changes'
@ -19,6 +18,5 @@ class Verb:
class Flag:
AUTHOR = 'author'
MODERATOR = 'moderator'
RATING_AUTHOR = 'rating_author'
REPORTER = 'reporter'
REVIEWER = 'reviewer'

View File

@ -8,8 +8,6 @@
{% blocktrans %}{{ someone }} dismissed your {{ what }}{% endblocktrans %}
{% elif verb == Verb.RATED_EXTENSION %}
{% blocktrans %}{{ someone }} {{ verb }} {{ what }}{% endblocktrans %}
{% elif verb == Verb.REJECTED_RATING %}
{% blocktrans %}Your rating {{ what }} was rejected because it violates site policy.{% endblocktrans %}
{% elif verb == Verb.REPORTED_EXTENSION %}
{% blocktrans %}{{ someone }} reported {{ what }}{% endblocktrans %}
{% elif verb == Verb.REPORTED_RATING %}

View File

@ -8,8 +8,6 @@
{% blocktrans %}Your {{ what }} was dismissed{% endblocktrans %}
{% elif verb == Verb.RATED_EXTENSION %}
{% blocktrans %}{{ target_type }} rated: "{{ name }}"{% endblocktrans %}
{% elif verb == Verb.REJECTED_RATING %}
{% blocktrans %}Your rating was rejected{% endblocktrans %}
{% elif verb == Verb.REPORTED_EXTENSION %}
{% blocktrans %}{{ target_type }} reported: "{{ name }}"{% endblocktrans %}
{% elif verb == Verb.REPORTED_RATING %}

View File

@ -15,7 +15,6 @@ VERB2FLAGS = {
Verb.COMMENTED: [Flag.AUTHOR, Flag.REVIEWER],
Verb.DISMISSED_ABUSE_REPORT: [Flag.REPORTER],
Verb.RATED_EXTENSION: [Flag.AUTHOR],
Verb.REJECTED_RATING: [Flag.RATING_AUTHOR],
Verb.REPORTED_EXTENSION: [Flag.MODERATOR],
Verb.REPORTED_RATING: [Flag.MODERATOR],
Verb.REQUESTED_CHANGES: [Flag.AUTHOR, Flag.REVIEWER],

View File

@ -1,11 +1,10 @@
from statistics import median
from actstream import action
from actstream.actions import follow
from django.db.models.signals import post_save, pre_delete
from django.dispatch import receiver
from constants.activity import Flag, Verb
from constants.activity import Verb
from ratings.models import Rating
from ratings.utils import compute_rating_sortkey
@ -44,22 +43,6 @@ def _create_action_from_rating(
)
@receiver(post_save, sender=Rating)
def _follow_rating_as_author(
sender: object,
instance: Rating,
created: bool,
raw: bool,
**kwargs: object,
) -> None:
if raw:
return
if not created:
return
follow(instance.user, instance, send_action=False, flag=Flag.RATING_AUTHOR)
@receiver(pre_delete, sender=Rating)
def _log_deletion(sender: object, instance: Rating, **kwargs: object) -> None:
instance.record_deletion()