add absolute url to file model
This commit is contained in:
parent
1dd4ac8088
commit
391da3fd27
1 changed files with 7 additions and 1 deletions
|
@ -1,9 +1,9 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
import os
|
|
||||||
import uuid
|
import uuid
|
||||||
from admin_resumable.fields import ModelAdminResumableFileField
|
from admin_resumable.fields import ModelAdminResumableFileField
|
||||||
from shortuuidfield import ShortUUIDField
|
from shortuuidfield import ShortUUIDField
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
|
|
||||||
class SharedFile(models.Model):
|
class SharedFile(models.Model):
|
||||||
|
@ -14,9 +14,15 @@ class SharedFile(models.Model):
|
||||||
hotlink = models.BooleanField(default=False)
|
hotlink = models.BooleanField(default=False)
|
||||||
published = models.BooleanField(default=True)
|
published = models.BooleanField(default=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.get_original_filename()
|
||||||
|
|
||||||
def get_original_filename(self):
|
def get_original_filename(self):
|
||||||
return "_".join(self.file.name.split('_')[1:])
|
return "_".join(self.file.name.split('_')[1:])
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse('files:file', args=(self.short_id,))
|
||||||
|
|
||||||
|
|
||||||
class FileToken(models.Model):
|
class FileToken(models.Model):
|
||||||
valid_time = timedelta(minutes=5)
|
valid_time = timedelta(minutes=5)
|
||||||
|
|
Reference in a new issue