def social_doctypes(dbsession): from autonomie.models.user.userdatas import SocialDocTypeOption options = [] for i in "Rib", "Permis": option = SocialDocTypeOption(label=i) dbsession.add(option) dbsession.flush() options.append(option) return options
def ensure_doctypes_rel(userdatas_id, request): """ Ensure there is a UserDatasSocialDocTypes instance attaching each social doc type with the userdatas :param int userdatas_id: The id of the userdatas instance :param obj request: The request object """ for doctype in SocialDocTypeOption.query(): doctype_id = doctype.id rel = UserDatasSocialDocTypes.get((userdatas_id, doctype_id,)) if rel is None: rel = UserDatasSocialDocTypes( userdatas_id=userdatas_id, doctype_id=doctype_id, ) request.dbsession.add(rel) request.dbsession.flush()
def ensure_doctypes_rel(userdatas_id, request): """ Ensure there is a UserDatasSocialDocTypes instance attaching each social doc type with the userdatas :param int userdatas_id: The id of the userdatas instance :param obj request: The request object """ for doctype in SocialDocTypeOption.query(): doctype_id = doctype.id rel = UserDatasSocialDocTypes.get(( userdatas_id, doctype_id, )) if rel is None: rel = UserDatasSocialDocTypes( userdatas_id=userdatas_id, doctype_id=doctype_id, ) request.dbsession.add(rel) request.dbsession.flush()