diff options
Diffstat (limited to 'app/birds/models.py')
-rw-r--r-- | app/birds/models.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/app/birds/models.py b/app/birds/models.py index dc2aa19..05a1159 100644 --- a/app/birds/models.py +++ b/app/birds/models.py @@ -8,6 +8,7 @@ from locations.models import Location from django import forms from django.conf import settings +from photos.models import LuxImage def get_upload_path(self, filename): return "images/bird-images/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename) @@ -42,11 +43,21 @@ class Bird(models.Model): scientific_name = models.CharField(max_length=200) code = models.IntegerField(choices=ABA_CODES, default=0) bird_class = models.ForeignKey(BirdClass) - image = models.FileField(upload_to=get_upload_path, null=True, blank=True) + image = models.FileField(upload_to=get_upload_path, null=True, blank=True, help_text="width of high res is 1360px") + image_credit = models.CharField(max_length=200, blank=True, null=True) def __str__(self): return self.common_name + # function to resize large image to 680px wide and use as normal image + # the question is, should this happen here, or with some universale image + # model that can be attached to other models, loaded in entries and + # displayed in galleries. I suppose the answer is yes then isn't it? + # the problem is that I still can't see exactly what that looks like... + + def get_image_url(self): + return "%s%s" % (settings.IMAGES_URL, self.image.url.split("media")[1][8:]) + def get_absolute_url(self): return reverse("birds:detail", kwargs={"slug": self.slug}) @@ -82,6 +93,7 @@ class BirdSighting(models.Model): date = models.DateTimeField('Date', default=timezone.now) image = models.FileField(upload_to=get_upload_path, null=True, blank=True) seen_by = models.ManyToManyField(User) + images = models.ManyToManyField(LuxImage) class Meta: verbose_name_plural = 'Bird Sighting' |