Add Readme
This commit is contained in:
27
README.md
27
README.md
@@ -0,0 +1,27 @@
|
|||||||
|
# Allmende Payment System
|
||||||
|
|
||||||
|
A FastAPI-based payment system for the communal living projects and similar groups.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
- [uv](https://docs.astral.sh/uv/) (package and dependency manager)
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
### 1. Install uv
|
||||||
|
Ensure `uv` is installed. If not, follow the [official installation guide](https://docs.astral.sh/uv/getting-started/installation/).
|
||||||
|
|
||||||
|
### 2. Initialize the database
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make reset_db
|
||||||
|
```
|
||||||
|
Resets the database and initializes it with some mock data.
|
||||||
|
|
||||||
|
### 3. Run the Development Server
|
||||||
|
```bash
|
||||||
|
uv run fastapi dev src/allmende_payment_system/app.py
|
||||||
|
```
|
||||||
|
A demo user will be created automatically.
|
||||||
|
|
||||||
|
## License
|
||||||
|
This project is licensed under the [European Union Public Licence (EUPL)](https://joinup.ec.europa.eu/collection/eupl).
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
allmende-payment-system = "allmende_payment_system:main"
|
aps = "allmende_payment_system.cli:main"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["uv_build>=0.9.2,<0.10.0"]
|
requires = ["uv_build>=0.9.2,<0.10.0"]
|
||||||
|
|||||||
@@ -22,18 +22,21 @@ SessionDep = Annotated[Session, Depends(get_session)]
|
|||||||
|
|
||||||
async def get_user(request: Request) -> dict:
|
async def get_user(request: Request) -> dict:
|
||||||
|
|
||||||
if username := os.environ.get("APS_username", None):
|
if "ynh_user" in request.headers:
|
||||||
|
# if the ynh_user header is present, we assume we're running in YunoHost and use the header values
|
||||||
|
return {
|
||||||
|
"username": request.headers["ynh_user"],
|
||||||
|
"display_name": request.headers["ynh_user_fullname"],
|
||||||
|
}
|
||||||
|
|
||||||
|
if not "APS_PRODUCTION_MODE" in os.environ:
|
||||||
|
username = os.environ.get("APS_username", "demo_user")
|
||||||
return {
|
return {
|
||||||
"username": username,
|
"username": username,
|
||||||
"display_name": os.environ.get("APS_display_name", "Missing Display Name"),
|
"display_name": username,
|
||||||
}
|
}
|
||||||
if "ynh_user" not in request.headers:
|
|
||||||
raise HTTPException(status_code=401, detail="Missing ynh_user header")
|
|
||||||
|
|
||||||
return {
|
raise HTTPException(status_code=401, detail="Missing ynh_user header")
|
||||||
"username": request.headers["ynh_user"],
|
|
||||||
"display_name": request.headers["ynh_user_fullname"],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async def get_user_object(request: Request, session: SessionDep) -> User:
|
async def get_user_object(request: Request, session: SessionDep) -> User:
|
||||||
|
|||||||
Reference in New Issue
Block a user