Skip to content

Commit 0c075bd

Browse files
committed
fixes #120
1 parent eabcbd5 commit 0c075bd

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

render_static/tests/enum_app/templatetags/enum_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def visit(self, enum, is_bool, final):
7070
[prop for prop in self.properties_ if hasattr(enum, prop)]
7171
if self.properties_ else []
7272
)
73-
for param in ['value', 'name']: # pragma: no cover
73+
for param in ['value']: # pragma: no cover
7474
if param not in properties:
7575
properties.insert(0, param)
7676

render_static/tests/js_tests.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,7 +2318,7 @@ def enum_compare(
23182318
[prop for prop in properties if hasattr(cls, prop)]
23192319
if properties else []
23202320
)
2321-
for param in ['value', 'name']: # pragma: no cover
2321+
for param in ['value']: # pragma: no cover
23222322
if param not in properties:
23232323
properties.insert(0, param)
23242324

@@ -2629,13 +2629,12 @@ def test_exclude_props(self):
26292629
STATIC_TEMPLATES={
26302630
'context': {
26312631
'include_properties': True,
2632-
'exclude_properties': ['uri', 'version'],
2632+
'exclude_properties': ['uri', 'version', 'name'],
26332633
'properties': True,
26342634
'test_properties': [
26352635
'slug',
26362636
'label',
2637-
'value',
2638-
'name'
2637+
'value'
26392638
],
26402639
'symmetric_properties': False
26412640
},
@@ -2656,13 +2655,13 @@ def test_exclude_props_param(self):
26562655
js_file=ENUM_STATIC_DIR / 'enum_app/test.js',
26572656
enum_classes=[EnumTester.MapBoxStyle],
26582657
class_properties=False,
2659-
properties=['slug', 'label', 'value', 'name']
2658+
properties=['slug', 'label', 'value']
26602659
)
26612660
contents = get_content(ENUM_STATIC_DIR / 'enum_app/test.js')
26622661
self.assertNotIn('uri', contents)
26632662
self.assertNotIn('version', contents)
2663+
self.assertNotIn('name', contents)
26642664
self.assertIn('this.value = ', contents)
2665-
self.assertIn('this.name = ', contents)
26662665
self.assertIn('this.slug = ', contents)
26672666
self.assertIn('this.label = ', contents)
26682667

render_static/transpilers/enums_to_js.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ def properties(self, enum: Type[Enum]):
169169
170170
:param enum: The enum class being transpiled
171171
"""
172-
builtins = copy(self.builtins_)
172+
builtins = [
173+
bltin for bltin in self.builtins_
174+
if bltin not in self.exclude_properties_
175+
]
173176
if self.include_properties_:
174177
if (
175178
hasattr(list(enum)[0], 'label') and

0 commit comments

Comments
 (0)