Merge remote-tracking branch 'upstream/main'
This commit is contained in:
commit
7cc622fc44
11 changed files with 2314 additions and 2674 deletions
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
|
@ -19,7 +19,7 @@ jobs:
|
|||
needs: [release]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.EXT_GITHUB }}
|
||||
repository: lnbits/lnbits-extensions
|
||||
|
|
|
|||
24
Makefile
24
Makefile
|
|
@ -5,27 +5,27 @@ format: prettier black ruff
|
|||
check: mypy pyright checkblack checkruff checkprettier
|
||||
|
||||
prettier:
|
||||
poetry run ./node_modules/.bin/prettier --write .
|
||||
uv run ./node_modules/.bin/prettier --write .
|
||||
pyright:
|
||||
poetry run ./node_modules/.bin/pyright
|
||||
uv run ./node_modules/.bin/pyright
|
||||
|
||||
mypy:
|
||||
poetry run mypy .
|
||||
uv run mypy .
|
||||
|
||||
black:
|
||||
poetry run black .
|
||||
uv run black .
|
||||
|
||||
ruff:
|
||||
poetry run ruff check . --fix
|
||||
uv run ruff check . --fix
|
||||
|
||||
checkruff:
|
||||
poetry run ruff check .
|
||||
uv run ruff check .
|
||||
|
||||
checkprettier:
|
||||
poetry run ./node_modules/.bin/prettier --check .
|
||||
uv run ./node_modules/.bin/prettier --check .
|
||||
|
||||
checkblack:
|
||||
poetry run black --check .
|
||||
uv run black --check .
|
||||
|
||||
checkeditorconfig:
|
||||
editorconfig-checker
|
||||
|
|
@ -33,14 +33,14 @@ checkeditorconfig:
|
|||
test:
|
||||
PYTHONUNBUFFERED=1 \
|
||||
DEBUG=true \
|
||||
poetry run pytest
|
||||
uv run pytest
|
||||
install-pre-commit-hook:
|
||||
@echo "Installing pre-commit hook to git"
|
||||
@echo "Uninstall the hook with poetry run pre-commit uninstall"
|
||||
poetry run pre-commit install
|
||||
@echo "Uninstall the hook with uv run pre-commit uninstall"
|
||||
uv run pre-commit install
|
||||
|
||||
pre-commit:
|
||||
poetry run pre-commit run --all-files
|
||||
uv run pre-commit run --all-files
|
||||
|
||||
|
||||
checkbundle:
|
||||
|
|
|
|||
|
|
@ -37,4 +37,4 @@ def events_start():
|
|||
scheduled_tasks.append(task)
|
||||
|
||||
|
||||
__all__ = ["db", "events_ext", "events_static_files", "events_start", "events_stop"]
|
||||
__all__ = ["db", "events_ext", "events_start", "events_static_files", "events_stop"]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
"name": "Events",
|
||||
"short_description": "Sell and register event tickets",
|
||||
"tile": "/events/static/image/events.png",
|
||||
"min_lnbits_version": "1.0.0",
|
||||
"lnbits": "1.1.0",
|
||||
"min_lnbits_version": "1.3.0",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "talvasconcelos",
|
||||
|
|
|
|||
11
crud.py
11
crud.py
|
|
@ -1,5 +1,4 @@
|
|||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Optional, Union
|
||||
|
||||
from lnbits.db import Database
|
||||
from lnbits.helpers import urlsafe_short_hash
|
||||
|
|
@ -72,8 +71,8 @@ async def update_ticket(ticket: Ticket) -> Ticket:
|
|||
return ticket
|
||||
|
||||
|
||||
async def get_ticket(payment_hash: str) -> Optional[Ticket]:
|
||||
row = await db.fetchone(
|
||||
async def get_ticket(payment_hash: str) -> Ticket | None:
|
||||
return await db.fetchone(
|
||||
"SELECT * FROM events.ticket WHERE id = :id",
|
||||
{"id": payment_hash},
|
||||
)
|
||||
|
|
@ -90,7 +89,7 @@ async def get_ticket(payment_hash: str) -> Optional[Ticket]:
|
|||
return Ticket(**ticket_data)
|
||||
|
||||
|
||||
async def get_tickets(wallet_ids: Union[str, list[str]]) -> list[Ticket]:
|
||||
async def get_tickets(wallet_ids: str | list[str]) -> list[Ticket]:
|
||||
if isinstance(wallet_ids, str):
|
||||
wallet_ids = [wallet_ids]
|
||||
q = ",".join([f"'{wallet_id}'" for wallet_id in wallet_ids])
|
||||
|
|
@ -162,7 +161,7 @@ async def update_event(event: Event) -> Event:
|
|||
return event
|
||||
|
||||
|
||||
async def get_event(event_id: str) -> Optional[Event]:
|
||||
async def get_event(event_id: str) -> Event | None:
|
||||
return await db.fetchone(
|
||||
"SELECT * FROM events.events WHERE id = :id",
|
||||
{"id": event_id},
|
||||
|
|
@ -170,7 +169,7 @@ async def get_event(event_id: str) -> Optional[Event]:
|
|||
)
|
||||
|
||||
|
||||
async def get_events(wallet_ids: Union[str, list[str]]) -> list[Event]:
|
||||
async def get_events(wallet_ids: str | list[str]) -> list[Event]:
|
||||
if isinstance(wallet_ids, str):
|
||||
wallet_ids = [wallet_ids]
|
||||
q = ",".join([f"'{wallet_id}'" for wallet_id in wallet_ids])
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import Query
|
||||
from pydantic import BaseModel, EmailStr, root_validator
|
||||
|
|
@ -15,7 +14,7 @@ class CreateEvent(BaseModel):
|
|||
currency: str = "sat"
|
||||
amount_tickets: int = Query(..., ge=0)
|
||||
price_per_ticket: float = Query(..., ge=0)
|
||||
banner: Optional[str] = None
|
||||
banner: str | None = None
|
||||
|
||||
|
||||
class CreateTicket(BaseModel):
|
||||
|
|
@ -50,7 +49,7 @@ class Event(BaseModel):
|
|||
price_per_ticket: float
|
||||
time: datetime
|
||||
sold: int = 0
|
||||
banner: Optional[str] = None
|
||||
banner: str | None = None
|
||||
|
||||
|
||||
class Ticket(BaseModel):
|
||||
|
|
|
|||
2615
poetry.lock
generated
2615
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,39 +1,34 @@
|
|||
[tool.poetry]
|
||||
[project]
|
||||
name = "lnbits-events"
|
||||
version = "0.0.0"
|
||||
requires-python = ">=3.10,<3.13"
|
||||
description = "LNbits, free and open-source Lightning wallet and accounts system."
|
||||
authors = ["Alan Bits <alan@lnbits.com>"]
|
||||
authors = [{ name = "Alan Bits", email = "alan@lnbits.com" }]
|
||||
urls = { Homepage = "https://lnbits.com", Repository = "https://github.com/lnbits/events" }
|
||||
dependencies = [ "lnbits>1" ]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.10 | ^3.9"
|
||||
lnbits = {version = "*", allow-prereleases = true}
|
||||
[tool.poetry]
|
||||
package-mode = false
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "^24.3.0"
|
||||
pytest-asyncio = "^0.21.0"
|
||||
pytest = "^7.3.2"
|
||||
mypy = "^1.5.1"
|
||||
pre-commit = "^3.2.2"
|
||||
ruff = "^0.3.2"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
[tool.uv]
|
||||
dev-dependencies = [
|
||||
"black",
|
||||
"pytest-asyncio",
|
||||
"pytest",
|
||||
"mypy",
|
||||
"pre-commit",
|
||||
"ruff",
|
||||
]
|
||||
|
||||
[tool.mypy]
|
||||
exclude = "(nostr/*)"
|
||||
[[tool.mypy.overrides]]
|
||||
module = [
|
||||
"lnbits.*",
|
||||
"lnurl.*",
|
||||
"loguru.*",
|
||||
"fastapi.*",
|
||||
"pydantic.*",
|
||||
"pyqrcode.*",
|
||||
"shortuuid.*",
|
||||
"httpx.*",
|
||||
]
|
||||
ignore_missing_imports = "True"
|
||||
plugins = ["pydantic.mypy"]
|
||||
|
||||
[tool.pydantic-mypy]
|
||||
init_forbid_extra = true
|
||||
init_typed = true
|
||||
warn_required_dynamic_aliases = true
|
||||
warn_untyped_fields = true
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
log_cli = false
|
||||
|
|
@ -76,6 +71,7 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|||
# needed for pydantic
|
||||
[tool.ruff.lint.pep8-naming]
|
||||
classmethod-decorators = [
|
||||
"validator",
|
||||
"root_validator",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -72,11 +72,10 @@
|
|||
</q-card>
|
||||
<q-card v-else class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
||||
<div class="text-center q-mb-lg">
|
||||
<a class="text-secondary" :href="'lightning:' + receive.paymentReq">
|
||||
<lnbits-qrcode
|
||||
:value="'lightning:' + receive.paymentReq.toUpperCase()"
|
||||
></lnbits-qrcode>
|
||||
</a>
|
||||
<lnbits-qrcode
|
||||
:href="'lightning:' + receive.paymentReq"
|
||||
:value="'lightning:' + receive.paymentReq.toUpperCase()"
|
||||
></lnbits-qrcode>
|
||||
</div>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn outline color="grey" @click="copyText(receive.paymentReq)"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
from datetime import datetime, timezone
|
||||
from http import HTTPStatus
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from lnbits.core.crud import get_standalone_payment, get_user
|
||||
|
|
@ -69,7 +68,7 @@ async def api_events_public():
|
|||
async def api_event_create(
|
||||
data: CreateEvent,
|
||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
||||
event_id: Optional[str] = None,
|
||||
event_id: str | None = None,
|
||||
):
|
||||
if event_id:
|
||||
event = await get_event(event_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue