wbcore 1.59.6__py2.py3-none-any.whl → 1.59.6rc0__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
wbcore/filters/mixins.py CHANGED
@@ -90,12 +90,12 @@ class WBCoreFilterMixin:
90
90
  "help_text": self.get_help_text(),
91
91
  }
92
92
  lookup_expr = {
93
+ "label": get_lookup_label(self.lookup_expr) if self.lookup_label is None else self.lookup_label,
93
94
  "icon": get_lookup_icon(self.lookup_expr) if self.lookup_icon is None else self.lookup_icon,
95
+ "key": name,
94
96
  "hidden": self.hidden,
95
97
  "allow_exclude": self.allow_exclude,
96
98
  "input_properties": {
97
- "label": get_lookup_label(self.lookup_expr) if self.lookup_label is None else self.lookup_label,
98
- "key": name,
99
99
  "type": self.filter_type,
100
100
  },
101
101
  }
@@ -1,4 +1,4 @@
1
1
  from .bases import ButtonConfig
2
2
  from .buttons import ActionButton, DropDownButton, HyperlinkButton, WidgetButton
3
- from .enums import ButtonDefaultColor, ButtonType
3
+ from .enums import ButtonDefaultColor, ButtonType, HyperlinkTarget
4
4
  from .view_config import ButtonViewConfig
@@ -11,6 +11,7 @@ class ButtonConfig:
11
11
  label: Optional[str] = None
12
12
  icon: Optional[str] = None
13
13
  title: Optional[str] = None
14
+ style: Optional[dict] = None
14
15
  color: ButtonDefaultColor | str = ButtonDefaultColor.PRIMARY
15
16
  weight: int = 100
16
17
  disabled: bool = False
@@ -30,12 +31,16 @@ class ButtonConfig:
30
31
  if iter := getattr(super(), "__iter__", None):
31
32
  yield from iter()
32
33
 
33
- for key in ["label", "icon", "title"]:
34
+ for key in ["label", "icon", "title", "style"]:
34
35
  value = getattr(self, key, None)
35
36
  if value:
36
37
  yield key, value
37
38
  color = getattr(self.color, "value", self.color)
38
39
  yield "color", color
40
+ yield (
41
+ "level",
42
+ color,
43
+ ) # TODO: we return level for backward compatibility reason. to be removed once we move to frontend version 2
39
44
  yield "disabled", self.disabled # set to True if you want to set the css "disabled" property to that button
40
45
  yield "always_render", self.always_render # set to True the button always needs to be rendered (even if empty)
41
46
  yield "placeholder", self.placeholder # set to a valid string if a placeholder is needed onhover
@@ -11,7 +11,7 @@ from wbcore.serializers import ListSerializer, RepresentationSerializer, Seriali
11
11
  from wbcore.utils.urls import get_parse_endpoint, get_urlencode_endpoint
12
12
 
13
13
  from .bases import ButtonConfig, ButtonTypeMixin, ButtonUrlMixin
14
- from .enums import ButtonType
14
+ from .enums import ButtonType, HyperlinkTarget
15
15
 
16
16
 
17
17
  @dataclass
@@ -71,6 +71,12 @@ class WidgetButton(ButtonTypeMixin, ButtonUrlMixin, ButtonConfig):
71
71
  @dataclass
72
72
  class HyperlinkButton(ButtonTypeMixin, ButtonUrlMixin, ButtonConfig):
73
73
  button_type = ButtonType.HYPERLINK
74
+ target: HyperlinkTarget = HyperlinkTarget.BLANK
75
+
76
+ def serialize(self, request, **kwargs):
77
+ res = super().serialize(request, **kwargs)
78
+ res["target"] = self.target.value
79
+ return res
74
80
 
75
81
  def __hash__(self):
76
82
  if self.key:
@@ -66,3 +66,10 @@ class ButtonType(Enum):
66
66
  HYPERLINK = "hyperlink"
67
67
  WIDGET = "widget"
68
68
  ACTION = "action"
69
+
70
+
71
+ class HyperlinkTarget(Enum):
72
+ BLANK = "_blank"
73
+ SELF = "_self"
74
+ PARENT = "_parent"
75
+ TOP = "_top"
@@ -11,7 +11,7 @@ from wbcore.metadata.configs.buttons import (
11
11
  HyperlinkButton,
12
12
  WidgetButton,
13
13
  )
