示例#1
0
def create_example_data():
    if not Cell.select():
        user = User(name='Example User', login_name='user', password='******')
        batman = User(name='Batman', login_name='batman', password='******')
        user.save()
        batman.save()

        board1 = Board(name='First')
        board2 = Board(name='Second')
        board3 = Board(name='Third')
        batman1 = Board(name='Batmobil')
        batman2 = Board(name='BatBarlang')
        batman3 = Board(name='BatRobin')

        board1.save()
        board2.save()
        board3.save()
        batman1.save()
        batman2.save()
        batman3.save()

        Boardstable.create(board=board1, user=user)
        Boardstable.create(board=board2, user=user)
        Boardstable.create(board=board3, user=user)

        Boardstable.create(board=batman1, user=batman)
        Boardstable.create(board=batman2, user=batman)
        Boardstable.create(board=batman3, user=batman)

        Cell.create(text="Rocket",
                    name="Weapon",
                    order=1,
                    board=board1,
                    status=Status.get(Status.status == "new"))
        Cell.create(text="Pistol",
                    name="Weapon",
                    order=2,
                    board=board1,
                    status=Status.get(Status.status == "new"))
        Cell.create(text="Sword",
                    name="Weapon",
                    order=3,
                    board=board1,
                    status=Status.get(Status.status == "new"))
        Cell.create(text="Kalasnyikov",
                    name="Weapon",
                    order=1,
                    board=board1,
                    status=Status.get(Status.status == "progress"))
        Cell.create(text="Grenade",
                    name="Weapon",
                    order=1,
                    board=board1,
                    status=Status.get(Status.status == "done"))
示例#2
0
    def get(self, username):
        user = User.get_or_none(username=username)
        pagination = ap_pagination(self)
        if user:
            user = user.profile.get()

            # Retrive statuses
            objects = []
            for k in TimelineManager(user).query():
                try:
                    objects.append(
                        Status.get(
                            Status.identifier == status).to_activitystream())
                except:
                    pass

            print(objects)
            # create collection page
            collectionPage = activities.OrderedCollectionPage(
                map(activities.Note, objects), **pagination)

            # create collection
            collection = activities.OrderedCollection([collectionPage])
            self.write(json.dumps(collectionPage.to_json(context=True)))
            self.set_status(200)
def rearrange_different_statused_cells(newid, oldid, oldstatus, newstatus,
                                       id_in_db):
    moved_cell = Cell.get(Cell.id == id_in_db)
    # newStatused rearrange
    cells = Cell.select().where((Cell.status == Status.get(
        Status.status == newstatus)) & (Cell.board == moved_cell.board)
                                & (Cell.order >= newid))
    for cell in cells:
        cell.order += 1
        cell.save()
    # oldStatus rearrange
    cells = Cell.select().where((Cell.status == Status.get(
        Status.status == oldstatus)) & (Cell.board == moved_cell.board)
                                & (Cell.order > oldid))
    for cell in cells:
        cell.order -= 1
        cell.save()

    moved_cell.order = newid
    moved_cell.status = Status.get(Status.status == newstatus)
    moved_cell.save()
示例#4
0
    def on_get(self, req, resp):
        username = req.context['user'].username
        r = redis.StrictRedis(host='localhost', port=6379)

        local = req.get_param('local') or False
        max_id = req.get_param('max_id') or None
        since_id = req.get_param('since_id') or None
        limit = req.get_param('limit') or 40
        statuses = []
        for post in r.zrange('{}:hometimeline'.format(username),
                             0,
                             min(limit - 1, 40),
                             withscores=False):
            statuses.append(Status.get(id=post).to_json())

        print(statuses)
        resp.body = json.dumps(statuses, default=str)
        resp.status = falcon.HTTP_200
示例#5
0
    def on_get(self, req, resp):
        user = req.context['user']
        r = redis.StrictRedis(host=os.environ.get('REDIS_HOST', 'localhost'))

        local = req.get_param('local') or False
        max_id = req.get_param('max_id') or None
        since_id = req.get_param('since_id') or None
        limit = req.get_param('limit') or 20
        statuses = []
        errors = 0
        for post in TimelineManager(user).query(since_id=since_id,
                                                max_id=max_id,
                                                local=True,
                                                limit=limit):
            try:
                statuses.append(Status.get(id=int(post)).to_json())
            except:
                errors += 1

        resp.body = json.dumps(statuses, default=str)
        resp.status = falcon.HTTP_200
示例#6
0
	def getById(id):
		k = db.Key.from_path('Status', int(id))
		return Status.get(k)
示例#7
0
async def delete_status(req, status_id):
    status = Status.get(id=status_id)
    status.delete()
    return json({})
示例#8
0
async def update_status(req):
    status = Status.get(id=req.json.get("id"))
    status.title = req.json.get("title")
    status.text = req.json.get("text")
    status.save()
    return json({})