Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 84ac9e812a | |||
| d2f882ed61 | |||
| 4c586abee0 |
+4
-4
@@ -71,6 +71,10 @@ def get_current_status(ausleihung, log_changes=False, user=None):
|
||||
# Bei stornierten Ausleihungen bleibt der Status immer storniert
|
||||
if original_status == 'cancelled':
|
||||
return 'cancelled'
|
||||
|
||||
# Wenn die Ausleihung bereits abgeschlossen ist, bleibt sie es
|
||||
if original_status == 'completed':
|
||||
return 'completed'
|
||||
|
||||
current_time = datetime.datetime.now()
|
||||
start_time = ausleihung.get('Start')
|
||||
@@ -79,10 +83,6 @@ def get_current_status(ausleihung, log_changes=False, user=None):
|
||||
# Wenn kein Startdatum vorhanden ist, Status auf 'planned' setzen
|
||||
if not start_time:
|
||||
new_status = 'planned'
|
||||
# Wenn die Ausleihung als 'completed' markiert wurde und ein Enddatum hat,
|
||||
# bleibt sie bei 'completed'
|
||||
elif original_status == 'completed' and end_time:
|
||||
new_status = 'completed'
|
||||
# Wenn die aktuelle Zeit vor dem Startdatum liegt, ist die Ausleihung geplant
|
||||
elif current_time < start_time:
|
||||
# DEBUG: Log info wenn Booking noch lange in der Zukunft ist
|
||||
|
||||
@@ -324,7 +324,8 @@ def _send_web_push_notification(subscription, payload):
|
||||
data=json.dumps(payload),
|
||||
vapid_private_key=VAPID_PRIVATE_KEY,
|
||||
vapid_claims={'sub': VAPID_SUBJECT},
|
||||
timeout=10
|
||||
timeout=10,
|
||||
ttl=3600 # Notification expires after 1 hour if device is offline
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
@@ -13,4 +13,5 @@ redis
|
||||
reportlab
|
||||
python-barcode
|
||||
openpyxl
|
||||
cryptographypywebpush
|
||||
cryptography
|
||||
pywebpush
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
<label for="booking-type">Reservierungstyp:</label>
|
||||
<select id="booking-type" name="booking_type">
|
||||
<option value="single">Einzeltermin</option>
|
||||
<option value="range">Zeitraum</option>
|
||||
<option value="recurring">Wiederkehrend</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -624,6 +626,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
}
|
||||
|
||||
const userId = document.getElementById('user-id').value || 'Admin'; // Get user ID or use fallback
|
||||
const bookingType = document.getElementById('booking-type').value;
|
||||
|
||||
// Convert JSON data to FormData
|
||||
const formData = new FormData();
|
||||
@@ -631,16 +634,43 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// Add all required fields with correct names the server expects
|
||||
formData.append('item_id', itemId);
|
||||
formData.append('booking_date', startDate);
|
||||
formData.append('booking_end_date', startDate); // For single bookings, end = start
|
||||
formData.append('period_start', periodStart);
|
||||
formData.append('period_end', periodEnd);
|
||||
formData.append('notes', document.getElementById('booking-notes').value || '');
|
||||
formData.append('booking_type', document.getElementById('booking-type').value);
|
||||
formData.append('user_id', userId);
|
||||
|
||||
if (bookingType === 'range') {
|
||||
const endDate = document.getElementById('booking-end-date').value;
|
||||
if (!endDate) {
|
||||
alert('Bitte wählen Sie ein Enddatum für den Zeitraum.');
|
||||
return;
|
||||
}
|
||||
formData.append('booking_end_date', endDate);
|
||||
formData.append('booking_type', 'range');
|
||||
} else if (bookingType === 'recurring') {
|
||||
formData.append('booking_type', 'single'); // Server expects 'single' structure for these individually sent requests
|
||||
const dates = calculateDates();
|
||||
if (dates.length === 0) {
|
||||
alert('Es konnten keine Termine berechnet werden. Bitte überprüfen Sie Ihre Eingaben.');
|
||||
return;
|
||||
}
|
||||
if (confirm(`Möchten Sie wirklich ${dates.length} Termine planen?`)) {
|
||||
processMultipleDates(formData, dates, periodStart, periodEnd);
|
||||
}
|
||||
return; // Use processMultipleDates instead
|
||||
} else {
|
||||
formData.append('booking_end_date', startDate); // For single bookings, end = start
|
||||
formData.append('booking_type', 'single');
|
||||
}
|
||||
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]') ? document.querySelector('meta[name="csrf-token"]').content : '';
|
||||
|
||||
// Submit with FormData instead of JSON
|
||||
fetch('/plan_booking', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken
|
||||
},
|
||||
body: formData // Remove the Content-Type header and JSON.stringify
|
||||
})
|
||||
.then(response => {
|
||||
@@ -681,8 +711,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// Cancel booking
|
||||
document.getElementById('cancel-booking').addEventListener('click', function() {
|
||||
if (confirm('Möchten Sie diese Ausleihe wirklich stornieren?')) {
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]') ? document.querySelector('meta[name="csrf-token"]').content : '';
|
||||
fetch('/cancel_booking/' + currentEventId, {
|
||||
method: 'POST'
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
@@ -1131,8 +1165,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
newFormData.get('end_date'));
|
||||
|
||||
// Submit this booking
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]') ? document.querySelector('meta[name="csrf-token"]').content : '';
|
||||
fetch('/plan_booking', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken
|
||||
},
|
||||
body: newFormData
|
||||
})
|
||||
.then(response => response.json())
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
from app import app
|
||||
with app.test_client() as client:
|
||||
with client.session_transaction() as sess:
|
||||
sess['username'] = 'admin'
|
||||
sess['admin'] = True
|
||||
resp = client.get('/terminplan')
|
||||
print("Status:", resp.status_code)
|
||||
+1
-1
@@ -13,4 +13,4 @@ reportlab
|
||||
python-barcode
|
||||
openpyxl
|
||||
cryptography
|
||||
pywebpushpywebpush
|
||||
pywebpush
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
from Web.app import app
|
||||
with app.test_client() as client:
|
||||
resp = client.get('/terminplan')
|
||||
print(resp.status_code)
|
||||
# print(resp.data.decode('utf-8')[:200])
|
||||
Reference in New Issue
Block a user