Fix file name display in status view

This commit is contained in:
Kumi 2021-01-06 14:03:13 +01:00
parent 51dacb50e0
commit 178fa098f5
2 changed files with 7 additions and 1 deletions

View file

@ -3,6 +3,8 @@ from django.contrib.auth import get_user_model
from django.core.validators import MaxValueValidator, MinValueValidator
from django.utils import timezone
import os.path
from colorfield.fields import ColorField
from common.helpers import get_upload_path
@ -48,6 +50,10 @@ class StatusMedia(models.Model):
status = models.ForeignKey(Status, models.CASCADE)
file = models.FileField(get_upload_path)
@property
def basename(self):
return os.path.basename(self.file.name)
class StatusActivity(models.Model):
status = models.ForeignKey(Status, models.CASCADE)
activity = models.ForeignKey(Activity, models.CASCADE)

View file

@ -59,7 +59,7 @@
<div class="container">
<ul>
{% for attachment in object.statusmedia_set.all %}
<li><a href="{{ attachment.file.url }}">{{ attachment.file.name }}</a></li>
<li><a href="{{ attachment.file.url }}">{{ attachment.basename }}</a></li>
{% endfor %}
</ul>
</div>