예제 #1
0
def advertiser_messages_campaigns_edit(request, id):
    ''' View to edit an EmailCampaign '''
    from forms import EmailCampaignForm
    campaign = get_object_or_404(request.organization.emailcampaign_set, id=id)

    if request.method == "POST":
        form = EmailCampaignForm(request.POST, org=request.organization)

        if form.is_valid():
            for k, v in form.cleaned_data.items():
                setattr(campaign, k, v)

            campaign.save()
            return HttpResponseRedirect('/advertiser/messages/campaigns/%d/' %
                                        campaign.id)

    else:
        form = EmailCampaignForm(initial={
            'name': campaign.name,
            'email_from': campaign.email_from,
            'reply_to_address': campaign.reply_to_address,
            'subject': campaign.subject,
            'body': campaign.body,
            'html_body': campaign.html_body,
            'date_send': datetime.date.today(),
        },
                                 org=request.organization)

    return AQ_render_to_response(request,
                                 'advertiser/messages/campaign-edit.html', {
                                     'campaign': campaign,
                                     'form': form,
                                 },
                                 context_instance=RequestContext(request))
예제 #2
0
def advertiser_messages_campaigns_edit(request, id):
    ''' View to edit an EmailCampaign '''
    from forms import EmailCampaignForm
    campaign = get_object_or_404(request.organization.emailcampaign_set, id=id)

    if request.method == "POST":
        form = EmailCampaignForm(request.POST, org=request.organization)

        if form.is_valid():
            for k, v in form.cleaned_data.items():
                setattr(campaign, k, v)

            campaign.save()
            return HttpResponseRedirect('/advertiser/messages/campaigns/%d/' % campaign.id)

    else:
        form = EmailCampaignForm(initial={
                    'name' : campaign.name,
                    'email_from' : campaign.email_from,
                    'reply_to_address' : campaign.reply_to_address,
                    'subject' : campaign.subject,
                    'body' : campaign.body,
                    'html_body' : campaign.html_body,
                    'date_send': datetime.date.today(),
               }, org=request.organization)

    return AQ_render_to_response(request, 'advertiser/messages/campaign-edit.html', {
                'campaign' : campaign,
                'form' : form,
            }, context_instance=RequestContext(request))
예제 #3
0
def advertiser_messages_campaigns_add(request):
    ''' This view allows Advertisers to create a new EmailCampaign.  Additionally
        the Campaign can be assigned to a Group by providing a group_id '''
    from forms import EmailCampaignForm
    from atrinsic.base.models import EmailCampaign, PublisherGroup
    group_id = request.REQUEST.get('group_id', None)

    if request.method == "POST":
        form = EmailCampaignForm(request.POST, org=request.organization)

        if form.is_valid():
            c = EmailCampaign(advertiser=request.organization)
            for k, v in form.cleaned_data.items():
                setattr(c, k, v)
            c.save()

            if group_id:
                try:
                    g = PublisherGroup.objects.get(id=group_id)
                    c.publisher_group.add(g)
                except PublisherGroup.DoesNotExist:
                    pass
            return HttpResponseRedirect('/advertiser/messages/campaigns/%d/' %
                                        c.id)
    else:
        form = EmailCampaignForm(initial={'date_send': datetime.date.today()},
                                 org=request.organization)

    return AQ_render_to_response(request,
                                 'advertiser/messages/campaign-add.html', {
                                     'form': form,
                                     'group_id': group_id,
                                 },
                                 context_instance=RequestContext(request))
예제 #4
0
def advertiser_messages_campaigns_add(request):
    ''' This view allows Advertisers to create a new EmailCampaign.  Additionally
        the Campaign can be assigned to a Group by providing a group_id '''
    from forms import EmailCampaignForm
    from atrinsic.base.models import EmailCampaign, PublisherGroup
    group_id = request.REQUEST.get('group_id', None)
 
    if request.method == "POST":
        form = EmailCampaignForm(request.POST, org=request.organization)

        if form.is_valid():
            c = EmailCampaign(advertiser=request.organization)
            for k, v in form.cleaned_data.items():
                setattr(c, k, v)
            c.save()

            if group_id:
                try:
                    g = PublisherGroup.objects.get(id=group_id)
                    c.publisher_group.add(g)
                except PublisherGroup.DoesNotExist:
                    pass
            return HttpResponseRedirect('/advertiser/messages/campaigns/%d/' % c.id)
    else:
        form = EmailCampaignForm(initial={'date_send': datetime.date.today()}, org=request.organization)

    return AQ_render_to_response(request, 'advertiser/messages/campaign-add.html', {
            'form' : form,
            'group_id' : group_id,
        }, context_instance=RequestContext(request))