From 8eb20525e8bf9142407d6b5790d6dc19beb73af2 Mon Sep 17 00:00:00 2001 From: Karim Date: Sun, 25 Nov 2018 13:25:29 +0000 Subject: [PATCH] Update schema to allow for drawing grid size to be part of project. --- gns3server/controller/project.py | 20 +++++++++++++++++++- gns3server/controller/topology.py | 1 + gns3server/schemas/project.py | 18 +++++++++++++++--- gns3server/schemas/topology.py | 6 +++++- tests/controller/test_project.py | 3 ++- tests/controller/test_topology.py | 3 ++- 6 files changed, 44 insertions(+), 7 deletions(-) diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index f7561af1..685f43a5 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -69,7 +69,7 @@ class Project: def __init__(self, name=None, project_id=None, path=None, controller=None, status="opened", filename=None, auto_start=False, auto_open=False, auto_close=True, scene_height=1000, scene_width=2000, zoom=100, show_layers=False, snap_to_grid=False, show_grid=False, - grid_size=0, show_interface_labels=False, variables=None, supplier=None): + grid_size=75, drawing_grid_size=25, show_interface_labels=False, variables=None, supplier=None): self._controller = controller assert name is not None @@ -85,6 +85,7 @@ class Project: self._snap_to_grid = snap_to_grid self._show_grid = show_grid self._grid_size = grid_size + self._drawing_grid_size = drawing_grid_size self._show_interface_labels = show_interface_labels self._variables = variables self._supplier = supplier @@ -263,6 +264,21 @@ class Project: """ self._grid_size = grid_size + @property + def drawing_grid_size(self): + """ + Grid size + :return: integer + """ + return self._drawing_grid_size + + @drawing_grid_size.setter + def drawing_grid_size(self, grid_size): + """ + Setter for grid size + """ + self._drawing_grid_size = grid_size + @property def show_interface_labels(self): """ @@ -837,6 +853,7 @@ class Project: "snap_to_grid", "show_grid", "grid_size", + "drawing_grid_size", "show_interface_labels" ] @@ -1084,6 +1101,7 @@ class Project: "snap_to_grid": self._snap_to_grid, "show_grid": self._show_grid, "grid_size": self._grid_size, + "drawing_grid_size": self._drawing_grid_size, "show_interface_labels": self._show_interface_labels, "supplier": self._supplier, "variables": self._variables diff --git a/gns3server/controller/topology.py b/gns3server/controller/topology.py index 686f9336..a8502cd0 100644 --- a/gns3server/controller/topology.py +++ b/gns3server/controller/topology.py @@ -84,6 +84,7 @@ def project_to_topology(project): "snap_to_grid": project.snap_to_grid, "show_grid": project.show_grid, "grid_size": project.grid_size, + "drawing_grid_size": project.drawing_grid_size, "show_interface_labels": project.show_interface_labels, "variables": project.variables, "supplier": project.supplier, diff --git a/gns3server/schemas/project.py b/gns3server/schemas/project.py index c232f8ce..7ac1a4a8 100644 --- a/gns3server/schemas/project.py +++ b/gns3server/schemas/project.py @@ -102,7 +102,11 @@ PROJECT_CREATE_SCHEMA = { }, "grid_size": { "type": "integer", - "description": "Grid size for the drawing area" + "description": "Grid size for the drawing area for appliances" + }, + "drawing_grid_size": { + "type": "integer", + "description": "Grid size for the drawing area for labels" }, "show_interface_labels": { "type": "boolean", @@ -167,7 +171,11 @@ PROJECT_UPDATE_SCHEMA = { }, "grid_size": { "type": "integer", - "description": "Grid size for the drawing area" + "description": "Grid size for the drawing area for appliances" + }, + "drawing_grid_size": { + "type": "integer", + "description": "Grid size for the drawing area for labels" }, "show_interface_labels": { "type": "boolean", @@ -248,7 +256,11 @@ PROJECT_OBJECT_SCHEMA = { }, "grid_size": { "type": "integer", - "description": "Grid size for the drawing area" + "description": "Grid size for the drawing area for appliances" + }, + "drawing_grid_size": { + "type": "integer", + "description": "Grid size for the drawing area for labels" }, "show_interface_labels": { "type": "boolean", diff --git a/gns3server/schemas/topology.py b/gns3server/schemas/topology.py index 7b319253..5f313f5c 100644 --- a/gns3server/schemas/topology.py +++ b/gns3server/schemas/topology.py @@ -93,7 +93,11 @@ TOPOLOGY_SCHEMA = { }, "grid_size": { "type": "integer", - "description": "Grid size for the drawing area" + "description": "Grid size for the drawing area for appliances" + }, + "drawing_grid_size": { + "type": "integer", + "description": "Grid size for the drawing area for labels" }, "show_interface_labels": { "type": "boolean", diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py index 49678f4f..9e7d7d2d 100644 --- a/tests/controller/test_project.py +++ b/tests/controller/test_project.py @@ -77,7 +77,8 @@ def test_json(tmpdir): "show_interface_labels": False, "show_layers": False, "snap_to_grid": False, - "grid_size": 0, + "grid_size": 75, + "drawing_grid_size": 25, "supplier": None, "variables": None } diff --git a/tests/controller/test_topology.py b/tests/controller/test_topology.py index 81eb0a0f..f9668946 100644 --- a/tests/controller/test_topology.py +++ b/tests/controller/test_topology.py @@ -45,7 +45,8 @@ def test_project_to_topology_empty(tmpdir): "show_interface_labels": False, "show_layers": False, "snap_to_grid": False, - "grid_size": 0, + "grid_size": 75, + "drawing_grid_size": 25, "topology": { "nodes": [], "links": [],