# Copyright © 2022 Aravinth Manivannan # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . from datetime import datetime, timedelta, timezone from payments import get_payment_model, RedirectNeeded, PaymentStatus from django.contrib.auth.models import User from django.shortcuts import get_object_or_404 from dash.models import Instance def payment_fullfilled(instance: Instance) -> bool: Payment = get_payment_model() now = datetime.now(tz=timezone.utc) delta = now - timedelta(seconds=(60 * 60 * 24 * 30)) # one month payment = None for p in Payment.objects.filter(date__gt=(delta), instance_name=instance.name): if p.status == PaymentStatus.CONFIRMED: return True return False