Release v1.2.10: Version aus VERSION-Variable und verbesserte Zeilenabstände

This commit is contained in:
2025-03-19 18:54:06 +01:00
parent d50ea60af9
commit 7b88e62de0
5 changed files with 1615 additions and 214 deletions

75
app.py
View File

@@ -18,7 +18,7 @@ logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Version der Anwendung
VERSION = "1.2.1"
VERSION = "1.2.10"
# Pfad zur Datenbank
DB_FILE = 'data/customers.db'
@@ -56,7 +56,12 @@ def init_db():
email TEXT,
bemerkung TEXT,
fachrichtung TEXT,
tag TEXT
tag TEXT,
handy TEXT,
tele_firma TEXT,
kontakt1 TEXT,
kontakt2 TEXT,
kontakt3 TEXT
)
''')
@@ -71,6 +76,8 @@ def init_db():
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_email ON customers(email)')
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_fachrichtung ON customers(fachrichtung)')
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_tag ON customers(tag)')
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_handy ON customers(handy)')
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_tele_firma ON customers(tele_firma)')
# Erstelle einen zusammengesetzten Index für die häufigste Suchkombination
c.execute('CREATE INDEX IF NOT EXISTS idx_customers_name_ort ON customers(name, ort)')
@@ -96,34 +103,44 @@ def import_csv():
# Importiere MEDISOFT-Daten
if os.path.exists('data/customers.csv'):
logger.info("Importiere MEDISOFT-Daten...")
df = pd.read_csv('data/customers.csv', encoding='utf-8')
df = pd.read_csv('data/customers.csv', encoding='iso-8859-1')
df.columns = df.columns.str.strip().str.replace('"', '')
df = df.apply(lambda x: x.str.strip().str.replace('"', '') if x.dtype == "object" else x)
df['name'] = df['Vorname'] + ' ' + df['Nachname']
for _, row in df.iterrows():
c.execute('''
INSERT INTO customers (name, nummer, strasse, plz, ort, telefon, mobil, email, fachrichtung, tag)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (row['name'], row['Nummer'], row['Strasse'], row['PLZ'], row['Ort'],
row['Tel'], row['Handy'], row['mail'], row['Fachrichtung'], 'medisoft'))
INSERT INTO customers (
name, nummer, strasse, plz, ort, telefon, mobil, email,
fachrichtung, tag, handy, tele_firma, kontakt1, kontakt2, kontakt3
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (
row['VorNachname'], row['Nummer'], row['Strasse'], row['PLZ'], row['Ort'],
row['Tel'], row['Tel'], row['mail'], row['Fachrichtung'], 'medisoft',
row['Handy'], row['Tele Firma'], row['Kontakt1'], row['Kontakt2'], row['Kontakt3']
))
else:
logger.warning("MEDISOFT CSV-Datei nicht gefunden")
# Importiere MEDICONSULT-Daten
if os.path.exists('data/customers_snk.csv'):
logger.info("Importiere MEDICONSULT-Daten...")
df_snk = pd.read_csv('data/customers_snk.csv', encoding='utf-8')
df_snk = pd.read_csv('data/customers_snk.csv', encoding='iso-8859-1')
df_snk.columns = df_snk.columns.str.strip().str.replace('"', '')
df_snk = df_snk.apply(lambda x: x.str.strip().str.replace('"', '') if x.dtype == "object" else x)
df_snk['name'] = df_snk['Vorname'] + ' ' + df_snk['Nachname']
for _, row in df_snk.iterrows():
c.execute('''
INSERT INTO customers (name, nummer, strasse, plz, ort, telefon, mobil, email, fachrichtung, tag)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (row['name'], row['Nummer'], row['Strasse'], row['PLZ'], row['Ort'],
row['Tel'], row['Handy'], row['mail'], row['Fachrichtung'], 'mediconsult'))
INSERT INTO customers (
name, nummer, strasse, plz, ort, telefon, mobil, email,
fachrichtung, tag, handy, tele_firma, kontakt1, kontakt2, kontakt3
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (
row['VorNachname'], row['Nummer'], row['Strasse'], row['PLZ'], row['Ort'],
row['Tel'], row['Tel'], row['mail'], row['Fachrichtung'], 'mediconsult',
row['Handy'], row['Tele Firma'], row['Kontakt1'], row['Kontakt2'], row['Kontakt3']
))
else:
logger.warning("MEDICONSULT CSV-Datei nicht gefunden")
@@ -167,7 +184,12 @@ def search_customers():
c.mobil,
c.email,
c.fachrichtung,
c.tag
c.tag,
c.handy,
c.tele_firma,
c.kontakt1,
c.kontakt2,
c.kontakt3
FROM customers c
WHERE 1=1
'''
@@ -253,7 +275,12 @@ def search_customers():
'mobil': row[6],
'email': row[7],
'fachrichtung': row[8],
'tag': row[9] # Tag-Feld hinzugefügt
'tag': row[9],
'handy': row[10],
'tele_firma': row[11],
'kontakt1': row[12],
'kontakt2': row[13],
'kontakt3': row[14]
}
formatted_results.append(customer)
@@ -319,7 +346,7 @@ def index():
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
logger.info(f"Client-IP: {client_ip}")
logger.info(f"Erlaubte IP-Bereiche: {allowed_ip_ranges}")
return render_template('index.html', allowed_ip_ranges=allowed_ip_ranges)
return render_template('index.html', allowed_ip_ranges=allowed_ip_ranges, version=VERSION)
@app.route('/search', methods=['GET', 'POST'])
def search_customers():
@@ -353,7 +380,12 @@ def search_customers():
c.mobil,
c.email,
c.fachrichtung,
c.tag
c.tag,
c.handy,
c.tele_firma,
c.kontakt1,
c.kontakt2,
c.kontakt3
FROM customers c
WHERE 1=1
'''
@@ -439,7 +471,12 @@ def search_customers():
'mobil': row[6],
'email': row[7],
'fachrichtung': row[8],
'tag': row[9] # Tag-Feld hinzugefügt
'tag': row[9],
'handy': row[10],
'tele_firma': row[11],
'kontakt1': row[12],
'kontakt2': row[13],
'kontakt3': row[14]
}
formatted_results.append(customer)