def fixture_add_collection(name=u"My first Collection", user=None, collection_type=Collection.USER_DEFINED_TYPE): if user is None: user = fixture_add_user() coll = Collection.query.filter_by( actor=user.id, title=name, type=collection_type ).first() if coll is not None: return coll coll = Collection() coll.actor = user.id coll.title = name coll.type = collection_type coll.generate_slug() coll.save() # Reload Session.refresh(coll) # ... and detach from session: Session.expunge(coll) return coll
def fixture_add_collection(name=u"My first Collection", user=None): if user is None: user = fixture_add_user() coll = Collection.query.filter_by(creator=user.id, title=name).first() if coll is not None: return coll coll = Collection() coll.creator = user.id coll.title = name coll.generate_slug() coll.save() # Reload Session.refresh(coll) # ... and detach from session: Session.expunge(coll) return coll
def fixture_add_collection(name="My first Collection", user=None, collection_type=Collection.USER_DEFINED_TYPE): if user is None: user = fixture_add_user() coll = Collection.query.filter_by(actor=user.id, title=name, type=collection_type).first() if coll is not None: return coll coll = Collection() coll.actor = user.id coll.title = name coll.type = collection_type coll.generate_slug() coll.save() # Reload Session.refresh(coll) # ... and detach from session: Session.expunge(coll) return coll