Skip to content

Commit

Permalink
Added impressum
Browse files Browse the repository at this point in the history
  • Loading branch information
eira132 committed Mar 11, 2022
1 parent e18507a commit 5c2dbeb
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ cp .env-example2 .env
nano .env
```

#### Impressum / Legal Notice
The legal.json file found at `/static/text/legal.json` should contain information about the hosting entity.
Each property should contains the necessary information with the following format:
- Full Name (or company name)
- Address Line 1 (street and house number)
- Address Line 2 (zip code and city)
- Phone number (international format)
- Email (of the contact person)


## Docker
You also can build a docker container
```console
Expand Down
11 changes: 10 additions & 1 deletion app/static/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# Static
Here you add staic files for the frontend.
Here you add staic files for the frontend.

# Impressum / Legal Notice
The legal.json file found at `/static/text/legal.json` should contain information about the hosting entity.
Each property should contains the necessary information with the following format:
- Full Name (or company name)
- Address Line 1 (street and house number)
- Address Line 2 (zip code and city)
- Phone number (international format)
- Email (of the contact person)
7 changes: 7 additions & 0 deletions app/static/text/legal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"full_name": "Max Mustermann",
"address_1": "Straße Hausnummer",
"address_2": "PLZ Ort",
"phone_number": "+49 (0) 123 456789",
"email": "[email protected]"
}
25 changes: 25 additions & 0 deletions app/templates/impressum.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% extends "shared/layout_singleform.html" %}

{% block content %}

<div class="row justify-content-center">
<div class="col-10 limit-width">
<h2 class="display-1 fs-4 mb-1">Impressum</h2>
<hr class="mt-1">
</div>
</div>

<div class="row justify-content-center">
<div class="col-10 limit-width">
<h2>Angaben gem&auml;&szlig; &sect; 5 TMG</h2>
<p class="mb-0">{{entity.full_name}}</p>
<p class="mb-0">{{entity.address_1}}</p>
<p>{{entity.address_2}}</p>

<h2>Kontakt</h2>
<p class="mb-0">Telefon: {{entity.phone_number}}</p>
<p>Email: {{entity.email}}</p>
</div>
</div>

{% endblock %}
16 changes: 16 additions & 0 deletions app/tools/legal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""Reads legal information from a json file and returns an object"""

import json
from pathlib import Path

def read_legal(path: Path = Path("static/text/legal.json")) -> dict:
"""Reads information from the legal. file and returns a dict
Args:
path (Path): path to the file to be read. Defaults to "static/text/legal.json"
Returns:
dict: dict containing the json content
"""
with path.open(encoding="utf-8", mode="r") as file:
return json.load(file)
14 changes: 14 additions & 0 deletions app/views/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from schemes.scheme_user import UserLogin
from services import service_res
from tools.security import get_current_user
from tools.legal import read_legal

templates = Jinja2Templates("templates")
router = fastapi.APIRouter()
Expand Down Expand Up @@ -96,3 +97,16 @@ def index(request: Request, db_session: Session = Depends(get_db)): # <- REMOVE
############ END REMOVE ###############

return templates.TemplateResponse("index.html", {"request": request})


@router.get("/impressum", response_class=HTMLResponse)
def impressum(request: Request):
"""Return legal page
Args:
request (Request): the http request
Returns:
TemplateResponse: the http response
"""
return templates.TemplateResponse("impressum.html", {"request": request, "entity": read_legal()})
5 changes: 5 additions & 0 deletions docs/source/tools/legal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
legal
=====

.. automodule:: tools.legal
:members:
5 changes: 3 additions & 2 deletions docs/source/tools/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ Contains some usefull tools that are needed for the application
:caption: Contents:

config.rst
legal.rst
gapi.rst
hashing.rst
my_logging.rst
security.rst
recipe_db.rst
recipe_db.rst
security.rst

0 comments on commit 5c2dbeb

Please sign in to comment.