Exemplo n.º 1
0
def mensajes(request, lang):
    if not request.user.is_authenticated() or request.user.is_superuser:
        return HttpResponseRedirect('/%s/index?next=%s' % (lang,request.path))
    code = request.user.code
    log = AccessLog(code=code, page=request.path)
    log.save()
    submitted = False
    if request.method == 'POST':
        if request.POST.get('body'):
            msg = Message(msg=request.POST.get('body'),
                          public=request.POST.get('public', False),
                          rte=code, language=lang)
            msg.save()
            submitted = True

    otherlang = (lang == 'es') and 'en' or 'es'
    msgs = Message.objects.filter(public=True).exclude(language__exact=otherlang).order_by('-timestamp')
    startdate = datetime.datetime(2010, 7, 25)
    for msg in msgs:
        msg.localTo = msg.rte.to(lang)
        msg.own = msg.rte == code
        if msg.timestamp > startdate:
            msg.timestampstr = pronounce_date(msg.timestamp, lang)

    atts = {'lang': lang, 'spanish': lang=='es',
            'nametag': nTag(request),
            'sent_rsvp': request.user.code.sent_rsvp,
            'invited_to_party': request.user.code.invited_to_party,
            'code': code.code, 'pays': code.pays, 'dinner': code.dinner,
            'submitted': submitted,
            'msgs': msgs,
           }
    context = RequestContext(request, atts)
    return render_to_response('mensajes.html', context)
Exemplo n.º 2
0
def novedades(request, lang):
    if not request.user.is_authenticated() or request.user.is_superuser:
        return HttpResponseRedirect('/%s/index?next=%s' % (lang,request.path))
    code = request.user.code
    log = AccessLog(code=code, page=request.path)
    log.save()
    news = Novedad.objects.order_by('-date').filter(language=lang)
    for n in news:
        n.datestr = pronounce_date(n.date, lang)
    atts = {'lang': lang, 'spanish': lang=='es',
            'nametag': nTag(request),
            'sent_rsvp': request.user.code.sent_rsvp,
            'invited_to_party': request.user.code.invited_to_party,
            'code': code.code, 'pays': code.pays, 'dinner': code.dinner,
            'news': news,
           }
    context = RequestContext(request, atts)
    return render_to_response('news.html', context)