Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.states
assets/external/
*.db
*.py[cod]
.web
__pycache__/
venv/
alembic/
alembic.ini
alembic.ini
6 changes: 3 additions & 3 deletions full_stack_python/articles/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class ArticlePublicState(SessionState):
limit: int = 20

@rx.var
def post_id(self):
return self.router.page.params.get("post_id", "")
def post_id(self) -> str:
return self.post_id_web

@rx.var
def post_url(self):
def post_url(self) -> str:
if not self.post:
return f"{ARTICLE_LIST_ROUTE}"
return f"{ARTICLE_LIST_ROUTE}/{self.post.id}"
Expand Down
12 changes: 6 additions & 6 deletions full_stack_python/auth/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@


class SessionState(reflex_local_auth.LocalAuthState):
@rx.cached_var
def my_userinfo_id(self) -> str | None:
@rx.var(cache=True)
def my_userinfo_id(self) -> int | None:
if self.authenticated_user_info is None:
return None
return self.authenticated_user_info.id

@rx.cached_var
def my_user_id(self) -> str | None:
@rx.var(cache=True)
def my_user_id(self) -> int | None:
if self.authenticated_user.id < 0:
return None
return self.authenticated_user.id

@rx.cached_var
@rx.var(cache=True)
def authenticated_username(self) -> str | None:
if self.authenticated_user.id < 0:
return None
return self.authenticated_user.username

@rx.cached_var
@rx.var(cache=True)
def authenticated_user_info(self) -> UserInfo | None:
if self.authenticated_user.id < 0:
return None
Expand Down
14 changes: 10 additions & 4 deletions full_stack_python/blog/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ class BlogPostState(SessionState):
post_publish_active: bool = False

@rx.var
def blog_post_id(self):
return self.router.page.params.get("blog_id", "")
def blog_post_id(self) -> str:
return self.blog_id

@rx.var
def blog_post_url(self):
def blog_post_url(self) -> str:
if not self.post:
return f"{BLOG_POSTS_ROUTE}"
return f"{BLOG_POSTS_ROUTE}/{self.post.id}"

@rx.var
def blog_post_edit_url(self):
def blog_post_edit_url(self) -> str:
if not self.post:
return f"{BLOG_POSTS_ROUTE}"
return f"{BLOG_POSTS_ROUTE}/{self.post.id}/edit"
Expand Down Expand Up @@ -113,6 +113,12 @@ def to_blog_post(self, edit_page=False):
return rx.redirect(f"{self.blog_post_edit_url}")
return rx.redirect(f"{self.blog_post_url}")

def set_post_content(self, value: str):
self.post_content = value

def set_post_publish_active(self, value: bool):
self.post_publish_active = value


class BlogAddPostFormState(BlogPostState):
form_data: dict = {}
Expand Down
2 changes: 1 addition & 1 deletion full_stack_python/contact/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ContactState(SessionState):
did_submit: bool = False

@rx.var
def thank_you(self):
def thank_you(self) -> str:
first_name = self.form_data.get("first_name") or ""
return f"Thank you {first_name}".strip() + "!"

Expand Down
2 changes: 1 addition & 1 deletion full_stack_python/full_stack_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def index() -> rx.Component:

app.add_page(
article_detail_page,
route=f"{navigation.routes.ARTICLE_LIST_ROUTE}/[post_id]",
route=f"{navigation.routes.ARTICLE_LIST_ROUTE}/[post_id_web]",
on_load=ArticlePublicState.get_post_detail
)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
reflex==0.5.3
reflex==0.8.18
reflex-local-auth
6 changes: 5 additions & 1 deletion rxconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

config = rx.Config(
app_name="full_stack_python",
db_url="sqlite:///reflex.db",
db_url="sqlite:///reflex.db",
plugins=[
rx.plugins.SitemapPlugin(),
rx.plugins.TailwindV4Plugin(),
],
)