Exemplo n.º 1
0
def index(request):
    if (request.auth_info.admin):
        invitation_list=Invitation.list_all()
    else:
        invitation_list=Invitation.list_my(request.auth_info.email)

    return render_to_response('admin/invitations_index.html', RequestContext(request, { 'invitation_list': invitation_list }))
Exemplo n.º 2
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}))
Exemplo n.º 3
0
def clear_all_all(request):
    if not request.auth_info.admin:
        raise Http404

    invitation_keys=Invitation.keys_all()

    db.delete(invitation_keys)

    return HttpResponseRedirect('..')
Exemplo n.º 4
0
def delete(request, invitation_id):


    invitation = Invitation.get_by_id(int(invitation_id))

    if invitation is None:
        raise Http404

    invitation.delete()

    return HttpResponseRedirect('../..')
Exemplo n.º 5
0
def print_all(request):

    r =  HttpResponse(mimetype='application/pdf')
    file_name = urllib.quote("adresy.pdf")
    logging.info(file_name)
    r['Content-Disposition'] = "attachment; filename*=UTF-8''%s"%file_name

    invitation_list=Invitation.list_my(request.auth_info.email)

    mode = request.GET.get('mode',None)

    pdf.students_invitation(r,invitation_list,mode=mode)

    return r
Exemplo n.º 6
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)
Exemplo n.º 7
0
def edit(request, invitation_id):

    invitation = Invitation.get_by_id(int(invitation_id))

    if invitation is None:
        raise Http404

    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_edit.html', RequestContext(request, {'form':form}))
Exemplo n.º 8
0
def clear_all(request):
    invitation_keys=Invitation.keys_my(request.auth_info.email)
    db.delete(invitation_keys)

    return HttpResponseRedirect('..')