def timeline_vote_session(request, test_session, discussion): from assembl.models import DiscussionPhase, LangString phase = DiscussionPhase( discussion = discussion, identifier = 'voteSession', title = LangString.create(u"voteSession phase title fixture", "en"), description = LangString.create(u"voteSession phase description fixture", "en"), start = datetime(2014, 12, 31, 9, 0, 0), end = datetime(2015, 12, 31, 9, 0, 0), interface_v1 = False, image_url = u'https://example.net/image.jpg' ) # Create the phase test_session.add(phase) test_session.flush() def fin(): print "finalizer timeline" test_session.delete(phase) test_session.flush() request.addfinalizer(fin) return phase
def timeline_phase2_interface_v1(request, test_app, test_session, discussion, subidea_1, subidea_2): from assembl.models import DiscussionPhase, LangString phase1 = DiscussionPhase(identifier='survey', discussion=discussion, title=LangString.create('phase 1', 'en'), description=LangString.create( 'A first exploratory phase', 'en'), root_idea=subidea_1, start=datetime(2014, 12, 31, 9), end=datetime(2015, 12, 31, 9), interface_v1=True) test_session.add(phase1) phase2 = DiscussionPhase(identifier='thread', discussion=discussion, title=LangString.create('phase 2', 'en'), description=LangString.create( 'A second divergent phase', 'en'), root_idea=subidea_2, start=datetime(2015, 12, 31, 9, 1), end=datetime(2049, 12, 31, 9), previous_event=phase1, order=2.0, interface_v1=True) test_session.add(phase2) test_session.flush() def fin(): print "finalizer timeline" phase2.previous_event = None phase2.previous_event_id = None phase2.delete() phase1.delete() test_session.flush() request.addfinalizer(fin) return phase2
def phases(request, test_session, discussion): from assembl.models import DiscussionPhase, LangString from assembl import models survey = DiscussionPhase( discussion=discussion, identifier='survey', title=LangString.create(u"survey phase title fixture", "en"), description=LangString.create(u"survey phase description fixture", "en"), start=datetime(2018, 1, 15, 9, 0, 0), end=datetime(2018, 2, 15, 9, 0, 0), interface_v1=False, image_url=u'https://example.net/image.jpg', is_thematics_table=True) thread = DiscussionPhase( discussion=discussion, identifier='thread', title=LangString.create(u"thread phase title fixture", "en"), description=LangString.create(u"thread phase description fixture", "en"), start=datetime(2018, 2, 16, 9, 0, 0), end=datetime(2018, 3, 15, 9, 0, 0), interface_v1=False, image_url=u'https://example.net/image.jpg') multiColumns = DiscussionPhase( discussion=discussion, identifier='multiColumns', title=LangString.create(u"multiColumns phase title fixture", "en"), description=LangString.create( u"multiColumns phase description fixture", "en"), start=datetime(2018, 3, 16, 9, 0, 0), end=datetime(2018, 4, 15, 9, 0, 0), interface_v1=False, image_url=u'https://example.net/image.jpg') voteSession = DiscussionPhase( discussion=discussion, identifier='voteSession', title=LangString.create(u"voteSession phase title fixture", "en"), description=LangString.create(u"voteSession phase description fixture", "en"), start=datetime(2018, 4, 16, 9, 0, 0), end=datetime(2018, 5, 15, 9, 0, 0), interface_v1=False, image_url=u'https://example.net/image.jpg', is_thematics_table=True) brightMirror = DiscussionPhase( discussion=discussion, identifier='brightMirror', title=LangString.create(u"brightMirror phase title fixture", "en"), description=LangString.create( u"brightMirror phase description fixture", "en"), start=datetime(2018, 6, 16, 9, 0, 0), end=datetime(2018, 7, 15, 9, 0, 0), interface_v1=False, image_url=u'https://example.net/image.jpg', is_thematics_table=True) # Create the phase test_session.add(survey) test_session.add(thread) test_session.add(multiColumns) test_session.add(voteSession) test_session.add(brightMirror) test_session.flush() def fin(): print("finalizer timeline") test_session.delete(survey) test_session.delete(thread) test_session.delete(multiColumns) test_session.delete(voteSession) test_session.delete(brightMirror) test_session.flush() request.addfinalizer(fin) phases = test_session.query(models.DiscussionPhase).all() return {p.identifier: p for p in phases}