Permalink
Browse files

Add extension_split and cleaned_filename to the Document class

  • Loading branch information...
1 parent ea49395 commit e3505d05ec1496238c45b58137a7f9ab0f694f06 @rosarior committed Apr 11, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 apps/documents/models.py
@@ -13,6 +13,8 @@
except ImportError:
from StringIO import StringIO
+from unidecode import unidecode
+
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext
@@ -281,6 +283,16 @@ def content(self):
filename = property(_get_filename, _set_filename)
+ @property
+ def cleaned_filename(self):
+ return unidecode(self.extension_split()[0])
+
+ @property
+ def extension_split(self):
+ filename, extension = os.path.splitext(self.filename)
+ return filename, extension[1:]
+
+
class DocumentVersion(models.Model):
"""

0 comments on commit e3505d0

Please sign in to comment.