Пример #1
0
def index(request):
    storage = Storage(GmailCredentials, 'id', request.user, 'credential')
    credential = storage.get()
    if credential is None or credential.invalid == True:
        return redirect(reverse('gmail:index'))
    else:
        conn = Connection(request.user, credential)
        
        results = conn.find("label:!projekt-vlab-test")
        
        messages = []
        
        for result in results: 
            messages.append(conn.read(result))

        return render_to_response('gmail_test/index.html', {'messages': messages})
Пример #2
0
def update(request):
    storage = Storage(GmailCredentials, 'id', request.user, 'credential')
    credential = storage.get()
    if False:
        return redirect(reverse('gmail:index'))
    else:
        conn = Connection(request.user, credential)
        
        results = conn.find("label:!projekt-vlab-test")
        
        if results:
            message = conn.read(results[0])
            
            message.content['tags'] = [{'tag': "!Projekt/VLAB/TestUpdated"}]
            print "\n" + repr(results[0]) + "\n"
            print repr(message.content['tags']) + "\n"
        
            conn.update(results[0], message)
        else:
            message = None

        return render_to_response('gmail_test/update.html', {'message': message})