from django.conf import settings
from django.db import models
+from filex.utils import host_validator, path_validator
+
class Favorite(models.Model):
owner = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=u"Właściciel", related_name='favorites')
- host = models.CharField(u"Host", max_length=256)
- path = models.CharField(u"Ścieżka", max_length=1024, default='~')
+ host = models.CharField(u"Host", max_length=256, validators=[host_validator])
+ path = models.CharField(u"Ścieżka", max_length=1024, default='~', validators=[path_validator])
created = models.DateTimeField(u"Utworzono", auto_now_add=True)
updated = models.DateTimeField(u"Uaktualniono", auto_now=True)
unique_together = ('owner', 'host', 'path')
def __unicode__(self):
- return u'{}{} ({})'.format(self.host, self.path, self.owner)
+ return u'{}/{} ({})'.format(self.host, self.path, self.owner)