diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..cc924cb --- /dev/null +++ b/.env.example @@ -0,0 +1,18 @@ +# Flask Konfiguration +SECRET_KEY=your-secret-key-here +FLASK_ENV=development +FLASK_DEBUG=True + +# Oracle Datenbank Konfiguration +ORACLE_HOST=your-oracle-host.com +ORACLE_PORT=1521 +ORACLE_SERVICE_NAME=ORCL +ORACLE_USERNAME=your_username +ORACLE_PASSWORD=your_password + +# PostgreSQL Datenbank Konfiguration (optional) +POSTGRES_HOST=your-postgres-host.com +POSTGRES_PORT=5432 +POSTGRES_DATABASE=your_database +POSTGRES_USERNAME=your_username +POSTGRES_PASSWORD=your_password \ No newline at end of file diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..b410b5b --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,54 @@ + +- [x] Verify that the copilot-instructions.md file in the .github directory is created. ✓ Completed + +- [x] Clarify Project Requirements - Python Flask web server with authentication, SQL query builder interface with table list on left, query input and results on right, ability to save and retrieve queries via API as JSON/CSV + + +- [x] Scaffold the Project - ✓ Flask project structure created with authentication, database models, routes, templates, and static files + + +- [x] Customize the Project - ✓ Completed with full query builder functionality, authentication, and API endpoints + + +- [x] Install Required Extensions - ✓ No additional extensions needed + + +- [x] Compile the Project - ✓ Completed - Python environment configured and all dependencies installed successfully + + +- [ ] Create and Run Task + + +- [ ] Launch the Project + + +- [ ] Ensure Documentation is Complete + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5731387 --- /dev/null +++ b/.gitignore @@ -0,0 +1,63 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# Flask +instance/ +.webassets-cache + +# Environment variables +.env + +# IDE +.vscode/ +.idea/ +*.swp +*.swo + +# OS +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Database +*.db +*.sqlite +*.sqlite3 + +# Logs +*.log + +# Virtual Environment +.venv/ +venv/ +ENV/ +env/ +.env + +# Temporary files +*.tmp +*.temp \ No newline at end of file diff --git a/app/__init__.py b/app/__init__.py index b2ea99c..01286a3 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -46,7 +46,7 @@ def create_app(): from app.models import User admin = User.query.filter_by(username='admin').first() if not admin: - admin = User(username='admin', email='admin@example.com') + admin = User(username='admin', email='admin@example.com', is_admin=True) admin.set_password('admin123') db.session.add(admin) db.session.commit() diff --git a/app/__pycache__/__init__.cpython-313.pyc b/app/__pycache__/__init__.cpython-313.pyc index 7ec576d..48c7f93 100644 Binary files a/app/__pycache__/__init__.cpython-313.pyc and b/app/__pycache__/__init__.cpython-313.pyc differ diff --git a/app/templates/admin/create_user.html b/app/templates/admin/create_user.html new file mode 100644 index 0000000..96a5c45 --- /dev/null +++ b/app/templates/admin/create_user.html @@ -0,0 +1,88 @@ +{% extends "base.html" %} + +{% block title %}Neuen Benutzer erstellen{% endblock %} + +{% block content %} +
+
+
+
+

Neuen Benutzer erstellen

+ + Zurück + +
+ +
+
+
+
+ + +
Der Benutzername muss eindeutig sein
+
+ +
+ + +
Die E-Mail-Adresse muss eindeutig sein
+
+ +
+ + +
Mindestens 6 Zeichen erforderlich
+
+ +
+
+ + +
+ Administratoren können andere Benutzer verwalten und haben Vollzugriff +
+
+
+ +
+ + + Abbrechen + +
+
+
+
+ + +
+
+
Wichtige Hinweise
+
+
+
    +
  • Alle mit * markierten Felder sind Pflichtfelder
  • +
  • Der Benutzername und die E-Mail-Adresse müssen eindeutig sein
  • +
  • Das Passwort sollte sicher gewählt werden
  • +
  • Administrator-Rechte gewähren Vollzugriff auf alle Funktionen
  • +
  • Neue Benutzer können sich sofort mit ihren Anmeldedaten einloggen
  • +
+
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/app/templates/admin/dashboard.html b/app/templates/admin/dashboard.html new file mode 100644 index 0000000..c633caa --- /dev/null +++ b/app/templates/admin/dashboard.html @@ -0,0 +1,173 @@ +{% extends "base.html" %} + +{% block title %}Admin Dashboard{% endblock %} + +{% block content %} +
+
+
+
+

Admin Dashboard

+ + Zurück zum Dashboard + +
+ + +
+
+
+
+
+
+

{{ users|length }}

+ Benutzer gesamt +
+ +
+
+
+
+
+
+
+
+
+

