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

liqd / adhocracy-plus / 18908688697

29 Oct 2025 12:59PM UTC coverage: 44.622% (-44.5%) from 89.135%
18908688697

Pull #2986

github

web-flow
Merge 1dfde8ee7 into 445e1d498
Pull Request #2986: Draft: Speed up Github Ci Tests

3012 of 6750 relevant lines covered (44.62%)

0.45 hits per line

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

58.54
/apps/contrib/widgets.py
1
from django import forms
1✔
2
from django.template.loader import render_to_string
1✔
3
from django.utils.translation import gettext_lazy as _
1✔
4

5
from adhocracy4.filters.widgets import FreeTextFilterWidget as A4FreeTextFilterWidget
1✔
6
from adhocracy4.filters.widgets import OrderingWidget
1✔
7
from adhocracy4.images.widgets import ImageInputWidget
1✔
8

9

10
class Select2Mixin:
1✔
11
    def __init__(self, *args, **kwargs):
1✔
12
        if "attrs" not in kwargs:
×
13
            kwargs["attrs"] = {}
×
14
        if "class" not in kwargs["attrs"]:
×
15
            kwargs["attrs"]["class"] = ""
×
16
        kwargs["attrs"]["class"] += " js-select2"
×
17

18
        super().__init__(*args, **kwargs)
×
19

20
    class Media:
1✔
21
        js = ("select2.js",)
1✔
22

23

24
class Select2Widget(Select2Mixin, forms.Select):
1✔
25
    pass
1✔
26

27

28
class Select2MultipleWidget(Select2Mixin, forms.SelectMultiple):
1✔
29
    pass
1✔
30

31

32
class TextWithDatalistWidget(forms.TextInput):
1✔
33
    def render(self, name, value, attrs=None, renderer=None):
1✔
34
        attrs = self.build_attrs(self.attrs, attrs)
×
35
        options = self.get_options(attrs.pop("options"))
×
36

37
        if "list" not in attrs:
×
38
            attrs["list"] = attrs["id"] + "_datalist"
×
39

40
        return render_to_string(
×
41
            "a4_candy_contrib/text_with_datalist.html",
42
            {
43
                "text_input": super().render(name, value, attrs, renderer),
44
                "id_for_datalist": attrs["list"],
45
                "options": options,
46
            },
47
        )
48

49
    def get_options(self, options):
1✔
50
        if callable(options):
×
51
            return options()
×
52
        if options:
×
53
            return options
×
54
        return {}
×
55

56

57
class AplusOrderingWidget(OrderingWidget):
1✔
58
    label = _("Ordering")
1✔
59

60
    def option_string(self):
1✔
61
        return '<li><a%(attrs)s href="?%(query_string)s#index">%(label)s</a></li>'
×
62

63

64
class FreeTextFilterWidget(A4FreeTextFilterWidget):
1✔
65
    label = _("Search")
1✔
66

67

68
class ImageInputWidgetSimple(ImageInputWidget):
1✔
69
    """Almost same as ImageInputWidget.
70

71
    Only difference is that it is not showing info box about image
72
    only being uploaded after clicking save.
73
    """
74

75
    widget_template_name = "a4images/image_upload_widget_simple.html"
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

© 2025 Coveralls, Inc