Switch from bottle to flask

This commit is contained in:
Felix Breidenstein 2020-10-16 01:07:14 +02:00
parent dc3c2b309c
commit eeea40b125
10 changed files with 250 additions and 141 deletions

40
templates/base.html Normal file
View file

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="d">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Schmeckels</title>
<link href="https://unpkg.com/tailwindcss/dist/tailwind.min.css" rel="stylesheet">
<link href="https://unpkg.com/@tailwindcss/custom-forms/dist/custom-forms.min.css" rel="stylesheet">
</head>
<body class="bg-grey-100 font-sans leading-normal tracking-normal">
<div class="bg-gray-300">
<ul class="flex pb-3 pt-3">
<li class="ml-12 mr-12">
<a class="text-blue-500 hover:text-blue-800" href="/">SCHMECKELS</a>
</li>
<li class="mr-2">
<a class="text-blue-500 hover:text-blue-800" href="/transactions">Transactions</a>
</li>
<li class="mr-2">
<a class="text-blue-500 hover:text-blue-800" href="/transactions?unsorted=1">Unsorted Transactions</a>
</li>
<li class="mr-2">
<a class="text-blue-500 hover:text-blue-800" href="/categories">Categories</a>
</li>
<li class="mr-2">
<a class="text-blue-500 hover:text-blue-800" href="/graph">Monthly Graph</a>
</li>
</ul>
</div>
<div class="pt-2 container mx-auto">
{% block main %} {% endblock %}
</div>
</body>
</html>

21
templates/categories.html Normal file
View file

@ -0,0 +1,21 @@
{% extends "base.html" %}
{% block main %}
<h1 class="text-2xl font-bold text-indigo-500">Category overview</h1>
<ul>
{% for c in categories %}
<li class="p-2">
{{ c.full_name() }}
<a class="float-right" href="/category/{{ c.name }}">
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold mx-2 y-1 px-2 rounded"> Transactions </button>
</a>
<a class="float-right" href="/category/{{ c.name }}/delete">
<button class="bg-red-500 hover:bg-red-700 text-white font-bold y-1 px-2 rounded"> Delete </button>
</a>
</li>
{% endfor %}
</ul>
{% endblock %}

28
templates/category.html Normal file
View file

@ -0,0 +1,28 @@
{% extends "base.html" %}
{% block main %}
<h1>Transaktionen aus {{ category.full_name() }}</h1>
<table class="table-auto">
<thead>
<tr>
<th class="px-4 py-2">Date</th>
<th class="px-4 py-2">Sender/Empfänger</th>
<th class="px-4 py-2">Verwendungszweck</th>
<th class="px-4 py-2">Betrag</th>
<th class="px-4 py-2"></th>
</tr>
</thead>
<tbody>
{% for t in transactions %}
<tr>
<td class="border px-4 py-2">{{ t.get_date("de") }}</td>
<td class="border px-4 py-2">{{ t.name }}</td>
<td class="border px-4 py-2">{{ t.description }}</td>
<td class="border px-4 py-2 {{ 'text-green-500' if t.is_positive() else 'text-red-500' }}">{{ t.pretty_amount() }}</td>
<td class="border px-4 py-2"><a href="#">Remove category</a></td>
</tr>
{% endfor %}
</tbody>
</table>

7
templates/graph.html Normal file
View file

@ -0,0 +1,7 @@
{% extends "base.html" %}
{% block main %}
<h1 class="text-2xl font-bold text-indigo-500">Last 12 months</h1>
{% endblock %}

28
templates/index.html Normal file
View file

@ -0,0 +1,28 @@
{% extends "base.html" %}
{% block main %}
<h1 class="text-2xl font-bold text-indigo-500">Monatsübersicht</h1>
{% if categories|length > 0 %}
<table class="table-auto border-none">
<thead>
<tr>
<th class="px-4 py-2">Categorie</th>
<th class="px-4 py-2 text-right">Summe</th>
</tr>kk
</thead>
<tbody>
{% for c in categories %}
<tr>
<td class="border px-4 py-2">{{ c["name"] }}</td>
<td class="border px-4 py-2 text-right {{ 'text-red-500' if c['amount'][0] == "-" else 'text-green-500' }}">{{ c["amount"] }} €</td>
</tr>
{% endfor %}
</tbody>
{% else %}
No transactions this month
{% endif %}
{% endblock %}

81
templates/report.pdf Normal file
View file

@ -0,0 +1,81 @@
<!DOCTYPE html>
<html lang="d">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Report {{ year }}</title>
<style>
@page {
size: 21cm 29.7cm;
margin: 20mm;
/* change the margins as you want them to be. */
}
body {
width: 100%;
}
.content {
width: 80%;
margin: auto;
}
h4 {
margin-bottom: 5px;
}
table {
width: 90%;
margin: auto
}
td.amount {
text-align: right;
}
tr.sum-column>td {
padding-top: 5px;
border-top: 1pt solid black;
}
tr.sum-column-total>td {
padding-top: 20px;
border-top: double black;
}
.text-red {
font-weight: bold;
color: red;
}
.text-green {
font-weight: bold;
color: green;
}
</style>
</head>
<body>
<h2>Kontoübersicht {{ year }}</h2>
<hr />
<div class="content">
% for name, entries in data.items():
<h4>{{ name }}</h4>
<table>
% for sc, amount in entries.items():
<tr>
<td class="category-name">{{ sc }}</td>
<td class="amount"> {{ amount }} €</td>
</tr>
% end
</table>
% end
</body>
</html>

View file

@ -0,0 +1,43 @@
{% extends "base.html" %}
{% block main %}
<form action="/bulksort" method="POST">
<select name="category">
{% for c in categories %}
<option value="{{ c.id }}">{{ c.full_name() }}</option>
{% endfor %}
</select>
<input type="submit">
<table class="table-auto">
<thead>
<tr>
<th class="px-4 py-2"></th>
<th class="px-4 py-2">Date</th>
<th class="px-4 py-2">Sender/Empfänger</th>
<th class="px-4 py-2">Verwendungszweck</th>
<th class="px-4 py-2 text-right">Betrag</th>
<th class="px-4 py-2">Kategorie</th>
</tr>
</thead>
<tbody>
{% for t in transactions %}
<tr>
<td class="border px-4 py-2"><input type="checkbox" name="transaction" value="{{ t.id }}"></td>
<td class="border px-4 py-2">{{ t.get_date("de") }}</td>
<td class="border px-4 py-2">{{ t.name }}<br/> <span class="text-gray-500">{{t.iban}}</span></td>
<td class="border px-4 py-2">{{ t.description }}</td>
<td class="border px-4 py-2 text-right {{ 'text-green-500' if t.is_positive() else 'text-red-500' }}">{{ t.pretty_amount() }} €</td>
{% if t.category %}
<td class="border px-4 py-2"> <a href="/category/{{ t.category.name }}"> {{ t.category.full_name()}}</a></td>
{% else %}
<td class="border px-4 py-2"> - </td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</form>
{% endblock %}