{{ users|selectattr('is_admin')|list|length }}

+ Administratoren +
+ +
+
+
+
+
+
+
+
+
+

{{ users|rejectattr('is_admin')|list|length }}

+ Standard-Benutzer +
+ +
+
+
+
+
+
+
+
+
+

{{ (users|selectattr('created_at')|map(attribute='created_at')|list|length) }}

+ Aktive Benutzer +
+ +
+
+
+
+
+ + + + + +
+
+
+
+
Letzte Benutzer
+
+
+ {% if users %} +
+ + + + + + + + + + + + {% for user in users[:5] %} + + + + + + + + {% endfor %} + +
BenutzernameE-MailRolleErstellt amAktionen
+ {{ user.username }} + {% if user.id == current_user.id %} + Sie + {% endif %} + {{ user.email }} + {% if user.is_admin %} + Administrator + {% else %} + Benutzer + {% endif %} + {{ user.created_at.strftime('%d.%m.%Y %H:%M') }} + + + +
+
+ + {% else %} +
+ +
Keine Benutzer gefunden
+

Erstellen Sie den ersten Benutzer über den Button oben.

+
+ {% endif %} +
+
+
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/app/templates/admin/edit_user.html b/app/templates/admin/edit_user.html new file mode 100644 index 0000000..644d186 --- /dev/null +++ b/app/templates/admin/edit_user.html @@ -0,0 +1,145 @@ +{% extends "base.html" %} + +{% block title %}Benutzer bearbeiten{% endblock %} + +{% block content %} +
+
+
+
+

Benutzer bearbeiten

+ + Zurück + +
+ +
+
+
+ {{ user.username }} + {% if user.id == current_user.id %} + Sie + {% endif %} + {% if user.is_admin %} + Administrator + {% endif %} +
+
+
+
+
+ + +
Der Benutzername muss eindeutig sein
+
+ +
+ + +
Die E-Mail-Adresse muss eindeutig sein
+
+ +
+ + +
Nur ausfüllen wenn Sie das Passwort ändern möchten (mindestens 6 Zeichen)
+
+ +
+
+ + + {% if user.id == current_user.id %} +
+ Sie können Ihre eigenen Admin-Rechte nicht ändern +
+ {% else %} +
+ Administratoren können andere Benutzer verwalten und haben Vollzugriff +
+ {% endif %} +
+
+ +
+ + + Abbrechen + +
+
+
+
+ + +
+
+
Benutzer-Informationen
+
+
+
+
Benutzer-ID:
+
{{ user.id }}
+
+
+
Erstellt am:
+
{{ user.created_at.strftime('%d.%m.%Y %H:%M:%S') }}
+
+
+
Rolle:
+
+ {% if user.is_admin %} + Administrator + {% else %} + Standard-Benutzer + {% endif %} +
+
+
+
Anzahl Queries:
+
{{ user.saved_queries|length }}
+
+
+
+ + + {% if user.id != current_user.id %} +
+
+
Gefahrenbereich
+
+
+

+ Achtung: Das Löschen eines Benutzers kann nicht rückgängig gemacht werden. + Alle gespeicherten Queries dieses Benutzers gehen verloren. +

+
+ +
+
+
+ {% endif %} +
+
+
+{% endblock %} \ No newline at end of file diff --git a/app/templates/admin/users.html b/app/templates/admin/users.html new file mode 100644 index 0000000..fe34cc7 --- /dev/null +++ b/app/templates/admin/users.html @@ -0,0 +1,154 @@ +{% extends "base.html" %} + +{% block title %}Benutzerverwaltung{% endblock %} + +{% block content %} +
+
+
+ + + {% if users %} +
+
+
+ + + + + + + + + + + + + {% for user in users %} + + + + + + + + + {% endfor %} + +
IDBenutzernameE-MailRolleErstellt amAktionen
{{ user.id }} + {{ user.username }} + {% if user.id == current_user.id %} + Sie + {% endif %} + {{ user.email }} +
+ {% if user.is_admin %} + + Administrator + + {% else %} + + Benutzer + + {% endif %} + + {% if user.id != current_user.id %} + + {% endif %} +
+
{{ user.created_at.strftime('%d.%m.%Y %H:%M') }} +
+ + + + + {% if user.id != current_user.id %} +
+ +
+ {% endif %} +
+
+
+
+
+ {% else %} +
+
+ +

Keine Benutzer gefunden

+

Erstellen Sie den ersten Benutzer.

+ + Ersten Benutzer erstellen + +
+
+ {% endif %} +
+
+
+ + +{% endblock %} \ No newline at end of file diff --git a/app/templates/base.html b/app/templates/base.html index 8f878e3..58fa90e 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -23,8 +23,16 @@ {% if current_user.is_authenticated %}