-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from DigiKlausur/dev
Dev
- Loading branch information
Showing
38 changed files
with
694 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.1.1" | ||
__version__ = "0.2.0-dev1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .diagrameditor import DiagramEditor | ||
|
||
__all__ = ["DiagramEditor"] |
52 changes: 52 additions & 0 deletions
52
e2xgrader/server_extensions/apps/diagram_editor/diagrameditor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import json | ||
|
||
from e2xcore import BaseApp | ||
from e2xcore.handlers import E2xApiHandler | ||
from nbgrader.apps.baseapp import NbGrader | ||
from nbgrader.server_extensions.formgrader.base import check_xsrf | ||
from tornado import web | ||
from traitlets import List, Unicode | ||
|
||
|
||
class DiagramConfigHandler(E2xApiHandler): | ||
@web.authenticated | ||
@check_xsrf | ||
def get(self): | ||
self.finish(json.dumps(self.settings.get("diagram_config", dict()))) | ||
|
||
|
||
class DiagramEditor(NbGrader, BaseApp): | ||
drawDomain = Unicode( | ||
default_value=None, allow_none=True, help="The url to drawio" | ||
).tag(config=True) | ||
drawOrigin = Unicode( | ||
default_value=None, allow_none=True, help="The drawio origin" | ||
).tag(config=True) | ||
libraries = List(default_value=[], help="A list of activated libraries").tag( | ||
config=True | ||
) | ||
|
||
def __init__(self, **kwargs): | ||
NbGrader.__init__(self, **kwargs) | ||
BaseApp.__init__(self, **kwargs) | ||
|
||
def get_diagram_config(self): | ||
# self.log.info("My drawDomain is", self.drawDomain) | ||
config = dict() | ||
if self.drawDomain: | ||
config["drawDomain"] = self.drawDomain | ||
if self.drawOrigin: | ||
config["drawOrigin"] = self.drawOrigin | ||
if len(self.libraries) > 0: | ||
config["libs"] = self.libraries | ||
return config | ||
|
||
def load_app(self): | ||
self.log.info("Loading the diagrameditor app") | ||
self.initialize([]) | ||
self.update_tornado_settings(dict(diagram_config=self.get_diagram_config())) | ||
self.add_handlers( | ||
[ | ||
(r"/e2x/diagrams/api", DiagramConfigHandler), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
e2xgrader/tests/server_extensions/apps/diagram_editor/test_diagrameditor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import unittest | ||
|
||
from traitlets.config import LoggingConfigurable | ||
|
||
from e2xgrader.server_extensions.apps.diagram_editor import DiagramEditor | ||
|
||
|
||
class DummyWebApp: | ||
@property | ||
def settings(self): | ||
return dict() | ||
|
||
|
||
class DummyApp(LoggingConfigurable): | ||
root_dir = "dummy" | ||
name = "dummy" | ||
|
||
@property | ||
def web_app(self): | ||
return DummyWebApp() | ||
|
||
|
||
class TestDiagramEditor(unittest.TestCase): | ||
def setUp(self) -> None: | ||
self.editor = DiagramEditor(parent=DummyApp()) | ||
|
||
def test_empty_config(self): | ||
self.assertDictEqual(self.editor.get_diagram_config(), dict()) | ||
|
||
def test_configure_draw_domain(self): | ||
domain = "myDomain" | ||
self.editor.drawDomain = domain | ||
self.assertDictEqual(self.editor.get_diagram_config(), dict(drawDomain=domain)) | ||
|
||
def test_configure_draw_origin(self): | ||
domain = "myDomain" | ||
self.editor.drawOrigin = domain | ||
self.assertDictEqual(self.editor.get_diagram_config(), dict(drawOrigin=domain)) | ||
|
||
def test_configure_libraries(self): | ||
libraries = ["lib1", "lib2", "lib3"] | ||
self.editor.libraries = libraries | ||
self.assertDictEqual(self.editor.get_diagram_config(), dict(libs=libraries)) | ||
|
||
def tearDown(self) -> None: | ||
self.editor.drawDomain = None | ||
self.editor.drawOrigin = None | ||
self.editor.libraries = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.