fix create and update

This commit is contained in:
Tiago vasconcelos 2021-10-19 17:02:22 +01:00
parent 41abbb44f7
commit facd94f59e
3 changed files with 10 additions and 10 deletions

View File

@ -427,7 +427,7 @@
LNbits.api
.request(
'GET',
'/events/api/v1/events?all_wallets',
'/events/api/v1/events?all_wallets=true',
this.g.user.wallets[0].inkey
)
.then(function (response) {

View File

@ -18,7 +18,7 @@ templates = Jinja2Templates(directory="templates")
@events_ext.get("/", response_class=HTMLResponse)
async def index(request: Request, user: User = Depends(check_user_exists)):
return events_renderer.TemplateResponse("events/index.html", {"request": request, "user": user.dict()})
return events_renderer().TemplateResponse("events/index.html", {"request": request, "user": user.dict()})
@events_ext.get("/{event_id}", response_class=HTMLResponse)
@ -30,7 +30,7 @@ async def display(request: Request, event_id):
)
if event.amount_tickets < 1:
return events_renderer.TemplateResponse(
return events_renderer().TemplateResponse(
"events/error.html",
{
"request": request,
@ -40,7 +40,7 @@ async def display(request: Request, event_id):
)
datetime_object = datetime.strptime(event.closing_date, "%Y-%m-%d").date()
if date.today() > datetime_object:
return events_renderer.TemplateResponse(
return events_renderer().TemplateResponse(
"events/error.html",
{
"request": request,
@ -49,7 +49,7 @@ async def display(request: Request, event_id):
}
)
return events_renderer.TemplateResponse(
return events_renderer().TemplateResponse(
"events/display.html",
{
"request": request,
@ -76,7 +76,7 @@ async def ticket(request: Request, ticket_id):
status_code=HTTPStatus.NOT_FOUND, detail="Event does not exist."
)
return events_renderer.TemplateResponse(
return events_renderer().TemplateResponse(
"events/ticket.html",
{
"request": request,
@ -96,7 +96,7 @@ async def register(request: Request, event_id):
status_code=HTTPStatus.NOT_FOUND, detail="Event does not exist."
)
return events_renderer.TemplateResponse(
return events_renderer().TemplateResponse(
"events/register.html",
{
"request": request,

View File

@ -43,7 +43,7 @@ async def api_events(
return [event.dict() for event in await get_events(wallet_ids)]
@events_ext.post("/api/v1/events")
@events_ext.put("/api/v1/events/<event_id>")
@events_ext.put("/api/v1/events/{event_id}")
async def api_event_create(data: CreateEvent, event_id=None, wallet: WalletTypeInfo = Depends(get_key_type)):
if event_id:
event = await get_event(event_id)
@ -58,9 +58,9 @@ async def api_event_create(data: CreateEvent, event_id=None, wallet: WalletTypeI
status_code=HTTPStatus.FORBIDDEN,
detail=f"Not your event."
)
event = await update_event(event_id, **data)
event = await update_event(event_id, **data.dict())
else:
event = await create_event(**data)
event = await create_event(data=data)
return event.dict()