def announcement_en_fr(request, discussion, en_locale, fr_locale, admin_user, idea_with_en_fr, test_session): from assembl.models import LangString, LangStringEntry, IdeaAnnouncement title = LangString.create(u'Announce title in English', 'en') title.add_entry(LangStringEntry( locale=fr_locale, value=u"Titre d'announce en français", locale_confirmed=True)) body = LangString.create(u'Announce body in English', 'en') body.add_entry(LangStringEntry( locale=fr_locale, value=u"Corps d'announce en français", locale_confirmed=True)) quote = LangString.create(u'A quote in English', 'en') quote.add_entry(LangStringEntry( locale=fr_locale, value=u"Une quote en français", locale_confirmed=True)) summary = LangString.create(u"Announce summary in English", 'en') summary.add_entry(LangStringEntry( locale=fr_locale, value=u"Announce retenir en Français", locale_confirmed=True)) announce = IdeaAnnouncement(creator=admin_user, last_updated_by=admin_user, title=title, body=body, discussion=discussion, idea=idea_with_en_fr, quote=quote, summary=summary) test_session.add(title) test_session.add(body) test_session.add(summary) test_session.add(announce) test_session.flush() def fin(): print("finalizer announcement_en_fr") test_session.delete(title) test_session.delete(body) test_session.delete(summary) test_session.delete(announce) test_session.flush() request.addfinalizer(fin) return announce
def idea_with_en_fr(request, discussion, en_locale, fr_locale, test_session): """A top idea with english and french""" from assembl.models import Idea, LangString, LangStringEntry title = LangString.create(u'Title in english', 'en') title.add_entry(LangStringEntry( locale=fr_locale, value=u'Titre en français', locale_confirmed=True)) synthesis_title = LangString.create(u'What you need to know', 'en') synthesis_title.add_entry(LangStringEntry( locale=fr_locale, value=u'A retnir', locale_confirmed=True)) description = LangString.create(u'Idea description', 'en') description.add_entry(LangStringEntry( locale=fr_locale, value=u'Un Description', locale_confirmed=True)) idea = Idea(title=title, discussion=discussion, description=description, synthesis_title=synthesis_title) test_session.add(title) test_session.add(synthesis_title) test_session.add(description) test_session.add(idea) test_session.flush() def fin(): print("finalizer idea_with_en_fr") test_session.delete(idea) test_session.delete(title) test_session.delete(synthesis_title) test_session.delete(description) test_session.flush() request.addfinalizer(fin) return idea
def create_proposal_en_fr_x(request, session, discussion, creator_id, idea_id, num): from assembl.models import ( PropositionPost, IdeaRelatedPostLink, Locale, LangString, LangStringEntry) en_locale = Locale.get_or_create('en') fr_locale = Locale.get_or_create('fr') mt_locale = Locale.create_mt_locale(en_locale, fr_locale, db=session) body = LangString.create(u"English Proposition %d" % num, 'en') body.add_entry(LangStringEntry( locale=mt_locale, value=u'French Proposition %d' % num, locale_confirmed=True)) post = PropositionPost( discussion=discussion, creator_id=creator_id, subject=None, body=body, body_mime_type=u'text/html', message_id="*****@*****.**" % num ) icl = IdeaRelatedPostLink( idea_id=idea_id, content=post, discussion=discussion, creator_id=creator_id ) session.add(post) session.add(icl) session.flush() def fin(): session.delete(icl) session.delete(post) session.delete(mt_locale) session.flush() request.addfinalizer(fin) return post