Пример #1
0
def publisher_settings_alerts_edit(request, id):
    ''' View to allow a Publisher the ability to edit an Alert '''
    from forms import AlertForm

    alert = get_object_or_404(request.organization.alert_set, id=id)

    if request.method == "POST":
        form = AlertForm(request.POST)

        if form.is_valid():
            alert.alert_field = form.cleaned_data['alert_field']
            alert.time_period = form.cleaned_data['time_period']

            if not form.cleaned_data['up_or_down']:
                alert.change = str(form.cleaned_data['change'] * -1.00)
            else:
                alert.change = str(form.cleaned_data['change'])

            alert.save()

            return HttpResponseRedirect('/publisher/settings/alerts/')
    else:
        form = AlertForm(initial=alert.__dict__)

    return AQ_render_to_response(request,
                                 'publisher/settings/alerts-edit.html', {
                                     'form': form,
                                     'alert': alert,
                                 },
                                 context_instance=RequestContext(request))
Пример #2
0
def publisher_settings_alerts_add(request):
    ''' View to allow a Publisher to Add an Alert '''
    from atrinsic.base.models import Alert
    from forms import AlertForm

    if request.method == "POST":
        form = AlertForm(request.POST)

        if form.is_valid():
            change = form.cleaned_data['change']

            if not form.cleaned_data['up_or_down']:
                change = change * -1.00

            Alert.objects.create(organization=request.organization,
                                 alert_field=form.cleaned_data['alert_field'],
                                 time_period=form.cleaned_data['time_period'],
                                 change=str(change))

            return HttpResponseRedirect('/publisher/settings/alerts/')
    else:
        form = AlertForm()

    return AQ_render_to_response(request,
                                 'publisher/settings/alerts-add.html', {
                                     'form': form,
                                 },
                                 context_instance=RequestContext(request))
Пример #3
0
def publisher_settings_alerts_add(request):
    ''' View to allow a Publisher to Add an Alert '''
    from atrinsic.base.models import Alert
    from forms import AlertForm
    
    if request.method == "POST":
        form = AlertForm(request.POST)

        if form.is_valid():
            change = form.cleaned_data['change']

            if not form.cleaned_data['up_or_down']:
                change = change * -1.00

            Alert.objects.create(organization=request.organization,
                alert_field=form.cleaned_data['alert_field'],
                time_period=form.cleaned_data['time_period'],
                change=str(change))

            return HttpResponseRedirect('/publisher/settings/alerts/')
    else:
        form = AlertForm()

    return AQ_render_to_response(request, 'publisher/settings/alerts-add.html', {
            'form' : form,
        }, context_instance=RequestContext(request))
Пример #4
0
def publisher_settings_alerts_edit(request, id):
    ''' View to allow a Publisher the ability to edit an Alert '''
    from forms import AlertForm
    
    alert = get_object_or_404(request.organization.alert_set, id=id)

    if request.method == "POST":
        form = AlertForm(request.POST)

        if form.is_valid():
            alert.alert_field = form.cleaned_data['alert_field']
            alert.time_period = form.cleaned_data['time_period']

            if not form.cleaned_data['up_or_down']:
                alert.change = str(form.cleaned_data['change'] * -1.00)
            else:
                alert.change = str(form.cleaned_data['change'])

            alert.save()

            return HttpResponseRedirect('/publisher/settings/alerts/')
    else:
        form = AlertForm(initial=alert.__dict__)

    return AQ_render_to_response(request, 'publisher/settings/alerts-edit.html', {
            'form' : form,
            'alert': alert,
        }, context_instance=RequestContext(request))
Пример #5
0
def home(request):
    form = AlertForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():
            alert = form.save(commit=False)
            if alert.postcode:
                location = postcode_lookup(alert.postcode)
                alert.location = Point(location['wgs84_lon'], location['wgs84_lat'])
            else:
                alert.radius = None
            alert.save()
            EmailConfirmation.objects.confirm(
                request, alert,
                'alert-confirmed', 'alert-unsubscribed'
            )

            text = StaticText.objects.get(place='check-email').text
            return render(request, 'check-email.html', { 'text': text })

    return render(request, 'home.html', { 'form': form })