def post(self): data = request.json # check if one already exists that is active... if Campaign.active_campaign_exists(): raise APIException(message='Active campaign already exists. Cancel that campaign first in order to create a new one.') codeversion = services_manager.codeversion mode = services_manager.mode campaign = Campaign.launch_new_campaign(codeversion=codeversion, mode=mode, **data) return campaign, 201
def campaign(): from psiturk.models import Campaign parameters = { 'codeversion': '1.0', 'mode': 'sandbox', 'goal': 100, 'minutes_between_rounds': 1, 'assignments_per_round': 10, 'hit_reward': 1.00, 'hit_duration_hours': 1, } new_campaign = Campaign(**parameters) from psiturk.db import db_session db_session.add(new_campaign) db_session.commit() return new_campaign