Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork23
UserModel
related hooks, decorators, and settings#190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
6257c02
2762345
72055e2
cb1c172
6815927
a1809d1
81780dc
2f0735e
9a597a7
65119e3
b32ca1a
4d3b538
e2ae741
b312ff6
70c03b8
510f6a9
299f330
a5b2a18
b0bdbfc
f6abbbe
99a2a6d
adfc583
09dc565
29cccab
a516d7e
a9d98d5
41da464
c2cc324
bfab781
7fc1af9
e7b655f
95d4062
b46a173
b7481b5
de70662
e62317b
e7ef0bd
2beda54
dd408ac
8089f71
a660fc4
2bd4ccd
17c4a09
4f93fa7
3d791d9
1429c68
eb237dd
728813d
aeaecc5
5b757bf
357b473
51da91d
de49947
57d1bbe
295cfdb
3914b92
05ed7b4
2daf08f
201da96
ac960cd
8030a29
f1aa07a
d799615
fd64b77
922a69f
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,5 +4,6 @@ | ||
@component | ||
def my_component(): | ||
connection = use_connection() | ||
return html.div(str(connection)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,5 +4,6 @@ | ||
@component | ||
def my_component(): | ||
location = use_location() | ||
return html.div(str(location)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,5 +4,6 @@ | ||
@component | ||
def my_component(): | ||
origin = use_origin() | ||
return html.div(origin or "No origin") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,5 +4,6 @@ | ||
@component | ||
def my_component(): | ||
scope = use_scope() | ||
return html.div(str(scope)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from reactpy import component, html | ||
from reactpy_django.hooks import use_user_data | ||
@component | ||
def my_component(): | ||
user_data = use_user_data( | ||
default_data={ | ||
"basic_example": "123", | ||
"computed_example_sync": sync_default, | ||
"computed_example_async": async_default, | ||
} | ||
) | ||
return html.div( | ||
html.div(f"Data: {user_data.query.data}"), | ||
) | ||
def sync_default(): | ||
return ... | ||
async def async_default(): | ||
return ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from reactpy import component, html | ||
from reactpy_django.hooks import use_user_data | ||
@component | ||
def my_component(): | ||
query, mutation = use_user_data() | ||
def on_submit(event): | ||
if event["key"] == "Enter" and query.data: | ||
new_key = str(len(query.data)) | ||
mutation({**query.data, new_key: event["target"]["value"]}) | ||
return html.div( | ||
html.div(f"Data: {query.data}"), | ||
html.div(f"Loading: {query.loading | mutation.loading}"), | ||
html.div(f"Error(s): {query.error} {mutation.error}"), | ||
html.input({"on_key_press": on_submit}), | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from reactpy import component, html | ||
from reactpy_django.hooks import use_user | ||
@component | ||
def my_component(): | ||
user = use_user() | ||
return html.div(user.username) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
from reactpy import component, html | ||
from reactpy_django.decorators importuser_passes_test | ||
@component | ||
def my_component_fallback(): | ||
return html.div("I am NOT logged in!") | ||
def auth_check(user): | ||
return user.is_authenticated | ||
@user_passes_test(auth_check, fallback=my_component_fallback) | ||
@component | ||
def my_component(): | ||
return html.div("I am logged in!") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from reactpy import component, html | ||
from reactpy_django.decorators import user_passes_test | ||
def auth_check(user): | ||
return user.is_authenticated | ||
@user_passes_test(auth_check, fallback=html.div("I am NOT logged in!")) | ||
@component | ||
def my_component(): | ||
return html.div("I am logged in!") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from reactpy import component, html | ||
from reactpy_django.decorators import user_passes_test | ||
def auth_check(user): | ||
return user.is_authenticated | ||
@user_passes_test(auth_check) | ||
@component | ||
def my_component(): | ||
return html.div("I am logged in!") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
body[data-md-color-scheme="slate"] { | ||
--md-banner-bg-color:rgb(55, 81, 78); | ||
--md-banner-font-color: #fff; | ||
} | ||
Uh oh!
There was an error while loading.Please reload this page.