• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rafalp / Misago / 9487666026

12 Jun 2024 06:16PM UTC coverage: 97.699% (-1.0%) from 98.716%
9487666026

push

github

web-flow
Replace forum options with account settings (#1742)

1947 of 1979 new or added lines in 68 files covered. (98.38%)

661 existing lines in 143 files now uncovered.

52601 of 53840 relevant lines covered (97.7%)

0.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.65
/misago/threads/api/threadendpoints/delete.py
1
from django.db import transaction
1✔
2
from rest_framework.response import Response
1✔
3

4
from ...moderation import threads as moderation
1✔
5
from ...permissions import allow_delete_thread
1✔
6
from ...serializers import DeleteThreadsSerializer
1✔
7

8

9
@transaction.atomic
1✔
10
def delete_thread(request, thread):
1✔
11
    allow_delete_thread(request.user_acl, thread)
1✔
12
    moderation.delete_thread(request, thread)
1✔
13
    return Response({})
1✔
14

15

16
def delete_bulk(request, viewmodel):
1✔
17
    serializer = DeleteThreadsSerializer(
1✔
18
        data={"threads": request.data},
19
        context={
20
            "request": request,
21
            "settings": request.settings,
22
            "viewmodel": viewmodel,
23
        },
24
    )
25

26
    if not serializer.is_valid():
1✔
27
        if "threads" in serializer.errors:
1✔
28
            errors = serializer.errors["threads"]
1✔
29
            if "details" in errors:
1✔
30
                return Response(hydrate_error_details(errors["details"]), status=400)
1✔
31
            # Fix for KeyError - errors[0]
32
            try:
1✔
33
                return Response({"detail": errors[0]}, status=403)
1✔
34
            except KeyError:
1✔
35
                return Response({"detail": list(errors.values())[0][0]}, status=403)
1✔
36

UNCOV
37
        errors = list(serializer.errors)[0][0]
×
UNCOV
38
        return Response({"detail": errors}, status=400)
×
39

UNCOV
40
    for thread in serializer.validated_data["threads"]:
×
UNCOV
41
        with transaction.atomic():
×
UNCOV
42
            delete_thread(request, thread)
×
43

UNCOV
44
    return Response([])
×
45

46

47
def hydrate_error_details(errors):
1✔
48
    for error in errors:
1✔
49
        error["thread"]["id"] = int(error["thread"]["id"])
1✔
50
    return errors
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc