Updates, conserve filename

This commit is contained in:
datalets 2022-09-15 22:17:27 +02:00
parent 81ee0cc40c
commit 98008c1917
3 changed files with 38 additions and 62 deletions

View File

@ -17,7 +17,7 @@ from ..decorators import admin_required
from ..user.models import Event, Project, Activity
from ..aggregation import GetProjectData, AddProjectData, GetEventUsers
from ..apipackage import ImportEventPackage, ImportEventByURL, PackageEvent
from ..apipackage import ImportEventPackage, PackageEvent
from ..apiutils import (
get_project_list,
get_event_activities,
@ -87,7 +87,8 @@ def project_list_csv(event_id, event_name):
'Content-Disposition': 'attachment; filename='
+ event_name + '_dribdat.csv'
}
return Response(stream_with_context(gen_csv(request_project_list(event_id))),
csvlist = gen_csv(request_project_list(event_id))
return Response(stream_with_context(csvlist),
mimetype='text/csv',
headers=headers)
@ -390,9 +391,14 @@ def project_uploader():
ext = img.filename.split('.')[-1].lower()
if ext not in ACCEPTED_TYPES:
return 'Invalid format (allowed: %s)' % ','.join(ACCEPTED_TYPES)
filename = random_password(24) + '.' + ext
# use random subfolder inside user id folder
filename = '/'.join([
str(current_user.id),
random_password(24),
img.filename
])
# with tempfile.TemporaryDirectory() as tmpdir:
# img.save(path.join(tmpdir, filename))
# img.save(path.join(tmpdir, filename))
if 'S3_FOLDER' in current_app.config:
s3_filepath = '/'.join([current_app.config['S3_FOLDER'], filename])
else:
@ -421,8 +427,10 @@ def project_uploader():
)
return '/'.join([current_app.config['S3_HTTPS'], s3_filepath])
# ------ DATA PACKAGE API --------
def generate_event_package(event, format='json'):
""" Creates a Data Package from the data of an event """

70
poetry.lock generated
View File