14
- from wbcore.metadata.configs.buttons.enums import ButtonDefaultColor
14
+ from wbcore.metadata.configs.buttons.enums import ButtonDefaultColor, HyperlinkTarget
15
15
  from wbcore.metadata.configs.display.instance_display import create_simple_display
16
16
  from wbcore.metadata.utils import prefix_key
17
17
 
@@ -31,6 +31,7 @@ class TestDropDownButton:
31
31
  assert serialized_btn["icon"] == button.icon
32
32
  assert serialized_btn["title"] == button.title
33
33
  assert serialized_btn["color"] == button.color
34
+ assert serialized_btn["level"] == button.color
34
35
  assert serialized_btn["buttons"] == [button.buttons[0].serialize(rf)]
35
36
  assert serialized_btn["type"] == DropDownButton.button_type.value
36
37
 
@@ -42,6 +43,7 @@ class TestDropDownButton:
42
43
  assert serialized_btn["icon"] == button.icon
43
44
  assert serialized_btn["title"] == button.title
44
45
  assert serialized_btn["color"] == button.color
46
+ assert serialized_btn["level"] == button.color
45
47
  assert serialized_btn["buttons"] == [nested_button.serialize(rf, key_prefix=key_prefix)]
46
48
  assert serialized_btn["type"] == DropDownButton.button_type.value
47
49
  assert serialized_btn["buttons"][0]["key"] == prefix_key(nested_button.key, key_prefix)
@@ -76,6 +78,7 @@ class TestWidgetButton:
76
78
  assert serialized_btn["icon"] == key_button.icon
77
79
  assert serialized_btn["title"] == key_button.title
78
80
  assert serialized_btn["color"] == key_button.color
81
+ assert serialized_btn["level"] == key_button.color
79
82
  assert serialized_btn["key"] == key_button.key
80
83
  assert serialized_btn["type"] == self.button_class.button_type.value
81
84
 
@@ -86,6 +89,7 @@ class TestWidgetButton:
86
89
  assert serialized_btn["icon"] == key_button.icon
87
90
  assert serialized_btn["title"] == key_button.title
88
91
  assert serialized_btn["color"] == key_button.color
92
+ assert serialized_btn["level"] == key_button.color
89
93
  assert serialized_btn["type"] == self.button_class.button_type.value
90
94
  assert serialized_btn["key"] == prefix_key(key_button.key, key_prefix)
91
95
 
@@ -100,6 +104,7 @@ class TestWidgetButton:
100
104
  assert serialized_btn["icon"] == endpoint_button.icon
101
105
  assert serialized_btn["title"] == endpoint_button.title
102
106
  assert serialized_btn["color"] == endpoint_button.color
107
+ assert serialized_btn["level"] == endpoint_button.color
103
108
  assert serialized_btn["endpoint"] == endpoint_button.endpoint
104
109
  assert serialized_btn["type"] == self.button_class.button_type.value
105
110
 
@@ -113,11 +118,18 @@ class TestWidgetButton:
113
118
  class TestHyperlinkButtonutton(TestWidgetButton):
114
119
  button_class = HyperlinkButton
115
120
 
121
+ def test_serialize(self, rf, key_button):
122
+ super().test_serialize(rf, key_button)
123
+ key_button.target = random.choice(list(HyperlinkTarget))
124
+ serialized_btn = key_button.serialize(rf)
125
+ assert serialized_btn["target"] == key_button.target.value
126
+
116
127
  def test_serialize_endpoint_button(self, rf, endpoint_button):
117
128
  serialized_btn = endpoint_button.serialize(rf)
118
129
  assert serialized_btn["icon"] == endpoint_button.icon
119
130
  assert serialized_btn["title"] == endpoint_button.title
120
131
  assert serialized_btn["color"] == endpoint_button.color
132
+ assert serialized_btn["level"] == endpoint_button.color
121
133
  assert serialized_btn["endpoint"] == endpoint_button.endpoint
122
134
  assert serialized_btn["type"] == self.button_class.button_type.value
123
135
 
