Exemplo n.º 1
0
def update_contact(contact, subscribe):
    email = contact.email
    current = Subscription.email_is_subscribed(email)
    
    if current == subscribe:
        if subscribe:
            result = _("Already subscribed %(email)s.")
        else:
            result = _("Already removed %(email)s.")
        
    else:
        sub, created = Subscription.objects.get_or_create(email=email)
        sub.subscribed = subscribe
        sub.save()
        log.debug("Subscription now: %s" % sub)

        if subscribe:
            result = _("Subscribed: %(email)s")
        else:
            result = _("Unsubscribed: %(email)s")

    return result % { 'email' : email }
    
Exemplo n.º 2
0
def is_subscribed(contact):
    return Subscription.email_is_subscribed(contact.email)