コード例 #1
0
ファイル: views.py プロジェクト: farktronix/WeddingRSVP
def updateemails(request):
    replyID = request.POST.get('replyid')
    reply = None
    try:
        reply = Reply.objects.get(pk=replyID)
    except:
        pass
    
    if reply is None:
        return render_to_response('emailUpdate.html', {
            'errorText' : "Error updating person: not found",
        }, context_instance=RequestContext(request))
        
    
    emails = request.POST.get('emails')
    for email in reply.emails.all():
        email.delete()
    for email in emails.split(','):
        e = InviteEmail()
        e.email = email.strip()
        e.save()
        reply.emails.add(e)
        
    reply.save()
    return render_to_response('emailUpdate.html', {
        'resultText' : "Email address updated for " + reply._attendeeName(),
    }, context_instance=RequestContext(request))
コード例 #2
0
ファイル: views.py プロジェクト: farktronix/WeddingRSVP
def createupdate(request):
    allPeople = []
    for i in xrange(6):
        firstName = request.POST.get('firstName' + str(i))
        if firstName is not None and len(firstName) > 0:
            lastName = request.POST.get('lastName' + str(i)) or ""
            nickName = request.POST.get('nickName' + str(i)) or ""
            preferNick = request.POST.get('preferNick' + str(i)) or False
            allPeople.append(Person(firstName=firstName, 
                       lastName=lastName, 
                       nickName=nickName,
                       prefersNickName=preferNick))
    
    r = None
    if len(allPeople) > 0:
        r = Reply()
        r.ip="127.0.0.1"
        r.save()
        for p in allPeople:
            p.save()
            r.invitedPeople.add(p)
            r.attendingPeople.add(p)
        emails = request.POST.get('email')
        for email in emails.split(','):
            e = InviteEmail()
            e.email = email.strip()
            e.save()
            r.emails.add(e)
        r.hasPlusOne = request.POST.get('allowPlusOne') or False
        r.save()
    
    return render_to_response('adminNewReply.html', {
        'numPeople' : xrange(6),
        'lastReply' : r,
    }, context_instance=RequestContext(request))
コード例 #3
0
ファイル: views.py プロジェクト: farktronix/WeddingRSVP
def updatereply(request):
    reply = None
    try:
        reply = Reply.objects.get(pk=request.POST.get('reply_id'))
    except:
        pass
        
    if reply == None:    
        return newreply(request, "We couldn't find your name in the RSVP list. Please try again with your full name.")
        
    reply.attendingPeople.clear()
    
    willAttend = request.POST.get('willAttend')
    if willAttend == "yes":
        reply.attending = True
        
        for personID in request.POST.getlist('attendee'):
            try:
                p = Person.objects.get(pk=personID)
                if p is not None:
                    reply.attendingPeople.add(p)
            except:
                pass
                
        if reply.hasPlusOne:
            plusOneAttending = request.POST.getlist('attendeePlusOne')
            if plusOneAttending is not None and len(plusOneAttending) > 0:
                reply.plusOneAttending = True

                # Create the plus one person if necessary
                plusOneName = request.POST.get('plusOneName')
                if plusOneName is not None:
                    plusOnePerson = None
                    try:
                        (plusOnePerson, numResults) = _personFromName(plusOneName)
                    except:
                        pass
                    if plusOnePerson is None and plusOneName.lower() != 'guest':
                        # Create a new +1 person
                        nameComps = plusOneName.split()
                        firstName = ""
                        lastName = ""

                        if len(nameComps) > 0:
                            firstName = nameComps[0].capitalize()
                        if len(nameComps) > 1:
                            lastName = nameComps[1].capitalize()

                        plusOnePerson = Person(firstName=firstName, lastName=lastName, isPlusOne=True)
                        plusOnePerson.save()
                    if plusOnePerson is not None:
                        reply.attendingPeople.add(plusOnePerson)
            else:
                reply.plusOneAttending = False
    elif willAttend == "no":
        reply.attending = False
        reply.plusOneAttending = False
    
    emails = request.POST.get('emails')
    reply.emails.clear()
    for email in emails.split(','):
        e = InviteEmail()
        e.email = email.strip()
        e.save()
        reply.emails.add(e)
    
    reply.comment = request.POST.get('comment')
    
    reply.replyDate = datetime.datetime.now()
    reply.ip = _get_client_ip(request)
        
    reply.save()
    
    log = ReplyLog()
    log.ip = _get_client_ip(request)
    log.reply = reply
    log.save()
    log.initWithReply(reply)
    log.save()
    
    return render_to_response('replyupdated.html', {
        "reply"  : reply,
        "replyName" : reply._attendeeName()
    }, context_instance=RequestContext(request))