@@ -13,7 +13,7 @@ from wbcore.signals import (
13
13
  from wbcore.utils.importlib import parse_signal_received_for_module
14
14
 
15
15
  from .mixins import WBCoreSerializerFieldMixin
16
- from .text import StringRelatedField
16
+ from .text import TextField
17
17
  from .types import WBCoreType
18
18
 
19
19
  logger = logging.getLogger(__name__)
@@ -155,8 +155,6 @@ class AdditionalResourcesField(WBCoreSerializerFieldMixin, serializers.ReadOnlyF
155
155
 
156
156
 
157
157
  class HyperlinkField(WBCoreSerializerFieldMixin, serializers.ReadOnlyField):
158
- field_type = WBCoreType.HYPERLINK.value
159
-
160
158
  def __init__(self, *args, **kwargs):
161
159
  self.reverse_name = kwargs.pop("reverse_name")
162
160
  self.id_field_name = kwargs.pop("id_field_name", "id")
@@ -180,7 +178,7 @@ class SlugRelatedField(WBCoreSerializerFieldMixin, serializers.SlugRelatedField)
180
178
 
181
179
 
182
180
  class SerializerMethodField(WBCoreSerializerFieldMixin, serializers.SerializerMethodField):
183
- def __init__(self, method_name=None, field_class=StringRelatedField, **kwargs):
181
+ def __init__(self, method_name=None, field_class=TextField, **kwargs):
184
182
  self.field_class = field_class
185
183
  self.initkwargs = kwargs
186
184
  super().__init__(method_name, **kwargs)
@@ -31,7 +31,6 @@ class WBCoreType(Enum):
31
31
  URL = "url"
32
32
  SPARKLINE = "sparkline"
33
33
  LANGUAGE = "language"
34
- HYPERLINK = "hyperlink"
35
34
 
36
35
 
37
36
  class ReturnContentType(Enum):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wbcore
3
- Version: 1.59.6
3
+ Version: 1.59.6rc0
4
4
  Author-email: Christopher Wittlinger <c.wittlinger@stainly.com>
5
5
  Requires-Dist: celery[redis]==5.*
6
6
  Requires-Dist: croniter==2.*
@@ -970,7 +970,7 @@ wbcore/filters/backends.py,sha256=7XX5LcFrAFE5jvFj5qSjww4VMux8aKRlcQKmZxdIiKY,73
970
970
  wbcore/filters/defaults.py,sha256=poSD8Ww2NumwYjZ01zS0iBsNCmv6Bee1z3bDSYdX17A,1988
971
971
  wbcore/filters/filterset.py,sha256=TTk4mQq9DFCXdyzMq3Ig6e5uIbmjsr4HT2kswOgiuPc,11775
972
972
  wbcore/filters/lookups.py,sha256=IYuQqEcYutiXk9UpzY3qKSCaCR2vyllB0RXBj98o8Ao,1186
973
- wbcore/filters/mixins.py,sha256=YIy2SEOtDjUVb7oePiC5oPjQEIdiwym02BHAyDkdep4,4495
973
+ wbcore/filters/mixins.py,sha256=eIXW2Wq_VO3sXioQKcYdyTvZPHS06tytcGo4ZHEasvA,4487
974
974
  wbcore/filters/utils.py,sha256=wSs0g7mKF6n_ziSEDItfFYcuHwZTXyu78D6LHxzY2Bk,786
975
975
  wbcore/filters/fields/__init__.py,sha256=ZucwBossNTlvcUfRullicg0ovghQEGO0jxY5eQ3UaEs,546
976
976
  wbcore/filters/fields/booleans.py,sha256=6BrK3p1Bv_KIlVCeMOgJ7V8_P8tWQKBnxTOBOBSsGvE,175
@@ -1023,10 +1023,10 @@ wbcore/metadata/configs/primary_keys.py,sha256=MZSAHZpAOvVtd-zGkkcrZ88EzlGUL6ewO
1023
1023
  wbcore/metadata/configs/search_fields.py,sha256=FOq3zk6jSPQ24m1QII0iV-eLTcD_Z4IPp8TnBjVdFXI,275
1024
1024
  wbcore/metadata/configs/titles.py,sha256=Iha24FKpL6BacGlN61-_O4f7v9meHwJDkG4W09PWi5s,1841
1025
1025
  wbcore/metadata/configs/window_types.py,sha256=RbUbUvid9qMIXZMI0sqLTanZcWCP-pmwm-_33z_3hQs,451
1026
- wbcore/metadata/configs/buttons/__init__.py,sha256=s_FcAPwADxa8YE3gTbhbeqZhqBfoCZR3j4laLt7gpOo,205
1027
- wbcore/metadata/configs/buttons/bases.py,sha256=rAw5Te9V5y6tCCKOTbZXz-uln0vT7io2oPV6QDn1Ijc,2823
1028
- wbcore/metadata/configs/buttons/buttons.py,sha256=0dKPokHYMis_SZhFZ1gTHayFTMQk5nVAvyDetTNdQ6o,5033
1029
- wbcore/metadata/configs/buttons/enums.py,sha256=vkJBfNFPTIIFvYrDGxrugqgRe22_KcqFRU39jo8ZvFw,1472
1026
+ wbcore/metadata/configs/buttons/__init__.py,sha256=JAMiJMEDtsWqHh5O4-gsZBuPINZGHzMKVYxrIxvphTM,222
1027
+ wbcore/metadata/configs/buttons/bases.py,sha256=WbiCoNyvzCQkXdT3A4Hq0vGL0-0oY2i-BIOulaTeHXs,3040
1028
+ wbcore/metadata/configs/buttons/buttons.py,sha256=JRj84v3EA7z8tzBvLPup_4etiU0oSTO7HDQB4TYaDh4,5259
1029
+ wbcore/metadata/configs/buttons/enums.py,sha256=J7gGqVtmlUj6JM9elK-WDeZ4v5FuFkDMjNJDU1rO9cY,1583
1030
1030
  wbcore/metadata/configs/buttons/metadata.py,sha256=OhSkW18R6B_uJrtcGjN8VEkNCPlXD2DxuYWCqZXQbD0,348
1031
1031
  wbcore/metadata/configs/buttons/view_config.py,sha256=31fFJFeV9iM24FQY7I6XaPthokJdCuzSeCBdAB1xGnE,5308
1032
1032
  wbcore/metadata/configs/display/__init__.py,sha256=K3CdAUuC-YbowUusZ9F6vGfepppSqE8cfvazczEGePo,272
@@ -1052,7 +1052,7 @@ wbcore/metadata/configs/display/instance_display/layouts/inlines.py,sha256=xfcZ7
1052
1052
  wbcore/metadata/configs/display/instance_display/layouts/layouts.py,sha256=3nY6M-4ZmE9labpY80wx_yPIqQmQw0_mjG5smmrujl8,3264
1053
1053
  wbcore/metadata/configs/display/instance_display/layouts/sections.py,sha256=yFo5i-41KJp733MoDlzonaXDylOn0pbBlwqd7late0A,1298
1054
1054
  wbcore/metadata/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1055
- wbcore/metadata/tests/test_buttons.py,sha256=CxwzXS8rFW5N37GrkZl9AI2NyhMdlVCAETyPETe6fBc,6696
1055
+ wbcore/metadata/tests/test_buttons.py,sha256=cOH77BKzHtsvc4D7LnTu3037fFmE_jzekQQhX0lgeN8,7345
1056
1056
  wbcore/migrations/0001_initial_squashed_squashed_0010_preset_appliedpreset.py,sha256=6RxsuOPKfhSSox5DC0bwUrI-oR9bGPkSyI1zDv5juSM,16460
1057
1057
  wbcore/migrations/0011_genericmodel.py,sha256=w-SK0-EwQCbXtLyFz3V-rBY-hj8bw7_n0xe0NM2HF8U,588
1058
1058
  wbcore/migrations/0012_delete_notification.py,sha256=HM0oUd05bgpuupsO_oG7t-C3lXInpq_Sg1vcEIyfHd0,293
@@ -1102,7 +1102,7 @@ wbcore/serializers/fields/__init__.py,sha256=xNNak0yl8FtC6m-__B5mfieSNGAygXND34E
1102
1102
  wbcore/serializers/fields/boolean.py,sha256=vwP7HQflArFEG0w9FfXkPYKreFJ5qMjs-L0qKMeKCVQ,1682
1103
1103
  wbcore/serializers/fields/choice.py,sha256=ozVwKaPCpsgPuQXQWr8TxHIcxSdGvhw23OFVD0xnipg,2128
1104
1104
  wbcore/serializers/fields/datetime.py,sha256=UVrBAdh-Iy3cDdVxbce9rsPYwwfxDJ-kJEr_1K_29ec,7386
1105
- wbcore/serializers/fields/fields.py,sha256=R_JJxnSfgKK6pYFgfe_-7qo_y25YksQ-WuNgiKWev4U,7068
1105
+ wbcore/serializers/fields/fields.py,sha256=nRvVGqjaqgDThKKuMptrM5_IOKNi_hkGuL5rP2cr4Uw,7005
1106
1106
  wbcore/serializers/fields/file.py,sha256=tDDK2bITiP7zxl9Ilzja2_gWae_lf9CkO1rDEBPaj6g,568
1107
1107
  wbcore/serializers/fields/fsm.py,sha256=xUYxDj166PDnmDLggI4fShXdSunJVzbc8quFQioM3Yc,700
1108
1108
  wbcore/serializers/fields/json.py,sha256=8SmEOW2hXnTTfuCztaxA8AA3qtTxhCZtft7BJm1yO6o,2225
@@ -1113,7 +1113,7 @@ wbcore/serializers/fields/other.py,sha256=3r_70JH_A_daS99LuwQWwa0LNtyosKW7QKJzZg
1113
1113
  wbcore/serializers/fields/primary_key.py,sha256=yTbs5B2QlUX-XKEtop3JpwIPeP-FhM8u-2qDXM5q6u0,676
1114
1114
  wbcore/serializers/fields/related.py,sha256=mq7QhcjSG273G400ZueYJnNVNDlGgnUHLoAHaKRjW_Q,6355
1115
1115
  wbcore/serializers/fields/text.py,sha256=8cmRiH1RpCDGzuUmO1zMmm8uiybXDMqyuBkjFblNMmQ,5060
1116
- wbcore/serializers/fields/types.py,sha256=Jf2lcNRKOnxMn55JZTTcvACRpADXwwXgPX3ojigrung,1011
1116
+ wbcore/serializers/fields/types.py,sha256=eiSOajWwlZjFfXnMGjIakAa7WGzXHjtRQwT0LH-2_oA,983
1117
1117
  wbcore/shares/__init__.py,sha256=uhHkbgHoFgbcsxHUPxNNzNs11oIjjQ7zIxG8FzsREAI,32
1118
1118
  wbcore/shares/config.py,sha256=7-Tfit2PFUVpr9qbapcmtZbjeMiUHSyfYX6PKGwnj_w,2292
1119
1119
  wbcore/shares/decorator.py,sha256=vFoVidO2IxLzYPZ-qWDWjjPxbCzFAvw4FVl2YZfPPAQ,448
@@ -1233,6 +1233,6 @@ wbcore/viewsets/generics.py,sha256=lKDq9UY_Tyc56u1bqaIEvHGgoaXwXxpZ1c3fLVteptI,1
1233
1233
  wbcore/viewsets/mixins.py,sha256=IdHd_uixOv3ExKoHxTgL5Bt8OELIwfYwhBZm0nsvZfc,12054
1234
1234
  wbcore/viewsets/utils.py,sha256=4520Ij3ASM8lOa8QZkCqbBfOexVRiZu688eW-PGqMOA,882
1235
1235
  wbcore/viewsets/viewsets.py,sha256=FPPESunEjlunDr5VFsjTfsquTS3iDSQkw0H6QjMKPqk,6574
1236
- wbcore-1.59.6.dist-info/METADATA,sha256=etXZZxWC9mm2rclCXLdO4ygq24nRItcmZVUhHXN3Y90,2316
1237
- wbcore-1.59.6.dist-info/WHEEL,sha256=aha0VrrYvgDJ3Xxl3db_g_MDIW-ZexDdrc_m-Hk8YY4,105
1238
- wbcore-1.59.6.dist-info/RECORD,,
1236
+ wbcore-1.59.6rc0.dist-info/METADATA,sha256=VTbp66knyzJHTclsb0mYzK-P6lyCammJjAim7lZ3MGM,2319
1237
+ wbcore-1.59.6rc0.dist-info/WHEEL,sha256=aha0VrrYvgDJ3Xxl3db_g_MDIW-ZexDdrc_m-Hk8YY4,105
1238
+ wbcore-1.59.6rc0.dist-info/RECORD,,