Compare commits

..

No commits in common. "fed0675f9918b7007ab15e1fe741d34fa0a97f2d" and "569d40161b8713804c3a9e7e5216d72e1efe7279" have entirely different histories.

9 changed files with 4 additions and 97 deletions

View file

@ -20,11 +20,9 @@ def create_app() -> flask.Flask:
import tos
import account
import finances
tos.register(app)
account.register(app)
finances.register(app)
# max 100 MB
app.config['MAX_CONTENT_LENGTH'] = 100 * 1024 * 1024

View file

@ -1,52 +0,0 @@
import os
import io
import time
import json
import flask
import requests
from dotenv import load_dotenv
load_dotenv()
def get_finances():
return requests.get(
url=f'{os.environ["CORE_API_URL"]}/finances',
headers={
'Authorization': f'{os.environ["CORE_API_KEY"]}'
},
timeout=5
).json()
def register(app):
@app.route('/finances')
def finances_view():
data = get_finances()
finances = {
'donations_total': round(sum([i['amount_usd'] for i in data['donations']])),
'donations_num': len(data['donations']),
'donations_avg': round(sum([i['amount_usd'] for i in data['donations']]) / len(data['donations']), 2),
'donations_max': round(max([i['amount_usd'] for i in data['donations']])),
'most_used_donation_currency': max(data['donations'], key=lambda x: x['amount_usd'])['currency'],
'expenses_total': round(sum([i['amount_usd'] for i in data['expenses']])),
'expenses_wages': round(sum([i['amount_usd'] for i in data['expenses'] if i['type'] == 'wage'])),
'most_used_expense_currency': max(data['expenses'], key=lambda x: x['amount_usd'])['currency'],
}
return flask.render_template('finances.html', finances=finances)
@app.route('/finances/json')
def finances_download():
virtual_file = io.StringIO()
json.dump(get_finances(), virtual_file, indent=4)
name = f'finances-{time.strftime("%Y-%m-%d")}.json'
virtual_file.seek(0)
return flask.send_file(
io.BytesIO(virtual_file.read().encode('utf-8')),
mimetype='application/json',
as_attachment=True,
download_name=name
)

View file

@ -124,11 +124,10 @@ h6 {
}
.box {
margin-bottom: 1rem;
background: rgba(204, 154, 247, 0.1411764706);
border: 2px solid rgba(204, 154, 247, 0.1411764706);
border-radius: 5px;
padding: 0rem 1rem;
padding: 1rem 2rem;
}
@media (max-width: 900px) {

File diff suppressed because one or more lines are too long

View file

@ -110,11 +110,10 @@ h6
-webkit-text-fill-color: transparent
.box
margin-bottom: 1rem
background: $primary-soft
border: 2px solid $primary-soft
border-radius: $edge
padding: 0rem 1rem
padding: 1rem 2rem
@media (max-width: 900px)
body

View file

@ -10,7 +10,6 @@ header h1 {
}
div.featured__facts {
padding: 1.5rem;
margin-block: 2rem;
display: flex;
vertical-align: middle;
@ -38,7 +37,6 @@ div.featured__facts h2 span {
}
div.user-quotes div.user-quote__field {
padding: 1.5rem;
cursor: pointer;
margin-block: 2rem;
background: rgba(204, 154, 247, 0.1411764706);

File diff suppressed because one or more lines are too long

View file

@ -10,7 +10,6 @@ header
line-height: 4rem
div.featured__facts
padding: 1.5rem
margin-block: 2rem
display: flex
vertical-align: middle
@ -41,7 +40,6 @@ div.user-quotes
// grid-gap: 2rem
div.user-quote__field
padding: 1.5rem
cursor: pointer
margin-block: 2rem
background: $primary-soft

View file

@ -1,33 +0,0 @@
{% include 'common/begin.html' %}
<main>
<h1>Our finances - transparency is key!</h1>
<p>
<b>Warning</b> - no guarantees can be made that this information is 100% accurate. Crypto currency prices are updated once every hour.
</p>
<a href="/finances/json" target="_blank">
<button class="special">
<i class="bi bi-file-earmark-arrow-down"></i>
Download entire database
</button>
</a>
<h2>Donations</h2>
<div class="featured__facts box"><p>We have received <b>{{ finances.donations_num }} donations</b> so far.</p></div>
<div class="featured__facts box"><p>From donations, we received a total of <b>{{ finances.donations_total }} USD</b>.</p></div>
<div class="featured__facts box"><p>The average donation has an amount of <b>{{ finances.donations_avg }} USD</b>.
The largest donation is <b>{{ finances.donations_max }} USD</b>.</div>
<div class="featured__facts box"><p>Most people donated in <b>{{ finances.most_used_donation_currency }}</b>.</p></div>
<!-- <img src="{{ finances.donations_chart_url }} alt="Donations chart"> -->
<h2>Expenses</h2>
<div class="featured__facts box"><p>We have spent <b>{{ finances.expenses_total }} USD</b>.</p></div>
<div class="featured__facts box"><p>We paid our developers <b>{{ finances.expenses_wages }} USD</b> so far.</p></div>
<div class="featured__facts box"><p>We usually pay in <b>{{ finances.most_used_expense_currency }}</b>.</p></div>
</main>
{% include 'common/end.html' %}