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

iplweb / bpp / 0cececd7-a2e7-4a75-a26c-21df764ad54e

24 Aug 2025 10:29PM UTC coverage: 41.169% (-2.5%) from 43.704%
0cececd7-a2e7-4a75-a26c-21df764ad54e

push

circleci

mpasternak
Merge branch 'release/v202508.1206'

1 of 1 new or added line in 1 file covered. (100.0%)

2674 existing lines in 124 files now uncovered.

16057 of 39003 relevant lines covered (41.17%)

0.76 hits per line

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

55.36
src/pbn_api/admin/pbn_export_queue.py
1
from django import forms
2✔
2
from django.http import HttpResponseRedirect
2✔
3
from django.urls import reverse
2✔
4

5
from pbn_api.models.queue import PBN_Export_Queue
2✔
6
from pbn_api.tasks import task_sprobuj_wyslac_do_pbn
2✔
7

8
from django.contrib import admin, messages
2✔
9

10
from django.utils.safestring import mark_safe
2✔
11

12

13
class RenderHTMLWidget(forms.Textarea):
2✔
14
    def render(self, name, value, renderer, attrs=None):
2✔
UNCOV
15
        return mark_safe((value or "").replace("\n", "<br>"))
×
16

17

18
@admin.register(PBN_Export_Queue)
2✔
19
class PBN_Export_QueueAdmin(admin.ModelAdmin):
2✔
20
    list_per_page = 10
2✔
21
    list_display = [
2✔
22
        "rekord_do_wysylki",
23
        "object_id",
24
        "zamowil",
25
        "wysylke_podjeto",
26
        "wysylke_zakonczono",
27
        "ilosc_prob",
28
        "zakonczono_pomyslnie",
29
        "retry_after_user_authorised",
30
    ]
31

32
    search_fields = ["zamowil__username", "zamowil__email"]
2✔
33

34
    list_filter = ["zamowil", "zakonczono_pomyslnie", "retry_after_user_authorised"]
2✔
35

36
    date_hierarchy = "zamowiono"
2✔
37

38
    readonly_fields = [
2✔
39
        "object_id",
40
        "content_type",
41
        "zamowiono",
42
        "zamowil",
43
        "wysylke_podjeto",
44
        "wysylke_zakonczono",
45
        "ilosc_prob",
46
        "zakonczono_pomyslnie",
47
        "retry_after_user_authorised",
48
    ]
49

50
    def has_delete_permission(self, request, *args, **kw):
2✔
51
        if request.user.is_superuser:
1✔
52
            return True
1✔
53
        if "obj" in kw:
×
UNCOV
54
            if kw["obj"].zamowil == request.user:
×
UNCOV
55
                return True
×
UNCOV
56
        return False
×
57

58
    from django.db import models
2✔
59

60
    formfield_overrides = {models.TextField: {"widget": RenderHTMLWidget}}
2✔
61

62
    def _resend_single_item(self, obj, user, message_suffix=""):
2✔
63
        """Common logic for resending a single PBN export queue item"""
UNCOV
64
        obj.refresh_from_db()
×
UNCOV
65
        obj.wysylke_zakonczono = None
×
UNCOV
66
        obj.zakonczono_pomyslnie = None
×
UNCOV
67
        obj.retry_after_user_authorised = None
×
UNCOV
68
        obj.dopisz_komunikat(
×
69
            f"Ponownie wysłano przez użytkownika: {user}{message_suffix}"
70
        )
UNCOV
71
        obj.save()
×
UNCOV
72
        task_sprobuj_wyslac_do_pbn.delay(obj.pk)
×
73

74
    def resend_to_pbn_action(self, request, queryset):
2✔
UNCOV
75
        count = 0
×
UNCOV
76
        for obj in queryset:
×
UNCOV
77
            self._resend_single_item(obj, request.user, " (akcja masowa)")
×
UNCOV
78
            count += 1
×
79

UNCOV
80
        self.message_user(request, f"Ponowiono wysyłkę do PBN dla {count} elementów")
×
81

82
    resend_to_pbn_action.short_description = "Wyślij ponownie"
2✔
83

84
    actions = [resend_to_pbn_action]
2✔
85

86
    def save_form(self, request, form, change):
2✔
UNCOV
87
        return form.save(commit=False)
×
88

89
    def response_change(self, request, obj):
2✔
UNCOV
90
        if "_resend_to_pbn" in request.POST:
×
UNCOV
91
            self._resend_single_item(obj, request.user)
×
UNCOV
92
            self.message_user(request, f"Ponowiono wysyłkę do PBN: {obj}")
×
UNCOV
93
            return HttpResponseRedirect(
×
94
                reverse(
95
                    "admin:{}_{}_change".format(
96
                        obj._meta.app_label, obj._meta.model_name
97
                    ),
98
                    args=[obj.pk],
99
                )
100
            )
UNCOV
101
        return super().response_change(request, obj)
×
102

103
    def has_add_permission(self, request):
2✔
104
        return False
1✔
105

106
    def save_model(self, request, obj, form, change):
2✔
107
        # Uczyń FAKTYCZNIE readonly :-)
UNCOV
108
        messages.error(
×
109
            request,
110
            "Obiekt NIE został zapisany -- nie można edytować tej części serwisu.",
111
        )
UNCOV
112
        return
×
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

© 2025 Coveralls, Inc