Attempt to create a dockerfile, it failed. Add hashids and the ticket model.
This commit is contained in:
parent
3cd3faaf43
commit
07b4dfbe50
7
Dockerfile
Normal file
7
Dockerfile
Normal file
|
@ -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
|
3
Pipfile
3
Pipfile
|
@ -6,7 +6,6 @@ verify_ssl = true
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
pylint = "*"
|
pylint = "*"
|
||||||
autopep8 = "*"
|
autopep8 = "*"
|
||||||
aiosqlite = "*"
|
|
||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
fastapi = "*"
|
fastapi = "*"
|
||||||
|
@ -17,6 +16,8 @@ python-multipart = "*"
|
||||||
sqlalchemy = "*"
|
sqlalchemy = "*"
|
||||||
ormantic = "*"
|
ormantic = "*"
|
||||||
email-validator = "*"
|
email-validator = "*"
|
||||||
|
aiosqlite = "*"
|
||||||
|
hashids = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.7"
|
python_version = "3.7"
|
||||||
|
|
23
Pipfile.lock
generated
23
Pipfile.lock
generated
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "befb733bd2acc52b8906144deaf77e6a9db8d01128b0ed49e488ed7c78ee1d03"
|
"sha256": "725c6ba90de086c23ed96685fb21bef42b8d18b4b0a00b138244edff3b23ddd6"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -16,6 +16,13 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"default": {
|
"default": {
|
||||||
|
"aiosqlite": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:ad84fbd7516ca7065d799504fc41d6845c938e5306d1b7dd960caaeda12e22a9"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==0.10.0"
|
||||||
|
},
|
||||||
"bcrypt": {
|
"bcrypt": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:0258f143f3de96b7c14f762c770f5fc56ccd72f8a1857a451c1cd9a655d9ac89",
|
"sha256:0258f143f3de96b7c14f762c770f5fc56ccd72f8a1857a451c1cd9a655d9ac89",
|
||||||
|
@ -112,6 +119,13 @@
|
||||||
],
|
],
|
||||||
"version": "==0.8.1"
|
"version": "==0.8.1"
|
||||||
},
|
},
|
||||||
|
"hashids": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:6539b892a426e75747a9c0ad69409e9566f9c21b79310fc3424b5b6726f28da6"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==1.2.0"
|
||||||
|
},
|
||||||
"idna": {
|
"idna": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407",
|
"sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407",
|
||||||
|
@ -225,13 +239,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"develop": {
|
"develop": {
|
||||||
"aiosqlite": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:ad84fbd7516ca7065d799504fc41d6845c938e5306d1b7dd960caaeda12e22a9"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==0.10.0"
|
|
||||||
},
|
|
||||||
"astroid": {
|
"astroid": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:6560e1e1749f68c64a4b5dee4e091fce798d2f0d84ebe638cf0e0585a343acf4",
|
"sha256:6560e1e1749f68c64a4b5dee4e091fce798d2f0d84ebe638cf0e0585a343acf4",
|
||||||
|
|
3
app/hashes.py
Normal file
3
app/hashes.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from hashids import Hashids
|
||||||
|
from os import environ
|
||||||
|
hids = Hashids(environ.get("HASH_KEY", "memes!"), 5)
|
|
@ -40,18 +40,35 @@ class TicketCollection(orm.Model):
|
||||||
price: orm.Integer() = 0
|
price: orm.Integer() = 0
|
||||||
description: orm.String(max_length=1000) = ""
|
description: orm.String(max_length=1000) = ""
|
||||||
requires_student: orm.Boolean() = False
|
requires_student: orm.Boolean() = False
|
||||||
|
id: orm.Integer(primary_key=True) = None
|
||||||
|
|
||||||
|
|
||||||
class TicketCollectionDB(TicketCollection):
|
class TicketCollectionDB(TicketCollection):
|
||||||
user: orm.ForeignKey(UserInDB)
|
user: orm.ForeignKey(UserInDB)
|
||||||
|
|
||||||
id: orm.Integer(primary_key=True) = None
|
|
||||||
|
|
||||||
class Mapping:
|
class Mapping:
|
||||||
table_name = "TicketCollection"
|
table_name = "TicketCollection"
|
||||||
metadata = metadata
|
metadata = metadata
|
||||||
database = database
|
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):
|
class NewCollection(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
price: float
|
price: float
|
||||||
|
|
Loading…
Reference in a new issue