|
@@ -245,19 +245,16 @@ class AdhesionAdmin(AdtSearchMixin, admin.ModelAdmin):
|
|
|
def has_delete_permission(self, request, obj=None):
|
|
|
if not obj:
|
|
|
return False
|
|
|
- membership = obj.membership.current
|
|
|
one_year_ago = timezone.now() - timedelta(days=365)
|
|
|
-
|
|
|
- if membership and (membership.payment_method != PaymentUpdate.STOP or membership.start > one_year_ago):
|
|
|
+ membership = obj.membership.updates.filter(validated=True).first()
|
|
|
+
|
|
|
+ if not membership or membership.payment_method != PaymentUpdate.STOP or membership.start > one_year_ago:
|
|
|
return False
|
|
|
|
|
|
- if obj.antenna_set.all():
|
|
|
+ if obj.antenna_set.exists():
|
|
|
return False
|
|
|
-
|
|
|
- if any(map(lambda s: any(map(lambda a: a.end is None or a.end > one_year_ago, s.allocations.all())), obj.services.all())):
|
|
|
- return False
|
|
|
-
|
|
|
- if any(map(lambda s: s.contribution.current and (s.contribution.current.payment_method != PaymentUpdate.STOP or s.contribution.current.start > one_year_ago), obj.services.all())):
|
|
|
+
|
|
|
+ if obj.services.exists():
|
|
|
return False
|
|
|
return True
|
|
|
|