Пример #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))
Пример #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('/')
Пример #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('/')
Пример #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('/')
Пример #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)
Пример #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')
Пример #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)
Пример #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')
Пример #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')