def create_campaign(): import uuid from flask import url_for, redirect from campaign_manager.forms.campaign import CampaignForm from campaign_manager.models.campaign import Campaign """Get campaign details. """ form = CampaignForm(request.form) if form.validate_on_submit(): data = form.data data.pop('csrf_token') data.pop('submit') data['uuid'] = uuid.uuid4().hex Campaign.create(data, form.uploader.data) return redirect( url_for( 'campaign_manager.get_campaign', uuid=data['uuid']) ) context = dict( oauth_consumer_key=OAUTH_CONSUMER_KEY, oauth_secret=OAUTH_SECRET ) context['action'] = '/campaign_manager/create' context['campaigns'] = Campaign.all() context['categories'] = AbstractInsightsFunction.CATEGORIES context['functions'] = get_selected_functions() context['title'] = 'Create Campaign' return render_template( 'create_campaign.html', form=form, **context)
def create_campaign(): import uuid from flask import url_for, redirect from campaign_manager.forms.campaign import CampaignForm """Get campaign details. """ form = CampaignForm(request.form) if form.validate_on_submit(): data = form.data data.pop('csrf_token') data.pop('submit') data.pop('types_options') data['uuid'] = uuid.uuid4().hex Campaign.create(data, form.uploader.data) Campaign.compute(data["uuid"]) campaign = Campaign(data['uuid']) campaign.save() campaign.save_to_user_campaigns(data['user_id'], data['uuid'], Permission.ADMIN.name) return redirect( url_for('campaign_manager.get_campaign', uuid=data['uuid'])) context = dict(oauth_consumer_key=OAUTH_CONSUMER_KEY, oauth_secret=OAUTH_SECRET, map_provider=map_provider()) context['url'] = '/create' context['action'] = 'create' context['functions'] = get_selected_functions() context['title'] = 'Create Campaign' context['maximum_area_size'] = MAX_AREA_SIZE context['uuid'] = uuid.uuid4().hex context['types'] = {} context['link_to_omk'] = False context['feature_templates'] = get_types() try: context['types'] = json.dumps(get_types()).replace( 'True', 'true').replace('False', 'false') except ValueError: pass return render_template('create_campaign.html', form=form, **context)