Exemplo n.º 1
0
 def from_dict(data):
     data = data.get("tag")
     if not is_ok(data):
         raise TypeError("Missing data: tag")
     if not is_ok(data.get("name")):
         raise TypeError("Missing data: tag.name")
     return Tag(name=data["name"])
Exemplo n.º 2
0
 def from_dict(data):
     data = data.get("tag")
     if not is_ok(data):
         raise TypeError("Missing data: tag")
     if not is_ok(data.get("name")):
         raise TypeError("Missing data: tag.name")
     return Tag(name=data["name"])
Exemplo n.º 3
0
 def update_from_dict(self, data):
     data = data["post"]
     if not is_ok(data):
         raise TypeError("Missing data: post")
     if is_ok(data.get("title")):
         self.title = data["title"]
     if is_ok(data.get("body")):
         self.body = data["body"]
Exemplo n.º 4
0
 def update_from_dict(self, data):
     data = data["post"]
     if not is_ok(data):
         raise TypeError("Missing data: post")
     if is_ok(data.get("title")):
         self.title = data["title"]
     if is_ok(data.get("body")):
         self.body = data["body"]
Exemplo n.º 5
0
 def from_dict(data):
     data = data["post"]
     if not is_ok(data):
         raise TypeError("Missing data: post")
     if not is_ok(data.get("title")):
         raise TypeError("Missing data: post.title")
     if not is_ok(data.get("body")):
         raise TypeError("Missing data: post.body")
     return Post(title=data["title"], body=data["body"])
Exemplo n.º 6
0
 def from_dict(data):
     data = data.get("topic")
     if not is_ok(data):
         raise TypeError("Missing data: topic")
     if not is_ok(data.get("name")):
         raise TypeError("Missing data: topic.name")
     return Topic(name=data["name"],
                  dates=data.get("dates"),
                  citations=data.get("citations"),
                  notes=data.get("notes"))
Exemplo n.º 7
0
    def from_dict(data, archive=None):
        data = data.get("archive")
        if not is_ok(data):
            raise TypeError("Missing data: archive")

        if not is_ok(data.get("name")):
            raise TypeError("Missing data: archive.name")
        if (Archive.query.filter_by(name=data["name"]).first()
                or len(data["name"]) >= 128):
            raise TypeError("Invalid data: archive.name")
        return Archive(name=data["name"], notes=data.get("notes", ""))
Exemplo n.º 8
0
 def from_dict(data):
     data = data.get("box")
     if not is_ok(data):
         raise TypeError("Missing data: box")
     if not is_ok(data.get("number")):
         raise TypeError("Missing data: box.number")
     if Box.query.filter_by(number=data["number"]).first():
         raise TypeError("Invalid data: box.number")
     return Box(number=data["number"],
                dates=data.get("dates"),
                notes=data.get("notes"))
Exemplo n.º 9
0
 def from_dict(data):
     data = data["post"]
     if not is_ok(data):
         raise TypeError("Missing data: post")
     if not is_ok(data.get("title")):
         raise TypeError("Missing data: post.title")
     if not is_ok(data.get("body")):
         raise TypeError("Missing data: post.body")
     return Post(
         title=data["title"], body=data["body"]
     )
Exemplo n.º 10
0
 def from_dict(data):
     data = data.get("topic")
     if not is_ok(data):
         raise TypeError("Missing data: topic")
     if not is_ok(data.get("name")):
         raise TypeError("Missing data: topic.name")
     return Topic(
         name=data["name"],
         dates=data.get("dates"),
         citations=data.get("citations"),
         notes=data.get("notes")
     )
Exemplo n.º 11
0
 def from_dict(data):
     data = data.get("document")
     if not is_ok(data):
         raise TypeError("Missing data: document")
     if not is_ok(data.get("title")):
         raise TypeError("Missing data: document.title")
     if (Document.query.filter_by(title=data["title"]).first()
             or len(data["title"]) >= 128):
         raise TypeError("Invalid data: document.title")
     return Document(title=data["title"],
                     dates=data.get("dates"),
                     citations=data.get("citations"),
                     notes=data.get("notes"))
