Visual update

This commit is contained in:
Eriks Karls 2022-10-24 13:31:08 +03:00
parent 35841c9f29
commit 3d22494e48
2 changed files with 25 additions and 7 deletions

27
app.py
View File

@ -1,16 +1,30 @@
import datetime import datetime
import json import json
import uuid
import logging import logging
import uuid
from collections import defaultdict from collections import defaultdict
from io import BytesIO from io import BytesIO
from typing import Iterable, Mapping from typing import Iterable, Mapping
from flask import Flask, request, render_template, send_file, jsonify from flask import Flask, jsonify, render_template, request, send_file
from icalendar import Calendar, Event, Alarm from icalendar import Alarm, Calendar, Event
from unidecode import unidecode from unidecode import unidecode
app = Flask(__name__) app = Flask(__name__)
LV_MONTHS = {
1: "jan",
2: "feb",
3: "mar",
4: "apr",
5: "mai",
6: "jūn",
7: "jūl",
8: "aug",
9: "sep",
10: "okt",
11: "nov",
12: "dec",
}
# Source JSON created from http://vvc.gov.lv/export/sites/default/files/paplasinatais_saraksts.pdf # Source JSON created from http://vvc.gov.lv/export/sites/default/files/paplasinatais_saraksts.pdf
@ -69,7 +83,10 @@ def calendar_search():
words = { words = {
"text": kind.title(), "text": kind.title(),
"children": [ "children": [
{"id": key, "text": value} {
"id": key,
"text": f"{value} ({key.split('__')[1]}. {LV_MONTHS[int(key.split('__')[0])]}.)",
}
for key, value in mapping[kind].items() for key, value in mapping[kind].items()
if unidecode(value.lower(), errors="preserve").startswith(term) if unidecode(value.lower(), errors="preserve").startswith(term)
], ],
@ -80,4 +97,4 @@ def calendar_search():
if __name__ == "__main__": if __name__ == "__main__":
app.run("0.0.0.0", 5000, True, False) app.run("0.0.0.0", 8000, True, False)

View File

@ -1,2 +1,3 @@
Flask==2.0.2 Flask==2.2.2
icalendar==4.0.9 icalendar==5.0.1
unidecode==1.3.6