def create(cls, instance, title, text, creator, function=NORM, tags=None, wiki=False, formatting=False, sectionpage=False, allow_comment=True, allow_selection=True, always_show_original=True, abstract=None): from adhocracy.lib.text import title2alias from text import Text from tagging import Tagging if function not in Page.FUNCTIONS: raise AttributeError("Invalid page function type") label = title2alias(title) page = Page(instance, label, creator, function, formatting, sectionpage, allow_comment, allow_selection, always_show_original, abstract) meta.Session.add(page) meta.Session.flush() Text(page, Text.HEAD, creator, title, text, wiki) if tags is not None: page.taggings = Tagging.create_all(page, tags, creator) return page
def create(cls, instance, label, user, with_vote=False, tags=None): from poll import Poll from tagging import Tagging proposal = Proposal(instance, label, user) meta.Session.add(proposal) meta.Session.flush() poll = Poll.create(proposal, user, Poll.RATE, with_vote=with_vote) proposal.rate_poll = poll if tags is not None: proposal.taggings = Tagging.create_all(proposal, tags, user) meta.Session.flush() return proposal
def create(cls, instance, title, text, creator, function=NORM, tags=None, wiki=False): from adhocracy.lib.text import title2alias from text import Text from tagging import Tagging if function not in Page.FUNCTIONS: raise AttributeError("Invalid page function type") label = title2alias(title) page = Page(instance, label, creator, function) meta.Session.add(page) meta.Session.flush() Text(page, Text.HEAD, creator, title, text, wiki) if tags is not None: page.taggings = Tagging.create_all(page, tags, creator) return page