Skip to content

Commit

Permalink
draft users for ui
Browse files Browse the repository at this point in the history
  • Loading branch information
jrycw committed Feb 26, 2024
1 parent e48d46f commit 6f3fa53
Show file tree
Hide file tree
Showing 7 changed files with 344 additions and 44 deletions.
28 changes: 28 additions & 0 deletions app/fastui/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import datetime # noqa: F401
import uuid # noqa: F401

from pydantic import BaseModel, Field # noqa: F401


class UserCreationForm(BaseModel):
name: str = Field(title="Username", description="max length: 50", max_length=50)


# class UserDeletionForm(BaseModel):
# confirm: bool = False


class UserUpdateForm(BaseModel):
new_name: str = Field(
title="New Username", description="max length: 50", max_length=50
)


################################
# Event
################################


################################
# Health
################################
2 changes: 2 additions & 0 deletions app/fastui/queries/check_user_deletable.edgeql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
with user:= assert_single((select User{events:= .<host[is Event]} filter .name=<str>$name)),
select not exists user.events;
20 changes: 20 additions & 0 deletions app/fastui/queries/check_user_deletable_async_edgeql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# AUTOGENERATED FROM 'app/fastui/queries/check_user_deletable.edgeql' WITH:
# $ edgedb-py


from __future__ import annotations
import edgedb


async def check_user_deletable(
executor: edgedb.AsyncIOExecutor,
*,
name: str,
) -> bool:
return await executor.query_single(
"""\
with user:= assert_single((select User{events:= .<host[is Event]} filter .name=<str>$name)),
select not exists user.events;\
""",
name=name,
)
47 changes: 47 additions & 0 deletions app/fastui/shared.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from __future__ import annotations as _annotations

from fastui import AnyComponent
from fastui import components as c
from fastui.events import GoToEvent


def demo_page(
*components: AnyComponent, title: str | None = None
) -> list[AnyComponent]:
return [
c.PageTitle(text=f"EdgeDB FastUI — {title}" if title else "EdgeDB FastUI"),
c.Navbar(
title="EdgeDB FastUI",
title_event=GoToEvent(url="/"),
start_links=[
c.Link(
components=[c.Text(text="users")],
on_click=GoToEvent(url="/users/"),
active="startswith:/users",
),
],
),
c.Page(
components=[
*((c.Heading(text=title),) if title else ()),
*components,
],
),
c.Footer(
extra_text="EdgeDB FastUI",
links=[
c.Link(
components=[c.Text(text="Github")],
on_click=GoToEvent(url="https://github.com/pydantic/FastUI"),
),
c.Link(
components=[c.Text(text="PyPI")],
on_click=GoToEvent(url="https://pypi.org/project/fastui/"),
),
c.Link(
components=[c.Text(text="NPM")],
on_click=GoToEvent(url="https://www.npmjs.com/org/pydantic/"),
),
],
),
]
Loading

0 comments on commit 6f3fa53

Please sign in to comment.