Exemplo n.º 1
0
    def testFindAllBySubscription(self):
        objs = Conversation.findAllBySubscription(1)
        self.assertTrue(is_array(objs))
        self.assertTrue(len(objs) > 0)

        for obj in objs:
            self.assertTrue(isinstance(obj, Conversation))
Exemplo n.º 2
0
def show_conversations():
    form = UserActivityForm(request)
    if not form.validate():
        return json({'message': 'Validation Failed', 'errors': form.errors}, 422)

    user_id = app.auth.user.id
    total = Conversation.countAllBySubscription(user_id, form.after)
    pg = paginate(form, total)

    if total > 0:
        if pg.page_valid:
            data = Conversation.findAllBySubscription(user_id, pg.offset, pg.per_page, form.after)
        else:
            return json({'message': "This is the end of the list"}, 404)
    else:
        data = []

    return json(dict(conversations=data, **pg.info))
Exemplo n.º 3
0
def show_conversations():
    form = UserActivityForm(request)
    if not form.validate():
        return json({
            'message': 'Validation Failed',
            'errors': form.errors
        }, 422)

    user_id = app.auth.user.id
    total = Conversation.countAllBySubscription(user_id, form.after)
    pg = paginate(form, total)

    if total > 0:
        if pg.page_valid:
            data = Conversation.findAllBySubscription(user_id, pg.offset,
                                                      pg.per_page, form.after)
        else:
            return json({'message': "This is the end of the list"}, 404)
    else:
        data = []

    return json(dict(conversations=data, **pg.info))