Limit amount of imports (#1161)
* Limit amount of imports * Review suggestions * Format Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
parent
bcd4383e05
commit
2837350204
|
@ -28,6 +28,15 @@ def batch_import_route():
|
||||||
batch_imports = BatchImport.filter_by(user_id=current_user.id).all()
|
batch_imports = BatchImport.filter_by(user_id=current_user.id).all()
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
|
if len(batch_imports) > 10:
|
||||||
|
flash(
|
||||||
|
"You have too many imports already. Wait until some get cleaned up",
|
||||||
|
"error",
|
||||||
|
)
|
||||||
|
return render_template(
|
||||||
|
"dashboard/batch_import.html", batch_imports=batch_imports
|
||||||
|
)
|
||||||
|
|
||||||
alias_file = request.files["alias-file"]
|
alias_file = request.files["alias-file"]
|
||||||
|
|
||||||
file_path = random_string(20) + ".csv"
|
file_path = random_string(20) + ".csv"
|
||||||
|
|
|
@ -204,9 +204,10 @@ def create_app() -> Flask:
|
||||||
@login_manager.user_loader
|
@login_manager.user_loader
|
||||||
def load_user(alternative_id):
|
def load_user(alternative_id):
|
||||||
user = User.get_by(alternative_id=alternative_id)
|
user = User.get_by(alternative_id=alternative_id)
|
||||||
if user and user.disabled:
|
if user:
|
||||||
return None
|
sentry_sdk.set_user({"email": user.email, "id": user.id})
|
||||||
sentry_sdk.set_user({"email": user.email, "id": user.id})
|
if user.disabled:
|
||||||
|
return None
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue