X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=blobdiff_plain;f=filex%2Fmodels.py;h=82e73b4aafb22b7cbe51171a97a320e372dd2ba4;hb=3e29cd65efbb6b29b3db8c84e625f75829e550e7;hp=71a836239075aa6e6e4ecb700e9c42c95c022d91;hpb=ef3a889b1d85327be1aa86af703d814991cf60ad;p=qcg-portal.git diff --git a/filex/models.py b/filex/models.py index 71a8362..82e73b4 100644 --- a/filex/models.py +++ b/filex/models.py @@ -1,3 +1,22 @@ +# coding=utf-8 +from django.conf import settings from django.db import models -# Create your models here. +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, 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) + + class Meta: + verbose_name = u"Ulubiona lokalizacja" + verbose_name_plural = u"Ulubione lokalizacje" + unique_together = ('owner', 'host', 'path') + + def __unicode__(self): + return u'{}/{} ({})'.format(self.host, self.path, self.owner)