Skip to content
Merged
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: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"id": "numberlottery",
"name": "Numberlottery",
"version": "1.0.0",
"version": "1.1.0",
"short_description": "Block based numbers game",
"tile": "/numberlottery/static/image/numbers.png",
"min_lnbits_version": "1.3.0",
"min_lnbits_version": "1.7.0-rc1",
"tags": ["gambling"],
"contributors": [
{
Expand Down
4 changes: 2 additions & 2 deletions crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

async def create_game(data: Game) -> Game:
data.id = urlsafe_short_hash()
game = Game(**data.dict())
game = Game(**data.model_dump())
await db.insert("numberlottery.games", game)
return game

Expand Down Expand Up @@ -58,7 +58,7 @@ async def delete_game(game_id: str) -> None:

async def create_player(data: Player) -> Player:
data.id = urlsafe_short_hash()
player = Player(**data.dict())
player = Player(**data.model_dump())
await db.insert("numberlottery.players", player)
return player

Expand Down
15 changes: 8 additions & 7 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime, timezone

from pydantic import BaseModel, Field, validator
from pydantic import BaseModel, ConfigDict, Field, field_validator


class Game(BaseModel):
Expand All @@ -18,11 +18,11 @@ class Game(BaseModel):
block_number: int = 0
created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))

class Config:
extra = "allow"
model_config = ConfigDict(extra="allow")

@validator("closing_date", pre=True, always=True)
def force_utc(cls, v): # noqa: N805
@field_validator("closing_date", mode="before")
@classmethod
def force_utc(cls, v):
if isinstance(v, datetime):
return v if v.tzinfo else v.replace(tzinfo=timezone.utc)
return datetime.fromtimestamp(int(v), tz=timezone.utc)
Expand All @@ -38,8 +38,9 @@ class PublicGame(BaseModel):
block_hash: str = ""
block_number: int = 0

@validator("closing_date", pre=True, always=True)
def force_utc(cls, v): # noqa: N805
@field_validator("closing_date", mode="before")
@classmethod
def force_utc(cls, v):
if isinstance(v, datetime):
return v if v.tzinfo else v.replace(tzinfo=timezone.utc)
return datetime.fromtimestamp(int(v), tz=timezone.utc)
Expand Down
12 changes: 9 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[project]
name = "lnbits-numberlottery"
version = "0.0.0"
requires-python = ">=3.10,<3.13"
version = "1.1.0"
requires-python = ">=3.10,<3.14"
description = "LNbits, free and open-source Lightning wallet and accounts system."
authors = [{ name = "Alan Bits", email = "alan@lnbits.com" }]
urls = { Homepage = "https://lnbits.com", Repository = "https://github.com/lnbits/numberlottery" }
dependencies = [ "lnbits>1" ]
dependencies = [ "lnbits>=1.7.0rc1" ]

[dependency-groups]
dev = [
Expand All @@ -21,6 +21,12 @@ dev = [
[tool.poetry]
package-mode = false

[tool.poetry.dependencies]
python = ">=3.10,<3.13"

[tool.uv]
build-constraint-dependencies = ["scikit-build-core<0.10"]

[tool.mypy]
plugins = ["pydantic.mypy"]

Expand Down
1,265 changes: 899 additions & 366 deletions uv.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def numberlottery_renderer():
@numberlottery_generic_router.get("/", response_class=HTMLResponse)
async def index(request: Request, user: User = Depends(check_user_exists)):
return numberlottery_renderer().TemplateResponse(
"numberlottery/index.html", {"request": request, "user": user.json()}
"numberlottery/index.html", {"request": request, "user": user.model_dump_json()}
)


Expand Down
2 changes: 1 addition & 1 deletion views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def api_get_public_game(game_id: str):
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="Numbers game does not exist."
)
public_game = PublicGame(**game.dict())
public_game = PublicGame(**game.model_dump())
return public_game


Expand Down
Loading