L7G9 / tplot

Django Timeline Web Application
0 stars 0 forks source link

PDF file name #23

Closed L7G9 closed 4 weeks ago

L7G9 commented 1 month ago

Instead of identical filename for pdf could use timeline title to make file name. Would need to make sure it was valid.

L7G9 commented 1 month ago

Can use slugify to turn string in valid file name from django.utils.text import slugify def get_filename(in_string, extension="pdf"): return f"{slugify(in_string)}.{pdf}"

L7G9 commented 1 month ago

Make sure timeline title is alphanumeric only from django.core.validators import RegexValidator alphanumeric = RegexValidator(r'^[0-9a-zA-Z]*$', 'Only alphanumeric characters are allowed.') title = models.CharField(max_length=100, validators=[alphanumeric])

L7G9 commented 4 weeks ago

fixed 25/8/25 see timelines.pdf.get_filename