summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-api/opendc/database.py
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-02 14:26:23 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-02 18:07:42 +0200
commit45b73e4683cce35de79117c5b4a6919556d9644f (patch)
treefdbb282b639d03e0cc940c8587d5fe90c2283aa5 /opendc-web/opendc-web-api/opendc/database.py
parente2ec16a1a40f3ffc437378b4e22fda64f86fe284 (diff)
api: Add stricter validation of input/output data
This change adds stricter validation of data that enters and leaves the database. As a result, we clearly separate the database model from the data model that the REST API exports.
Diffstat (limited to 'opendc-web/opendc-web-api/opendc/database.py')
-rw-r--r--opendc-web/opendc-web-api/opendc/database.py11
1 files changed, 0 insertions, 11 deletions
diff --git a/opendc-web/opendc-web-api/opendc/database.py b/opendc-web/opendc-web-api/opendc/database.py
index f9a33b66..37fd1a4d 100644
--- a/opendc-web/opendc-web-api/opendc/database.py
+++ b/opendc-web/opendc-web-api/opendc/database.py
@@ -19,7 +19,6 @@
# SOFTWARE.
import urllib.parse
-from datetime import datetime
from pymongo import MongoClient
@@ -90,13 +89,3 @@ class Database:
The query needs to be in json format, i.e.: `{'name': prefab_name}`.
"""
getattr(self.opendc_db, collection).delete_many(query)
-
- @staticmethod
- def datetime_to_string(datetime_to_convert):
- """Return a database-compatible string representation of the given datetime object."""
- return datetime_to_convert.strftime(DATETIME_STRING_FORMAT)
-
- @staticmethod
- def string_to_datetime(string_to_convert):
- """Return a datetime corresponding to the given string representation."""
- return datetime.strptime(string_to_convert, DATETIME_STRING_FORMAT)