(request)
return ajax_success(msg=msg)
Toggle user subscription to Biostar Herald.
Toggle user subscription to Biostar Herald.
Toggle user subscription to Biostar Herald .
def herald_subscribe(request):
    """
    Toggle user subscription to Biostar Herald.
    """
    user = request.user

    # Get the herald email group
    group = EmailGroup.objects.filter(uid='herald').first()
    sub = EmailSubscription.objects.filter(email=user.email, group=group)

    if sub:
        sub.delete()
        msg = "Unsubscribed to Biostar Herald"
    else:
        EmailSubscription.objects.create(email=user.email, group=group)
        msg = "Subscribed to Biostar Herald"

    return ajax_success(msg=msg)
def herald_subscribe ( request ) : user = request . user # Get the herald email group group = EmailGroup . objects . filter ( uid = 'herald' ) . first ( ) sub = EmailSubscription . objects . filter ( email = user . email , group = group ) if sub : sub . delete ( ) msg = "Unsubscribed to Biostar Herald" else : EmailSubscription . objects . create ( email = user . email , group = group ) msg = "Subscribed to Biostar Herald" return ajax_success ( msg = msg )