From 07b4dfbe5010bde508bc59c83ce49f942c595de9 Mon Sep 17 00:00:00 2001 From: Julius de Jeu Date: Fri, 5 Jul 2019 00:57:57 +0200 Subject: [PATCH] Attempt to create a dockerfile, it failed. Add hashids and the ticket model. --- Dockerfile | 7 +++++++ Pipfile | 3 ++- Pipfile.lock | 23 +++++++++++++++-------- app/hashes.py | 3 +++ app/models.py | 21 +++++++++++++++++++-- 5 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 Dockerfile create mode 100644 app/hashes.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..de94961 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7 + +RUN pip3 install --no-cache-dir -U pip pipenv +COPY Pipfile* ./ +RUN pipenv install --deploy --system + +COPY ./app /app/app diff --git a/Pipfile b/Pipfile index d9ae1ae..e4c177e 100644 --- a/Pipfile +++ b/Pipfile @@ -6,7 +6,6 @@ verify_ssl = true [dev-packages] pylint = "*" autopep8 = "*" -aiosqlite = "*" [packages] fastapi = "*" @@ -17,6 +16,8 @@ python-multipart = "*" sqlalchemy = "*" ormantic = "*" email-validator = "*" +aiosqlite = "*" +hashids = "*" [requires] python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock index 3cdd876..4e766b4 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "befb733bd2acc52b8906144deaf77e6a9db8d01128b0ed49e488ed7c78ee1d03" + "sha256": "725c6ba90de086c23ed96685fb21bef42b8d18b4b0a00b138244edff3b23ddd6" }, "pipfile-spec": 6, "requires": { @@ -16,6 +16,13 @@ ] }, "default": { + "aiosqlite": { + "hashes": [ + "sha256:ad84fbd7516ca7065d799504fc41d6845c938e5306d1b7dd960caaeda12e22a9" + ], + "index": "pypi", + "version": "==0.10.0" + }, "bcrypt": { "hashes": [ "sha256:0258f143f3de96b7c14f762c770f5fc56ccd72f8a1857a451c1cd9a655d9ac89", @@ -112,6 +119,13 @@ ], "version": "==0.8.1" }, + "hashids": { + "hashes": [ + "sha256:6539b892a426e75747a9c0ad69409e9566f9c21b79310fc3424b5b6726f28da6" + ], + "index": "pypi", + "version": "==1.2.0" + }, "idna": { "hashes": [ "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", @@ -225,13 +239,6 @@ } }, "develop": { - "aiosqlite": { - "hashes": [ - "sha256:ad84fbd7516ca7065d799504fc41d6845c938e5306d1b7dd960caaeda12e22a9" - ], - "index": "pypi", - "version": "==0.10.0" - }, "astroid": { "hashes": [ "sha256:6560e1e1749f68c64a4b5dee4e091fce798d2f0d84ebe638cf0e0585a343acf4", diff --git a/app/hashes.py b/app/hashes.py new file mode 100644 index 0000000..0f1ff73 --- /dev/null +++ b/app/hashes.py @@ -0,0 +1,3 @@ +from hashids import Hashids +from os import environ +hids = Hashids(environ.get("HASH_KEY", "memes!"), 5) diff --git a/app/models.py b/app/models.py index a61c008..3da9b45 100644 --- a/app/models.py +++ b/app/models.py @@ -40,18 +40,35 @@ class TicketCollection(orm.Model): price: orm.Integer() = 0 description: orm.String(max_length=1000) = "" requires_student: orm.Boolean() = False + id: orm.Integer(primary_key=True) = None class TicketCollectionDB(TicketCollection): user: orm.ForeignKey(UserInDB) - id: orm.Integer(primary_key=True) = None - class Mapping: table_name = "TicketCollection" metadata = metadata database = database + +class Ticket(orm.Model): + id: orm.Integer(primary_key=True) = None + owner: orm.String(max_length=100) + email: orm.String(max_length=100, allow_null=True) = None + validated: orm.Boolean() = False + + + +class TicketDB(Ticket): + collection: orm.ForeignKey(TicketCollectionDB) + + class Mapping: + table_name = "Tickets" + metadata = metadata + database = database + + class NewCollection(BaseModel): name: str price: float