Skip to content

Commit

Permalink
fixes #120
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Oct 24, 2023
1 parent eabcbd5 commit 0c075bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion render_static/tests/enum_app/templatetags/enum_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def visit(self, enum, is_bool, final):
[prop for prop in self.properties_ if hasattr(enum, prop)]
if self.properties_ else []
)
for param in ['value', 'name']: # pragma: no cover
for param in ['value']: # pragma: no cover
if param not in properties:
properties.insert(0, param)

Expand Down
11 changes: 5 additions & 6 deletions render_static/tests/js_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2318,7 +2318,7 @@ def enum_compare(
[prop for prop in properties if hasattr(cls, prop)]
if properties else []
)
for param in ['value', 'name']: # pragma: no cover
for param in ['value']: # pragma: no cover
if param not in properties:
properties.insert(0, param)

Expand Down Expand Up @@ -2629,13 +2629,12 @@ def test_exclude_props(self):
STATIC_TEMPLATES={
'context': {
'include_properties': True,
'exclude_properties': ['uri', 'version'],
'exclude_properties': ['uri', 'version', 'name'],
'properties': True,
'test_properties': [
'slug',
'label',
'value',
'name'
'value'
],
'symmetric_properties': False
},
Expand All @@ -2656,13 +2655,13 @@ def test_exclude_props_param(self):
js_file=ENUM_STATIC_DIR / 'enum_app/test.js',
enum_classes=[EnumTester.MapBoxStyle],
class_properties=False,
properties=['slug', 'label', 'value', 'name']
properties=['slug', 'label', 'value']
)
contents = get_content(ENUM_STATIC_DIR / 'enum_app/test.js')
self.assertNotIn('uri', contents)
self.assertNotIn('version', contents)
self.assertNotIn('name', contents)
self.assertIn('this.value = ', contents)
self.assertIn('this.name = ', contents)
self.assertIn('this.slug = ', contents)
self.assertIn('this.label = ', contents)

Expand Down
5 changes: 4 additions & 1 deletion render_static/transpilers/enums_to_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ def properties(self, enum: Type[Enum]):
:param enum: The enum class being transpiled
"""
builtins = copy(self.builtins_)
builtins = [
bltin for bltin in self.builtins_
if bltin not in self.exclude_properties_
]
if self.include_properties_:
if (
hasattr(list(enum)[0], 'label') and
Expand Down

0 comments on commit 0c075bd

Please sign in to comment.