Beispiel #1
0
def deleteArticle(object_id):
    HttpHelper.setJsonContentType()

    call = MongoProvider.CategoryCall()
    ret = call.delete(object_id)

    return dumps(True)
Beispiel #2
0
def getCategories():
    HttpHelper.setJsonContentType()

    call = MongoProvider.CategoryCall()

    mongoCategories = list(call.get())

    categories = list(
        map(lambda x: Category.Category.getInstance(x), mongoCategories))

    dicts = map(lambda x: dict(x), categories)

    return dumps(dicts)
Beispiel #3
0
def createCategory():
    HttpHelper.setJsonContentType()

    user = HttpHelper.getSessionKey("logged_user")

    if (user is None):
        return dumps(
            dict(Validation.Validation(False, "You are not logged in")))

    category_dict = HttpHelper.postBodyToDict()
    category = Category.Category.getInstance(category_dict)

    validation = category.validate()
    if (validation.success == True):
        category.mongoSerialization()

        call = MongoProvider.CategoryCall()
        ret = call.insert(dict(category))
        validation.id = str(ret.inserted_id)

    return dumps(dict(validation))