Example #1
0
def newNotebook(notebook):

    existing_notebook = Notebook.query.filter(
        Notebook.name == notebook.get("name")).one_or_none()

    if existing_notebook is None:

        newNotebook = Notebook(id=notebook.get("id"),
                               name=notebook.get("name"),
                               status="pending")

        db.session.add(newNotebook)
        db.session.commit()

        request_rpc = RpcClient()
        print(" [x] Requesting creating notebook")

        message = {
            'id': newNotebook.id,
            'name': newNotebook.name,
            'type': 'Notebook',
            'action': 'Create',
        }

        response = request_rpc.call(message)
        print(" [.] Successfully")

        return jsonify(newNotebook.serialize()), 201

    else:
        abort(409, "Notebook name exists already")
Example #2
0
    def __init__(self, parent):
        super().__init__(parent,
                         agwStyle=customtreectrl.TR_HAS_BUTTONS
                         | customtreectrl.TR_FULL_ROW_HIGHLIGHT
                         | customtreectrl.TR_ELLIPSIZE_LONG_ITEMS
                         | customtreectrl.TR_TOOLTIP_ON_LONG_ITEMS)

        self.root = self.AddRoot("所有笔记", data=Notebook())
        self._load_notebooks(self.root, None)
        self._init_ui()
        self._init_popup_menu()
        self._init_event()
        wx.CallAfter(self.DoSelectItem, self.GetRootItem().GetChildren()[0])
Example #3
0
    def create(user, name, color):
        """ Create a new notebook """

        if len(name) > 24:
            raise UnprocessableEntity(description="NOTEBOOK_NAME_MAX_LENGTH")

        current_time = int(time.time())
        notebook = Notebook(name=name,
                            color=color,
                            user=user.id,
                            created_at=current_time,
                            updated_at=current_time)

        notebook.save()

        return notebook.transform()
Example #4
0
from models import Notebook, TextNote, VideoNote

bio = Notebook("Bio 201 Notes")

bio.notes.append(TextNote("This is the first day of Bio 201"))
bio.notes.append(TextNote("Final exam is 95%."))
bio.notes.append(VideoNote("https://www.youtube.com/watch?v=PKffm2uI4dk"))

bio.display()
bio.save("bio201.txt")
bio.load("bio201.txt")

print(bio.to_json())
Example #5
0
import os
from config import db
from models import Notebook, Training, Endpoint

NOTEBOOKS = [{"notebook_name": "FirstNotebook", "notebook_id": "12345"}]

TRAININGS = [{"training_name": "FirstTraining", "training_id": "12345"}]

ENDPOINTS = [{"endpoint_name": "FirstEndpoint", "endpoint_id": "12345"}]

if os.path.exists("mimir.db"):
    os.remove("mimir.db")

db.create_all()

for notebook in NOTEBOOKS:
    n = Notebook(notebook_id=notebook.get("notebook_id"),
                 notebook_name=notebook.get("notebook_name"))
    db.session.add(n)

for training in TRAININGS:
    t = Training(training_id=training.get("training_id"),
                 training_name=training.get("training_name"))
    db.session.add(t)

for endpoint in ENDPOINTS:
    e = Endpoint(endpoint_id=endpoint.get("endpoint_id"),
                 endpoint_name=endpoint.get("endpoint_name"))
    db.session.add(e)

db.session.commit()
Example #6
0
import config
from models import Notebook, Training, Endpoint
from datetime import datetime

NOTEBOOKS = []

TRAININGS = []

ENDPOINTS = []

config.createDB()

db.create_all()

for notebook in NOTEBOOKS:
    n = Notebook(id=notebook.get("id"), name=notebook.get("name"))
    db.session.add(n)

for training in TRAININGS:
    t = Training(id=training.get("training_id"), name=training.get("name"))
    for endpoint in training.get("endpoints"):
        endpoint_id, endpoint_name, createdDate = endpoint
        n.endpoints.append(
            Ednpoint(id=endpoint_id,
                     name=endpoint_name,
                     created_date=datetime.strptime(created_date,
                                                    "%Y-%m-%d %H:%M:%S")))
    db.session.add(t)

for endpoint in ENDPOINTS:
    e = Endpoint(id=endpoint.get("id"), name=endpoint.get("name"))