def render_campaign_creation_message(request, campaign, content): client = campaign.client hostname = client.hostname initial_url = "{scheme}//{host}{path}".format( scheme=settings.INCOMING_REQUEST_SCHEME, host=hostname, path=sharingurls.initial_url(hostname, campaign, content), ) return CAMPAIGN_CREATION_NOTIFICATION_MESSAGE.format( username=request.user.username, campaign=campaign, client=client, summary_url=request.build_absolute_uri( reverse('targetadmin:campaign-summary', args=[campaign.client.pk, campaign.pk]) ), snippets_url=request.build_absolute_uri( "{}?campaign_pk={}&content_pk={}".format( reverse('targetadmin:snippets', args=[campaign.client.pk]), campaign.pk, content.pk, ) ), campaign_url=initial_url, )
def campaign_summary(request, client_pk, campaign_pk, wizard=False): client = get_object_or_404(relational.Client, pk=client_pk) root_campaign = get_object_or_404(client.campaigns.root(), pk=campaign_pk) campaign_properties = root_campaign.campaignproperties.get() content = campaign_properties.client_content filters = [] for campaign in root_campaign.iterchain(): filters.append([ list(choice_set_filter.filter.filterfeatures.values( 'feature', 'operator', 'value', 'feature_type__code', ).iterator()) for choice_set_filter in campaign.choice_set().choicesetfilters.all() ]) fb_obj_attributes = root_campaign.fb_object().fbobjectattribute_set.values( 'msg1_post', 'msg1_pre', 'msg2_post', 'msg2_pre', 'og_description', 'og_image', 'og_title', 'og_type', 'org_name', 'sharing_prompt', 'sharing_sub_header', ).get() (serialized_properties,) = serialize('python', (campaign_properties,), fields=( 'client_faces_url', 'client_thanks_url', 'client_error_url', 'status', )) summary_data = { 'campaign_id': root_campaign.pk, 'create_dt': root_campaign.create_dt.isoformat(), 'client': client, 'content_url': content.url, 'campaign_name': re.sub(r' 1$', '', root_campaign.name), 'root_campaign': root_campaign, 'campaign_properties': json.dumps(serialized_properties['fields']), 'fb_obj_attributes': json.dumps(fb_obj_attributes), 'filters': json.dumps(filters), } if campaign_properties.status < campaign_properties.Status.INACTIVE: incoming_host = client.hostname summary_data['sharing_url'] = '{}//{}{}'.format( settings.INCOMING_REQUEST_SCHEME, incoming_host, sharingurls.initial_url(incoming_host, root_campaign, content), ) if wizard: summary_data['message'] = CAMPAIGN_CREATION_THANK_YOU_MESSAGE return render(request, 'targetadmin/campaign_summary_page.html', summary_data)