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

iplweb / bpp / 84dc4c46-fc80-4fbb-a935-d485d9d0d8ef

17 Feb 2025 01:12AM UTC coverage: 42.994% (-5.0%) from 48.012%
84dc4c46-fc80-4fbb-a935-d485d9d0d8ef

push

circleci

mpasternak
Fix tests

10 of 11 new or added lines in 2 files covered. (90.91%)

825 existing lines in 39 files now uncovered.

15089 of 35096 relevant lines covered (42.99%)

0.79 hits per line

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

37.5
src/pbn_api/admin/widgets.py
1
# Register your models here.
2
import json
2✔
3

4
from django.forms import widgets
2✔
5

6

7
class PrettyJSONWidget(widgets.Textarea):
2✔
8
    show_only_current = False
2✔
9

10
    def format_value(self, value):
2✔
UNCOV
11
        try:
×
12
            v = json.loads(value)
×
13
            if self.show_only_current:
×
14
                # Pokazuj tylko ostatniÄ… wersjÄ™ z PBNu
15
                v = [value for value in v if value.get("current", False) is True]
×
16
            value = json.dumps(v, indent=4, sort_keys=True)
×
17
            # these lines will try to adjust size of TextArea to fit to content
18
            row_lengths = [len(r) for r in value.split("\n")]
×
UNCOV
19
            self.attrs["rows"] = min(max(len(row_lengths) + 2, 10), 60)
×
UNCOV
20
            self.attrs["cols"] = min(max(max(row_lengths) + 2, 40), 120)
×
UNCOV
21
            return value
×
UNCOV
22
        except Exception:
×
23
            # logger.warning("Error while formatting JSON: {}".format(e))
UNCOV
24
            return super().format_value(value)
×
25

26

27
class PrettyJSONWidgetReadonly(PrettyJSONWidget):
2✔
28
    def __init__(self, attrs=None):
2✔
UNCOV
29
        default_attrs = {"readonly": True}
×
UNCOV
30
        if attrs:
×
UNCOV
31
            default_attrs.update(attrs)
×
UNCOV
32
        super().__init__(default_attrs)
×
33

34

35
class PrettyJSONWidgetReadonlyOnlyCurrent(PrettyJSONWidgetReadonly):
2✔
36
    show_only_current = True
2✔
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