Exemplo n.º 12
0
 def from_dict(data):
     data = data.get("person")
     if not is_ok(data):
         raise TypeError("Missing data: person")
     if not is_ok(data.get("name")):
         raise TypeError("Missing data: person.name")
     if (Person.query.filter_by(name=data["name"]).first()
             or len(data["name"]) >= 128):
         raise TypeError("Invalid data: person.name")
     return Person(name=data["name"],
                   dates=data.get("dates"),
                   citations=data.get("citations"),
                   notes=data.get("notes"))
Exemplo n.º 13
0
 def from_dict(data, archive=None):
     data = data.get("archive")
     if not is_ok(data):
         raise TypeError("Missing data: archive")
     
     if not is_ok(data.get("name")):
         raise TypeError("Missing data: archive.name")
     if (Archive.query.filter_by(name=data["name"]).first() or
        len(data["name"]) >= 128):
         raise TypeError("Invalid data: archive.name")
     return Archive(
         name=data["name"], notes=data.get("notes", "")
     )
Exemplo n.º 14
0
 def from_dict(data):
     data = data.get("document")
     if not is_ok(data):
         raise TypeError("Missing data: document")
     if not is_ok(data.get("title")):
         raise TypeError("Missing data: document.title")
     if (Document.query.filter_by(title=data["title"]).first() or
        len(data["title"]) >= 128):
         raise TypeError("Invalid data: document.title")
     return Document(
         title=data["title"],
         dates=data.get("dates"),
         citations=data.get("citations"),
         notes=data.get("notes")
     )
Exemplo n.º 15
0
 def from_dict(data):
     data = data.get("person")
     if not is_ok(data):
         raise TypeError("Missing data: person")
     if not is_ok(data.get("name")):
         raise TypeError("Missing data: person.name")
     if (Person.query.filter_by(name=data["name"]).first() or
        len(data["name"]) >= 128):
         raise TypeError("Invalid data: person.name")
     return Person(
         name=data["name"],
         dates=data.get("dates"),
         citations=data.get("citations"),
         notes=data.get("notes")
     )
Exemplo n.º 16
0
 def to_dict(self):
     rv = dict(tag=dict(id=self.id,
                        name=self.name,
                        posts=[dict(url=p.get_url()) for p in self.posts]))
     for key in list(rv["tag"]):
         if not is_ok(rv["tag"][key]):
             rv["tag"].pop(key, None)
     return rv
Exemplo n.º 17
0
 def to_dict(self):
     rv = dict(tag=dict(
         id=self.id, name=self.name,
         posts=[dict(url=p.get_url()) for p in self.posts]
     ))
     for key in list(rv["tag"]):
         if not is_ok(rv["tag"][key]):
             rv["tag"].pop(key, None)
     return rv
Exemplo n.º 18
0
 def to_dict(self):
     rv = dict(post=dict(id=self.id,
                         title=self.title,
                         body=self.body,
                         html=self.html,
                         timestamp=datetime.strftime(
                             self.timestamp, '%b %d %Y %I:%M%p'),
                         tags=[dict(url=t.get_url()) for t in self.tags]))
     for key in list(rv["post"]):
         if not is_ok(rv["post"][key]):
             rv["post"].pop(key, None)
     return rv
Exemplo n.º 19
0
 def to_dict(self):
     rv = dict(post=dict(
         id=self.id, title=self.title,
         body=self.body,
         html=self.html,
         timestamp=datetime.strftime(
             self.timestamp, '%b %d %Y %I:%M%p'),
         tags=[dict(url=t.get_url()) for t in self.tags]
     ))
     for key in list(rv["post"]):
         if not is_ok(rv["post"][key]):
             rv["post"].pop(key, None)
     return rv
Exemplo n.º 20
0
 def update_from_dict(self, data):
     data = data.get("tag")
     if not is_ok(data):
         raise TypeError("Missing data: tag")
     if is_ok(data.get("name")):
         self.name == data["name"]
Exemplo n.º 21
0
 def update_from_dict(self, data):
     data = data.get("tag")
     if not is_ok(data):
         raise TypeError("Missing data: tag")
     if is_ok(data.get("name")):
         self.name == data["name"]