Esempio n. 1
0
def create(request):

    invitation = Invitation()
    invitation.init(owner=request.auth_info.email)
    if request.method == 'POST':
        form = InvitationForm(request.POST, instance=invitation)
        if form.is_valid():
            logging.info('edit invitation before %s'% invitation)
            form.save(commit=False)
            logging.info('edit invitation after %s'% invitation)
            invitation.save()
            return HttpResponseRedirect('..')
    else:
        form = InvitationForm(instance=invitation)

    return render_to_response('admin/invitations_create.html', RequestContext(request, {'form':form}))
Esempio n. 2
0
def prepare_invitation(owner, student_id, mode, addressing_parents, addressing_p, addressing_s, addressing_d):
    student = Student.get_by_id(int(student_id))
    if student is None:
        return
  

    logging.info('student: %s'%student)

    addressing=''
    iname = None
    isurname = None
    if mode=='parents':
        addressing=addressing_parents
        sex=student.get_sex()
        if not student.name is None:
            iname = inflector.do_inflect('name',sex,student.name)
        
        if not student.surname is None:
            isurname = inflector.do_inflect('surname',sex,student.surname)

    elif mode=='direct':
        if student.addressing =='p':
            addressing=addressing_p
        elif student.addressing =='s':
            addressing=addressing_s
        elif student.addressing =='d':
            addressing=addressing_d
       
    logging.info('addressing:%s'%addressing) 
 
    invitation = Invitation() 
    
    invitation.init(owner=owner,mode=mode, addressing=addressing, name=student.name, surname=student.surname, sex=student.get_sex(), street=student.street,
        street_no=student.street_no, city=student.city, post_code=student.post_code
                )

    if not iname is None:
        invitation.name_inflected = iname
    if not isurname is None:
        invitation.surname_inflected = isurname


    logging.info('pre save invitation=%s'%invitation)

    invitation.save()
    logging.info('invitation=%s'%invitation)