@ -37,14 +37,6 @@ python-versions = ">=3.6"
[package.dependencies]
typing-extensions = {version = ">=3.6.5", markers = "python_version < \"3.8\""}
[[package]]
name = "atomicwrites"
version = "1.4.1"
description = "Atomic file writes."
category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "attrs"
version = "22.1.0"
@ -152,7 +144,7 @@ python-versions = ">=3.7"
[[package]]
name = "certifi"
version = "2022.6.15"
version = "2022.9.14"
description = "Python package for providing Mozilla's CA Bundle."
category = "main"
optional = false
@ -232,7 +224,7 @@ toml = ["toml"]
[[package]]
name = "cryptography"
version = "37.0.4"
version = "38.0.1"
description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers."
category = "dev"
optional = false
@ -245,7 +237,7 @@ cffi = ">=1.12"
docs = ["sphinx (>=1.6.5,!=1.8.0,!=3.1.0,!=3.1.1)", "sphinx-rtd-theme"]
docstest = ["pyenchant (>=1.6.11)", "twine (>=1.12.0)", "sphinxcontrib-spelling (>=4.0.1)"]
pep8test = ["black", "flake8", "flake8-import-order", "pep8-naming"]
sdist = ["setuptools_rust (>=0.11.4)"]
sdist = ["setuptools-rust (>=0.11.4)"]
ssh = ["bcrypt (>=3.1.5)"]
test = ["pytest (>=6.2.0)", "pytest-benchmark", "pytest-cov", "pytest-subtests", "pytest-xdist", "pretend", "iso8601", "pytz", "hypothesis (>=1.11.4,!=3.79.2)"]
@ -659,7 +651,7 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]]
name = "graphene"
version = "3.1"
version = "3.1.1"
description = "GraphQL Framework for Python"
category = "main"
optional = false
@ -729,7 +721,7 @@ python-versions = ">=3.6"
[[package]]
name = "idna"
version = "3.3"
version = "3.4"
description = "Internationalized Domain Names in Applications (IDNA)"
category = "main"
optional = false
@ -839,7 +831,7 @@ python-versions = "*"
[[package]]
name = "jsonschema"
version = "4.15.0"
version = "4.16.0"
description = "An implementation of JSON Schema validation for Python"
category = "main"
optional = false
@ -937,7 +929,7 @@ cffi = ">=1.0.0"
[[package]]
name = "oauthlib"
version = "3.2.0"
version = "3.2.1"
description = "A generic, spec-compliant, thorough implementation of the OAuth request-signing logic"
category = "main"
optional = false
@ -1142,14 +1134,13 @@ test = ["nose"]
[[package]]
name = "pytest"
version = "7.1.2"
version = "7.1.3"
description = "pytest: simple powerful testing with Python"
category = "dev"
optional = false
python-versions = ">=3.7"
[package.dependencies]
atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""}
attrs = ">=19.2.0"
colorama = {version = "*", markers = "sys_platform == \"win32\""}
importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
@ -1175,11 +1166,11 @@ six = ">=1.5"
[[package]]
name = "python-dotenv"
version = "0.20.0"
version = "0.21.0"
description = "Read key-value pairs from a .env file and set them as environment variables"
category = "main"
optional = false
python-versions = ">=3.5"
python-versions = ">=3.7"
[package.extras]
cli = ["click (>=5.0)"]
@ -1381,7 +1372,7 @@ sqlcipher = ["sqlcipher3-binary"]
[[package]]
name = "sqlalchemy-continuum"
version = "1.3.12"
version = "1.3.13"
description = "Versioning and auditing extension for SQLAlchemy."
category = "main"
optional = false
@ -1392,13 +1383,12 @@ SQLAlchemy = ">=1.0.8"
SQLAlchemy-Utils = ">=0.30.12"
[package.extras]
anyjson = ["anyjson (>=0.3.3)"]
flask = ["Flask (>=0.9)"]
flask-login = ["Flask-Login (>=0.2.9)"]
flask-sqlalchemy = ["Flask-SQLAlchemy (>=1.0)"]
flexmock = ["flexmock (>=0.9.7)"]
i18n = ["SQLAlchemy-i18n (>=0.8.4,!=1.1.0)"]
test = ["pytest (>=2.3.5)", "flexmock (>=0.9.7)", "psycopg2 (>=2.4.6)", "PyMySQL (>=0.8.0)", "six (>=1.4.0)", "anyjson (>=0.3.3)", "Flask (>=0.9)", "Flask-Login (>=0.2.9)", "Flask-SQLAlchemy (>=1.0)", "SQLAlchemy-i18n (>=0.8.4,!=1.1.0)"]
test = ["pytest (>=2.3.5)", "flexmock (>=0.9.7)", "psycopg2 (>=2.4.6)", "PyMySQL (>=0.8.0)", "six (>=1.4.0)", "Flask (>=0.9)", "Flask-Login (>=0.2.9)", "Flask-SQLAlchemy (>=1.0)", "SQLAlchemy-i18n (>=0.8.4,!=1.1.0)"]
[[package]]
name = "sqlalchemy-utils"
@ -1654,7 +1644,6 @@ async-timeout = [
{file = "async-timeout-4.0.2.tar.gz", hash = "sha256:2163e1640ddb52b7a8c80d0a67a08587e5d245cc9c553a74a847056bc2976b15"},
{file = "async_timeout-4.0.2-py3-none-any.whl", hash = "sha256:8ca1e4fcf50d07413d66d1a5e416e42cfdf5851c981d679a09851a6853383b3c"},
]
atomicwrites = []
attrs = []
bcrypt = []
beautifulsoup4 = [
@ -1672,10 +1661,7 @@ botocore = [
{file = "botocore-1.22.12.tar.gz", hash = "sha256:fc59b55e8c5dde64b017b2f114c25f8cce397b667e812aea7eafb4b59b49d7cb"},
]
cachelib = []
certifi = [
{file = "certifi-2022.6.15-py3-none-any.whl", hash = "sha256:fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412"},
{file = "certifi-2022.6.15.tar.gz", hash = "sha256:84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d"},
]
certifi = []
cffi = []
chardet = []
charset-normalizer = []
@ -1844,10 +1830,7 @@ frictionless = []
future = [
{file = "future-0.18.2.tar.gz", hash = "sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d"},
]
graphene = [
{file = "graphene-3.1-py2.py3-none-any.whl", hash = "sha256:99becdccd2683c2db1a8486e98d007b5e64fa2ff0922e6c1b08e19233031368d"},
{file = "graphene-3.1.tar.gz", hash = "sha256:73332510a14b94fcb925dae4563ad6a028d414144704fdcc191565af72608798"},
]
graphene = []
graphql-core = [
{file = "graphql-core-3.2.1.tar.gz", hash = "sha256:9d1bf141427b7d54be944587c8349df791ce60ade2e3cccaf9c56368c133c201"},
{file = "graphql_core-3.2.1-py3-none-any.whl", hash = "sha256:f83c658e4968998eed1923a2e3e3eddd347e005ac0315fbb7ca4d70ea9156323"},
@ -1904,10 +1887,7 @@ hiredis = [
{file = "hiredis-2.0.0-pp37-pypy37_pp73-win32.whl", hash = "sha256:f52010e0a44e3d8530437e7da38d11fb822acfb0d5b12e9cd5ba655509937ca0"},
{file = "hiredis-2.0.0.tar.gz", hash = "sha256:81d6d8e39695f2c37954d1011c0480ef7cf444d4e3ae24bc5e89ee5de360139a"},
]
idna = [
{file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"},
{file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"},
]
idna = []
importlib-metadata = [
{file = "importlib_metadata-4.2.0-py3-none-any.whl", hash = "sha256:057e92c15bc8d9e8109738a48db0ccb31b4d9d5cfbee5a8670879a30be66304b"},
{file = "importlib_metadata-4.2.0.tar.gz", hash = "sha256:b7e52a1f8dec14a75ea73e0891f3060099ca1d8e6a462a4dff11c3e119ea1b31"},
@ -1996,10 +1976,7 @@ micawber = [
misaka = [
{file = "misaka-2.1.1.tar.gz", hash = "sha256:62f35254550095d899fc2ab8b33e156fc5e674176f074959cbca43cf7912ecd7"},
]
oauthlib = [
{file = "oauthlib-3.2.0-py3-none-any.whl", hash = "sha256:6db33440354787f9b7f3a6dbd4febf5d0f93758354060e802f6c06cb493022fe"},
{file = "oauthlib-3.2.0.tar.gz", hash = "sha256:23a8208d75b902797ea29fd31fa80a15ed9dc2c6c16fe73f5d346f83f6fa27a2"},
]
oauthlib = []
packaging = [
{file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
@ -2122,18 +2099,12 @@ pyrsistent = [
pystache = [
{file = "pystache-0.6.0.tar.gz", hash = "sha256:93bf92b2149a4c4b58d12142e2c4c6dd5c08d89e4c95afccd4b6efe2ee1d470d"},
]
pytest = [
{file = "pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"},
{file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"},
]
pytest = []
python-dateutil = [
{file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"},
{file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"},
]
python-dotenv = [
{file = "python-dotenv-0.20.0.tar.gz", hash = "sha256:b7e3b04a59693c42c36f9ab1cc2acc46fa5df8c78e178fc33a8d4cd05c8d498f"},
{file = "python_dotenv-0.20.0-py3-none-any.whl", hash = "sha256:d92a187be61fe482e4fd675b6d52200e7be63a12b724abbf931a40ce4fa92938"},
]
python-dotenv = []
python-slugify = [
{file = "python-slugify-6.1.2.tar.gz", hash = "sha256:272d106cb31ab99b3496ba085e3fea0e9e76dcde967b5e9992500d1f785ce4e1"},
{file = "python_slugify-6.1.2-py2.py3-none-any.whl", hash = "sha256:7b2c274c308b62f4269a9ba701aa69a797e9bca41aeee5b3a9e79e36b6656927"},
@ -2234,10 +2205,7 @@ sqlalchemy = [
{file = "SQLAlchemy-1.4.22-cp39-cp39-win_amd64.whl", hash = "sha256:1fdae7d980a2fa617d119d0dc13ecb5c23cc63a8b04ffcb5298f2c59d86851e9"},
{file = "SQLAlchemy-1.4.22.tar.gz", hash = "sha256:ec1be26cdccd60d180359a527d5980d959a26269a2c7b1b327a1eea0cab37ed8"},
]
sqlalchemy-continuum = [
{file = "SQLAlchemy-Continuum-1.3.12.tar.gz", hash = "sha256:ae51e5e7d300421b2270cb59413f6bbf5890ac3c9560995ac2dca1bc568033ba"},
{file = "SQLAlchemy_Continuum-1.3.12-py3-none-any.whl", hash = "sha256:8829ae87677c4f0ac14f5e6a2dd29a4a02be82e875db33fc1e05abf36e75741e"},
]
sqlalchemy-continuum = []
sqlalchemy-utils = []
stringcase = [
{file = "stringcase-1.2.0.tar.gz", hash = "sha256:48a06980661908efe8d9d34eab2b6c13aefa2163b3ced26972902e3bdfd87008"},

View File

@ -8,7 +8,7 @@ bleach==5.0.1; python_version >= "3.7"
boto3==1.19.12; python_version >= "3.6"
botocore==1.22.12; python_version >= "3.6"
cachelib==0.9.0; python_version >= "3.7"
certifi==2022.6.15; python_version >= "3.7" and python_version < "4"
certifi==2022.9.14; python_version >= "3.7" and python_version < "4"
cffi==1.15.1
chardet==5.0.0; python_version >= "3.6"
charset-normalizer==2.1.1; python_version >= "3.7" and python_version < "4" and python_full_version >= "3.6.0"
@ -37,13 +37,13 @@ flask-wtf==1.0.1; python_version >= "3.6"
flask==2.1.3; python_version >= "3.7"
frictionless==4.40.8
future==0.18.2; (python_version >= "2.6" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0")
graphene==3.1
graphene==3.1.1
graphql-core==3.2.1; python_version >= "3.6" and python_version < "4"
graphql-relay==3.2.0; python_version >= "3.6" and python_version < "4"
greenlet==1.1.3; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.7"
gunicorn==20.1.0; python_version >= "3.5"
hiredis==2.0.0; python_version >= "3.6"
idna==3.3; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4" or python_full_version >= "3.5.0" and python_version >= "3.7" and python_version < "4"
idna==3.4; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4" or python_full_version >= "3.5.0" and python_version >= "3.7" and python_version < "4"
importlib-metadata==4.2.0; python_version < "3.8" and python_version >= "3.7" and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.6.0" and python_version < "3.8" and python_version >= "3.6") and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.6.0" and python_version < "3.8" and python_version >= "3.7")
importlib-resources==5.9.0; python_version < "3.9" and python_version >= "3.7"
isodate==0.6.1
@ -51,14 +51,14 @@ itsdangerous==2.1.2; python_version >= "3.7"
jinja2==3.1.2; python_version >= "3.7"
jmespath==0.10.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6"
jsmin==3.0.1
jsonschema==4.15.0; python_version >= "3.7"
jsonschema==4.16.0; python_version >= "3.7"
lxml==4.9.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
mako==1.2.2; python_version >= "3.7"
marko==1.2.1; python_version >= "3.6"
markupsafe==2.1.1; python_version >= "3.7"
micawber==0.5.4
misaka==2.1.1
oauthlib==3.2.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
oauthlib==3.2.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
packaging==21.3; python_version >= "3.6"
petl==1.7.11; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0"
pkgutil-resolve-name==1.3.10; python_version < "3.9" and python_version >= "3.7"
@ -70,7 +70,7 @@ pyquery==1.4.3
pyrsistent==0.18.1; python_version >= "3.7"
pystache==0.6.0; python_version >= "3.6"
python-dateutil==2.8.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6"
python-dotenv==0.20.0; python_version >= "3.5"
python-dotenv==0.21.0; python_version >= "3.7"
python-slugify==6.1.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"
pytz==2022.2.1
pyyaml==5.4.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")
@ -83,7 +83,7 @@ s3transfer==0.5.2; python_version >= "3.6"
shellingham==1.5.0; python_version >= "3.6"
simpleeval==0.9.12
six==1.16.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7"
sqlalchemy-continuum==1.3.12
sqlalchemy-continuum==1.3.13
sqlalchemy-utils==0.38.3; python_version >= "3.6" and python_version < "4.0"
sqlalchemy==1.4.22; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")
stringcase==1.2.0