Ejemplo n.º 1
0
def abbestellen(request, email=None):
    if request.method == 'POST':
        form = AbbestellenForm(request.POST)
        if form.is_valid():
            email = form.cleaned_data.pop('email')            
            try:
                abonnent = Abonnent.objects.get(email=email)

                try:
                    v = Validierung.objects.get(email=email)
                except Validierung.DoesNotExist:
                    v = Validierung(email=email)

                v.aktion='abbestellen'
                v.save()

                Mail().abbestellen(email, v.code)

            except Abonnent.DoesNotExist:
                pass # don't tell the user

            return render(request,'news/abbestellen.html', {'success': True})
    else:
        form = AbbestellenForm(initial={'email': email})

    return render(request,'news/abbestellen.html', {'form': form})
Ejemplo n.º 2
0
def abonnieren(request):
    bezirke = Bezirk.objects.all().values()

    if request.method == 'POST':
        form = AbonnierenForm(request.POST, bezirke=bezirke)
        if form.is_valid():
            email = form.cleaned_data.pop('email')
            bezirkeJson = json.dumps(form.cleaned_data)
            
            try:
                v = Validierung.objects.get(email=email)
            except Validierung.DoesNotExist:
                v = Validierung(email=email)

            v.bezirke = bezirkeJson
            v.aktion = 'abonnieren'
            v.save()

            Mail().abonnieren(email, v.code)

            return render(request,'news/abonnieren.html', {
                'success': True,
                'abbestellen': settings.SITE_URL + '/news/abbestellen/' + email
            })
    else:
        form = AbonnierenForm(bezirke=bezirke)

    return render(request,'news/abonnieren.html', {
        'form': form,
        'abbestellen': settings.SITE_URL + '/news/abbestellen/'
        })