Esempio n. 1
0
def index(request):
    m = get_mailchimp_api()
    try:
        m.helper.ping()
    except mailchimp.Error:
        messages.error(request,  "Invalid API key")
    return render_to_response('home.html', {}, context_instance=RequestContext(request))
Esempio n. 2
0
def index(request):
    try:
        m = get_mailchimp_api()
        lists = m.lists.list()
    except mailchimp.Error, e:
        messages.error(request,  'An error occurred: %s - %s' % (e.__class__, e))
        return redirect('/')
Esempio n. 3
0
def index(request):
    try:
        m = get_mailchimp_api()
        campaigns = m.campaigns.list({'status':'sent'})
    except mailchimp.Error, e:
        messages.error(request,  'An error occurred: %s - %s' % (e.__class__, e))
        return redirect('/')
Esempio n. 4
0
def index(request):
    try:
        m = get_mailchimp_api()
        lists = m.lists.list()
    except mailchimp.Error, e:
        messages.error(request,
                       'An error occurred: %s - %s' % (e.__class__, e))
        return redirect('/')
Esempio n. 5
0
def subscribe(request, list_id):
    try:
        m = get_mailchimp_api()
        m.lists.subscribe(list_id, {'email':request.POST['email']})
        messages.success(request,  "The email has been successfully subscribed")
    except mailchimp.ListAlreadySubscribedError:
        messages.error(request,  "That email is already subscribed to the list")
        return redirect('/lists/'+list_id)
    except mailchimp.Error, e:
        messages.error(request,  'An error occurred: %s - %s' % (e.__class__, e))
        return redirect('/lists/'+list_id)
Esempio n. 6
0
def view(request, list_id):
    try:
        m = get_mailchimp_api()
        lists = m.lists.list({'list_id':list_id})
        list = lists['data'][0]
        members = m.lists.members(list_id)['data']
    except mailchimp.ListDoesNotExistError:
        messages.error(request,  "The list does not exist")
        return redirect('/lists')
    except mailchimp.Error, e:
        messages.error(request,  'An error occurred: %s - %s' % (e.__class__, e))
        return redirect('/lists')
Esempio n. 7
0
def subscribe(request, list_id):
    try:
        m = get_mailchimp_api()
        m.lists.subscribe(list_id, {'email': request.POST['email']})
        messages.success(request, "The email has been successfully subscribed")
    except mailchimp.ListAlreadySubscribedError:
        messages.error(request, "That email is already subscribed to the list")
        return redirect('/lists/' + list_id)
    except mailchimp.Error, e:
        messages.error(request,
                       'An error occurred: %s - %s' % (e.__class__, e))
        return redirect('/lists/' + list_id)
Esempio n. 8
0
def view(request, cid):
    try:
        m = get_mailchimp_api()
        campaigns = m.campaigns.list({'cid':cid})
        campaign = campaigns['data'][0]
        report = m.reports.summary(cid)
    except mailchimp.CampaignDoesNotExistError:
        messages.error(request,  "The campaign does not exist")
        return redirect('/reports')
    except mailchimp.Error, e:
        messages.error(request,  'An error occurred: %s - %s' % (e.__class__, e))
        return redirect('/reports')
Esempio n. 9
0
def view(request, list_id):
    try:
        m = get_mailchimp_api()
        lists = m.lists.list({'list_id': list_id})
        list = lists['data'][0]
        members = m.lists.members(list_id)['data']
    except mailchimp.ListDoesNotExistError:
        messages.error(request, "The list does not exist")
        return redirect('/lists')
    except mailchimp.Error, e:
        messages.error(request,
                       'An error occurred: %s - %s' % (e.__class__, e))
        return redirect('/lists')