Fix file name display in status view
This commit is contained in:
parent
51dacb50e0
commit
178fa098f5
2 changed files with 7 additions and 1 deletions
|
@ -3,6 +3,8 @@ from django.contrib.auth import get_user_model
|
||||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
|
||||||
from colorfield.fields import ColorField
|
from colorfield.fields import ColorField
|
||||||
|
|
||||||
from common.helpers import get_upload_path
|
from common.helpers import get_upload_path
|
||||||
|
@ -48,6 +50,10 @@ class StatusMedia(models.Model):
|
||||||
status = models.ForeignKey(Status, models.CASCADE)
|
status = models.ForeignKey(Status, models.CASCADE)
|
||||||
file = models.FileField(get_upload_path)
|
file = models.FileField(get_upload_path)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def basename(self):
|
||||||
|
return os.path.basename(self.file.name)
|
||||||
|
|
||||||
class StatusActivity(models.Model):
|
class StatusActivity(models.Model):
|
||||||
status = models.ForeignKey(Status, models.CASCADE)
|
status = models.ForeignKey(Status, models.CASCADE)
|
||||||
activity = models.ForeignKey(Activity, models.CASCADE)
|
activity = models.ForeignKey(Activity, models.CASCADE)
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<ul>
|
<ul>
|
||||||
{% for attachment in object.statusmedia_set.all %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue