Exemple #1
0
def gift(request, id):
    if not request.META.__contains__('HTTP_REFERER'):
        return redirect('/%s/panel/get_password/' % (id))
    if request.POST:
        wedding = get_or_404(Wedding, pk=id)
        Gift.objects.create(wedding=wedding.id, name=request.POST['name'])
    return redirect('/%s/panel/#gifts' % (wedding.id))
Exemple #2
0
def comment(request, institute):
    if request.POST:
        institute = get_or_404(Institute, pk=institute)
        exp = ''
        for w in settings.UNAVAILABLE_WORDS:
            if exp is '':
                exp = w
            else:
                exp += '|'+w
        regexp = re.compile('('+exp+')+',re.UNICODE)
        if re.search(regexp,request.POST['text'].lower()):
            return redirect('/%s?unavailable=1' % (institute.id))
        if institute.comments.filter(text=request.POST['text']).count() > 0:
            return redirect('/%s?said=1' % (institute.id))
        comment = Comment.objects.create(
            text=request.POST['text']
        )
        institute.comments.add(comment)
        try:
            tw = twitter.Api(
                consumer_key=settings.CONSUMER_KEY_TWITTER,
                consumer_secret=settings.CONSUMER_SECRET_TWITTER,
                access_token_key=settings.TOKEN_TWITTER,
                access_token_secret=settings.SECRET_TOKEN_TWITTER,
            )
            tw.PostUpdate(
                u'hola %s, tienes un comentario anonimo %s (%s)' % (institute.alias, settings.URL+'/'+str(institute.id), comment.text[:25]+'...')
            )
        except:
            pass
        return redirect('/%s' % (institute.id))
    return redirect('/404')
Exemple #3
0
def welcome(request, id):
    if not request.META.__contains__('HTTP_REFERER'):
        return redirect('/%s/panel/get_password/' % (id))
    wedding = get_or_404(Wedding, pk=id)
    if request.POST:
        wedding.welcome = request.POST['welcome']
        wedding.save()
    return redirect('/%s/panel/#welcome' % (wedding.id))
Exemple #4
0
def set_password(request, id):
    wedding = get_or_404(Wedding,pk=id,password='')
    if request.POST:
        wedding.password = hashlib.sha224(request.POST['password']).hexdigest()
        wedding.save()
        return redirect('/%s/panel/' % (wedding.id))
    args = {}
    return render('set_password.html', args, context_instance=rc(request))
Exemple #5
0
def view(request, character):
    character = get_or_404(Character, pk=character)
    i = Institute.objects.filter(characters__id=character.id)[0]
    args = {
        'character' : character,
        'institute' : i,
    }
    return render('view_character.html', args, context_instance=rc(request))
Exemple #6
0
def get_password(request, id):
    wedding = get_or_404(Wedding,pk=id)
    message = None
    if request.POST:
        password1 = hashlib.sha224(request.POST['password']).hexdigest()
        password2 = wedding.password
        if password1 == password2:
            return redirect('/%s/panel/' % (id))
        else:
            message = _(u'Lo sentimos, password incorrecto, intenta de nuevo.')
    args = {'message':message}
    return render('get_password.html', args, context_instance=rc(request))
Exemple #7
0
def create(request, institute):
    institute = get_or_404(Institute, pk=institute)
    if request.POST:
        character = Character.objects.create(
            name = request.POST['name'],
            alias = request.POST['alias'],
            image = request.FILES['image']
        )
        institute.characters.add(character)
        return redirect('/char/%s' % (character.id))
    args = {
        'institute': institute,
    }
    return render('create_character.html', args, context_instance=rc(request))
Exemple #8
0
def panel(request, id):
    if not request.META.__contains__('HTTP_REFERER'):
        return redirect('/%s/panel/get_password/' % (id))
    wedding = get_or_404(Wedding, pk=id)
    info_form = InfoForm(instance=wedding)
    if request.POST:
        info_form = InfoForm(request.POST, instance=wedding)
        if info_form.is_valid():
            info_form.save()
            return redirect('/%s/panel/#info' % (wedding.id))
    gifts = Gift.objects.filter(wedding=wedding.id)
    args = {
        'gifts':gifts,
        'info_form':info_form,
        'wedding':wedding,
    }
    return render('panel.html', args, context_instance=rc(request))
Exemple #9
0
def mark_gift(request):
    gift = get_or_404(Gift,pk=request.GET['id'])
    gift.taken=True
    gift.save()
    return HttpResponse('1');
Exemple #10
0
def view(request, institute):
    args = {
        'institute' : get_or_404(Institute, pk=institute),
        'characters' : get_or_404(Institute, pk=institute).characters.all()
    }
    return render('view_institute.html', args, context_instance=rc(request))