transliteration of the csv file name
This commit is contained in:
parent
66454b6197
commit
da9f98ccb5
|
@ -5,6 +5,7 @@ import os
|
|||
|
||||
from flask import Blueprint, render_template, request
|
||||
from loguru import logger
|
||||
from transliterate import translit
|
||||
|
||||
from app.models.collection import Collection
|
||||
from app.extensions import db
|
||||
|
@ -53,7 +54,7 @@ def export_users_to_csv(id: int):
|
|||
if len(collection.users) <= 0:
|
||||
return "", 204
|
||||
|
||||
filename = f"{collection.name} - {datetime.now()}.csv"
|
||||
filename = f"{translit(collection.name, 'ru', reversed=True)} - {datetime.now()}.csv"
|
||||
|
||||
fieldnames = collection.users[0].to_dict().keys()
|
||||
si = io.StringIO()
|
||||
|
@ -63,4 +64,4 @@ def export_users_to_csv(id: int):
|
|||
writer.writeheader()
|
||||
writer.writerows(map(lambda user: user.to_dict(), collection.users))
|
||||
|
||||
return si, 200, {'Content-Disposition': f'attachment; filename={filename}', 'Content-type': 'text/csv; charset=utf-8'}
|
||||
return si.getvalue(), 200, {'Content-Disposition': f'attachment; filename={filename}', 'Content-type': 'text/csv; charset=utf-8'}
|
|
@ -37,6 +37,7 @@ six==1.16.0
|
|||
SQLAlchemy==2.0.25
|
||||
Telethon==1.33.1
|
||||
TgCrypto==1.2.5
|
||||
transliterate==1.10.2
|
||||
typing_extensions==4.9.0
|
||||
tzdata==2023.4
|
||||
vine==5.1.0
|
||||
|
|
Loading…
Reference in New Issue