Add read only mode
This commit is contained in:
@@ -23,6 +23,13 @@ uv run fastapi dev src/allmende_payment_system/app.py
|
||||
```
|
||||
A demo user will be created automatically.
|
||||
|
||||
### Configuration
|
||||
|
||||
A preliminary config system exists and works via environment variables:
|
||||
|
||||
* APS_READ_ONLY: If set, users can make no purchases
|
||||
* APS_PRODUCTION_MODE: If set, demo functionality, like adding money to an account and the demo banner are removed.
|
||||
|
||||
### Testing
|
||||
|
||||
APS uses pytest. You can run the test suite with:
|
||||
|
||||
@@ -82,7 +82,8 @@
|
||||
{% elif user.accounts|length == 1 %}
|
||||
<input type="hidden" name="account_id" value="{{ user.accounts[0].id }}">
|
||||
{% endif %}
|
||||
<button type="submit" class="btn btn-primary">Jetzt Bezahlen</button>
|
||||
<button type="submit" class="btn btn-primary" {% if read_only_mode %}disabled{% endif %}>Jetzt Bezahlen</button>
|
||||
{% if read_only_mode %}<span class="text-muted small ms-3">⚠️ Das System befindet sich im schreibgeschützen Modus. Derzeit sind keine Einkäufe möglich.</span>{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -29,6 +29,7 @@ def get_jinja_renderer() -> Jinja2Templates:
|
||||
renderer.env.filters["timestamp_de"] = lambda x: x.strftime("%d.%m.%Y %H:%M")
|
||||
|
||||
renderer.env.globals["production_mode"] = "APS_PRODUCTION_MODE" in os.environ
|
||||
renderer.env.globals["read_only_mode"] = "APS_READ_ONLY" in os.environ
|
||||
return renderer
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user