Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ (src/): add docs tab #31

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/routes.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from flask import url_for, session, request, render_template, redirect

Check failure on line 1 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L1

Missing module docstring (missing-module-docstring, C0114)
from .app import app, dbms, oauth


@app.route('/', methods=['GET', 'POST', 'DELETE'])
def homepage():

Check failure on line 6 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L6

Missing function or method docstring (missing-function-docstring, C0116)
user = session.get('user')

app.logger.debug(f"/ User value: {user}")

Check failure on line 9 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L9

Use lazy % formatting in logging functions (logging-fstring-interpolation, W1203)

if user:
_username = user['metadata']['name']
Expand All @@ -24,12 +24,12 @@

if request.method == 'POST':
user_to_update = request.form['id']
app.logger.debug(f"UPDATING USER {user_to_update} REQUEST")

Check failure on line 27 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L27

Use lazy % formatting in logging functions (logging-fstring-interpolation, W1203)

dbms.update_request_status(user_to_update)

user['request_data'] = dbms.get_all_request_data()
app.logger.debug(f"ADMIN REQUEST DATA: {user['request_data']}")

Check failure on line 32 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L32

Use lazy % formatting in logging functions (logging-fstring-interpolation, W1203)

return render_template('users/admin.html', user=user)

Expand All @@ -45,7 +45,7 @@
print(request.method)

user['request_data'] = dbms.get_request_data(_username)
app.logger.debug(f"USER REQUEST DATA: {user['request_data']}")

Check failure on line 48 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L48

Use lazy % formatting in logging functions (logging-fstring-interpolation, W1203)

return render_template('users/user.html', user=user)

Expand All @@ -53,7 +53,7 @@


@app.route('/login')
def login():

Check failure on line 56 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L56

Missing function or method docstring (missing-function-docstring, C0116)
app.logger.debug('Redirecting to Vault')
redirect_uri = url_for('auth', _external=True, _scheme='https')

Expand All @@ -63,17 +63,17 @@


@app.route('/auth')
def auth():

Check failure on line 66 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L66

Missing function or method docstring (missing-function-docstring, C0116)
try:
token = oauth.vault.authorize_access_token()

except Exception as e: # TODO: choose better Exception

Check failure on line 70 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L70

TODO: choose better Exception (fixme, W0511)

Check failure on line 70 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L70

Catching too general exception Exception (broad-exception-caught, W0718)
app.logger.error("Error while autorizing access token, %s", e)

return redirect(url_for('homepage'))

app.logger.debug('Success user auth')
app.logger.debug(f'Token: {token}')

Check failure on line 76 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L76

Use lazy % formatting in logging functions (logging-fstring-interpolation, W1203)

session['user'] = token['userinfo']
session['token'] = token
Expand All @@ -81,10 +81,10 @@
return redirect(url_for('homepage'))

@app.route('/logout')
def logout():

Check failure on line 84 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L84

Missing function or method docstring (missing-function-docstring, C0116)
token = session.get('token')

app.logger.debug(f'Logging out {token}')

Check failure on line 87 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L87

Use lazy % formatting in logging functions (logging-fstring-interpolation, W1203)

oauth.vault.post('auth/token/revoke-self', token=token)

Expand All @@ -95,5 +95,9 @@
return redirect('/')

@app.route('/info')
def info():

Check failure on line 98 in src/routes.py

View workflow job for this annotation

GitHub Actions / Pylint

src/routes.py#L98

Missing function or method docstring (missing-function-docstring, C0116)
return render_template('info.html')

@app.route('/docs')
def docs():
return render_template('docs.html')
29 changes: 29 additions & 0 deletions src/templates/docs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends 'home.html' %}

{% block script %}
{% endblock%}

{% block disclaimer %}
{% endblock%}

{% block body %}
<!-- Description and Login -->
<div class="row mx-auto py-md-2">
<div class="card" style="width: 18rem;">
<!-- <img src="..." class="card-img-top" alt="..."> -->
<div class="card-body">
<h2 class="card-title">Documentation</h2>
<p class="card-text">Here you can find all the user documentation about the UniNuvola project.</p>

<ul class="list-group list-group-flush">
<li class="list-group-item">
<a class="btn btn-link" href="https://github.com/UniNuvola/quickstart/releases/latest/download/main.pdf" about="_blank">
<i class="bi bi-file-pdf" style="color:red"></i> Quickstart guide
</a>
</li>
</ul>
</div>
</div>

</div>
{% endblock%}
41 changes: 25 additions & 16 deletions src/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,38 @@

</head>
<body>
<!-- NAVBAR -->
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: #4c7bb4;">
<div class="container-fluid">
<a class="navbar-brand" href="/">
<img src="static/icon.png" alt="" style="width: 40px; height: 40px;">
UniNuvola
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/"><i class="bi bi-house-door-fill"></i> Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/info"><i class="bi bi-info-circle-fill"></i> About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/UniNuvola" target="_blank"><i class="bi bi-github"></i> GitHub</a>
</li>
</ul>
</div>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/"><i class="bi bi-house-door-fill"></i> Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/docs"><i class="bi bi-file-earmark-text-fill"></i> Docs</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/info"><i class="bi bi-info-circle-fill"></i> About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/UniNuvola" target="_blank"><i class="bi bi-github"></i> GitHub</a>
</li>
</ul>
</div>

<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="d-flex">
{% if user %}
<a href="/logout">
Expand All @@ -50,8 +57,10 @@
</a>
{% endif %}
</div>
</div>
</nav>

<!-- MAIN CONTENT -->
<div class="col-md-6 mx-auto p-4 py-md-5">
<main>
{% block disclaimer %}
Expand Down
Loading