def send_alert(organisation):
    FFAdminUser.send_alert_to_admin_users(
        subject='Organisation over number of seats',
        message=
        'Organisation %s has used %d seats which is over their plan limit of %d '
        '(plan: %s)' %
        (str(organisation.name), organisation.num_seats,
         organisation.subscription.max_seats, organisation.subscription.plan))
Esempio n. 2
0
def send_alert_if_cancelled(sender, instance, *args, **kwargs):
    try:
        existing_object = sender.objects.get(pk=instance.pk)
    except sender.DoesNotExist:
        return

    if instance.cancellation_date and existing_object.cancellation_date != instance.cancellation_date:
        FFAdminUser.send_alert_to_admin_users(
            subject='Organisation %s has cancelled their subscription' % instance.organisation.name,
            message='Organisation %s has cancelled their subscription on %s' % (instance.organisation.name,
                                                                                datetime.strftime(
                                                                                    instance.cancellation_date,
                                                                                    '%Y-%m-%d %H:%M'))
        )