Skip to content

Commit c738226

Browse files
committed
Change all magic methods to start with a dollar sign to signify they aren't normal.
1 parent cc377ff commit c738226

File tree

9 files changed

+19
-19
lines changed

9 files changed

+19
-19
lines changed

django_unicorn/views.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,15 @@ def message(request: HttpRequest, component_name: str = None) -> JsonResponse:
347347
else:
348348
(method_name, params) = parse_call_method_name(call_method_name)
349349

350-
if method_name == "refresh":
350+
if method_name == "$refresh":
351351
# Handle the refresh special action
352352
component = UnicornView.create(
353353
component_id=component_request.id,
354354
component_name=component_name,
355355
use_cache=True,
356356
request=request,
357357
)
358-
elif method_name == "reset":
358+
elif method_name == "$reset":
359359
# Handle the reset special action
360360
component = UnicornView.create(
361361
component_id=component_request.id,
@@ -367,13 +367,13 @@ def message(request: HttpRequest, component_name: str = None) -> JsonResponse:
367367
# Explicitly remove all errors and prevent validation from firing before render()
368368
component.errors = {}
369369
is_reset_called = True
370-
elif method_name == "toggle":
370+
elif method_name == "$toggle":
371371
for property_name in params:
372372
property_value = _get_property_value(component, property_name)
373373
property_value = not property_value
374374

375375
_set_property_value(component, property_name, property_value)
376-
elif method_name == "validate":
376+
elif method_name == "$validate":
377377
# Handle the validate special action
378378
validate_all_fields = True
379379
else:

example/unicorn/templates/unicorn/hello-world-test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div>
2-
<button unicorn:click="reset">Reset the component</button>
2+
<button unicorn:click="$reset">Reset the component</button>
33
<br />
44
<br />
55

example/unicorn/templates/unicorn/html-inputs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h2>Checkbox</h2>
88
<div>
99
<h2>Boolean Toggles</h2>
1010
{% if another_check %}YAYAYA{% else %}Noooooooo{% endif %}<br />
11-
<button unicorn:click="toggle('is_checked', 'another_check')" id="toggle-check">Toggle booleans</button>
11+
<button unicorn:click="$toggle('is_checked', 'another_check')" id="toggle-check">Toggle booleans</button>
1212
</div>
1313

1414
<div>

example/unicorn/templates/unicorn/models.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,6 @@ <h4>PK: {{ flavor.pk }}</h4>
101101
</div>
102102
<br />
103103

104-
<button unicorn:click="refresh">Refresh</button>
105-
<button unicorn:click="reset">Reset</button>
104+
<button unicorn:click="$refresh">$refresh</button>
105+
<button unicorn:click="$reset">$reset</button>
106106
</div>

example/unicorn/templates/unicorn/objects.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@
7373
</ul>
7474
</div>
7575

76-
<button u:click="reset">reset</button>
77-
<button u:click="refresh">refresh</button>
76+
<button u:click="$reset">$reset</button>
77+
<button u:click="$refresh">$refresh</button>
7878
</div>

example/unicorn/templates/unicorn/text-inputs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div>
2-
<button unicorn:click="reset">Reset the component</button>
2+
<button unicorn:click="$reset">Reset the component</button>
33
<br />
44
<br />
55

example/unicorn/templates/unicorn/validation.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
<a href="blob" unicorn:click.prevent="text='prevent?'">set_text_no_validation()</a>
4949
<button unicorn:click="set_text_no_validation">set_text_no_validation()</button>
5050
<button unicorn:click="set_text_with_validation">set_text_with_validation()</button>
51-
<button unicorn:click="validate">validate()</button>
52-
<button unicorn:click="reset">reset()</button>
53-
<button unicorn:click="reset()">reset() 2</button>
54-
<button unicorn:click="refresh">refresh()</button>
51+
<button unicorn:click="$validate">$validate</button>
52+
<button unicorn:click="$reset">$reset</button>
53+
<button unicorn:click="$reset()">$reset()</button>
54+
<button unicorn:click="$refresh">$refresh</button>
5555
</div>
5656
</div>
5757
</div>

tests/views/message/test_call_method.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_message_call_method_toggle(client):
6969
data = {}
7070
message = {
7171
"actionQueue": [
72-
{"payload": {"name": "toggle('check')"}, "type": "callMethod",}
72+
{"payload": {"name": "$toggle('check')"}, "type": "callMethod",}
7373
],
7474
"data": data,
7575
"checksum": generate_checksum(orjson.dumps(data)),
@@ -91,7 +91,7 @@ def test_message_call_method_nested_toggle(client):
9191
data = {}
9292
message = {
9393
"actionQueue": [
94-
{"payload": {"name": "toggle('nested.check')"}, "type": "callMethod",}
94+
{"payload": {"name": "$toggle('nested.check')"}, "type": "callMethod",}
9595
],
9696
"data": data,
9797
"checksum": generate_checksum(orjson.dumps(data)),

tests/views/message/test_db_input.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_message_db_input_update(client):
2121
},
2222
"type": "dbInput",
2323
},
24-
{"type": "callMethod", "payload": {"name": "refresh", "params": []}},
24+
{"type": "callMethod", "payload": {"name": "$refresh", "params": []}},
2525
],
2626
"data": data,
2727
"checksum": generate_checksum(orjson.dumps(data)),
@@ -68,7 +68,7 @@ def test_message_db_input_create(client):
6868
},
6969
"type": "dbInput",
7070
},
71-
{"type": "callMethod", "payload": {"name": "refresh", "params": []}},
71+
{"type": "callMethod", "payload": {"name": "$refresh", "params": []}},
7272
],
7373
"data": data,
7474
"checksum": generate_checksum(orjson.dumps(data)),

0 commit comments

Comments
 (0)