def handle_sub_canceled(sender, instance, **kwargs): instance.cancellation_date = instance.cancellation_date or timezone.now( ).date() for extra in instance.extra_subscription_set.all(): cancel_extra_sub(extra) for part in instance.parts.filter(q_activated()).all(): part.cancel() for part in instance.parts.filter(~q_activated()).all(): part.delete()
def not_started_subscriptions(): return Subscription.objects.filter(~q_activated()).order_by( 'start_date')
def all_active_extrasubscritions(): return ExtraSubscription.objects.filter(q_activated() & ~q_deactivated())
def waiting_extra_subs(): return ExtraSubscription.objects.filter(~q_activated())
def canceled_extra_subs(): return ExtraSubscription.objects.filter(q_activated() & q_cancelled() & ~q_deactivated())
def active_parts(self): return self.parts.filter(q_activated() & ~q_deactivated())
def extra_subscriptions(self): return self.extra_subscription_set.filter(q_activated() & ~q_deactivated())
def types_changed(self): return self.parts.filter(~q_activated() | (q_cancelled() & ~q_deactivated())).count()
def active_subscritions_by_depot(depot): return Subscription.objects.filter(depot=depot).filter(q_activated())
def active_subscriptions(self): return self.subscription_set.filter(q_activated() & ~q_deactivated()).order_by( 'primary_member__first_name')
def get_waiting_for_subscription(subscription): return SubscriptionPart.objects.filter( subscription=subscription).filter(~q_activated())