Skip to content

Commit

Permalink
Sort snapshots by dates
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-duponchelle committed Jul 26, 2016
1 parent e3d9c3b commit 2d6e7c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gns3server/controller/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def name(self):
def path(self):
return self._path

@property
def created_at(self):
return int(self._created_at)

def __json__(self):

return {
Expand Down
3 changes: 2 additions & 1 deletion gns3server/handlers/api/controller/snapshot_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def create(request, response):
def list(request, response):
controller = Controller.instance()
project = controller.get_project(request.match_info["project_id"])
response.json([s for s in project.snapshots.values()])
snapshots = [s for s in project.snapshots.values()]
response.json(sorted(snapshots, key=lambda s:s.created_at))

@Route.delete(
r"/projects/{project_id}/snapshots/{snapshot_id}",
Expand Down

0 comments on commit 2d6e7c4

Please sign in to comment.