diff options
author | luxagraf <sng@luxagraf.net> | 2018-07-07 20:41:09 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2018-07-07 20:41:09 -0400 |
commit | 6a2393e6819ea09aeb559354a69746750aa8cbdf (patch) | |
tree | 0ac9890740f9afcd9720ea9b550a3895d95ecb50 /app/photos/models.py | |
parent | fe13c3830c6b36fb8f78009a788650a992cb3070 (diff) |
added campsite model, refactored some code to avoid circular imports,
reorganized some auxilary functions and fixed broken build JS.
Diffstat (limited to 'app/photos/models.py')
-rw-r--r-- | app/photos/models.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/app/photos/models.py b/app/photos/models.py index 5a7bff1..5a41182 100644 --- a/app/photos/models.py +++ b/app/photos/models.py @@ -15,7 +15,6 @@ from django.conf import settings from django import forms from taggit.managers import TaggableManager -from locations.models import Location, Region from resizeimage.imageexceptions import ImageSizeError @@ -69,7 +68,7 @@ class LuxImage(models.Model): height = models.CharField(max_length=6, blank=True, null=True) width = models.CharField(max_length=6, blank=True, null=True) point = models.PointField(null=True, blank=True) - location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True, blank=True) + location = models.ForeignKey("locations.Location", on_delete=models.CASCADE, null=True, blank=True) is_public = models.BooleanField(default=True) sizes = models.ManyToManyField(LuxImageSize, blank=True) flickr_id = models.CharField(null=True, blank=True, max_length=80) @@ -177,10 +176,10 @@ class LuxImage(models.Model): if not self.point: self.point = LuxImage.objects.latest().point try: - self.location = Location.objects.filter( + self.location = apps.get_model('locations', 'Location').objects.filter( geometry__contains=self.point ).get() - except Location.DoesNotExist: + except DoesNotExist: raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL)) super(LuxImage, self).save() @@ -239,7 +238,7 @@ class LuxGallery(models.Model): images = models.ManyToManyField(LuxImage) pub_date = models.DateTimeField(null=True) point = models.PointField(null=True, blank=True) - location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True, blank=True) + location = models.ForeignKey("locations.Location", on_delete=models.CASCADE, null=True, blank=True) is_public = models.BooleanField(default=True) caption_style = models.CharField(blank=True, null=True, max_length=400) @@ -318,8 +317,8 @@ class Photo(models.Model): flickr_originalsecret = models.CharField(max_length=50) lon = models.FloatField('Longitude', help_text="Longitude of centerpoint", null=True) lat = models.FloatField('Latitude', help_text="Latitude of centerpoint", null=True) - location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True) - region = models.ForeignKey(Region, on_delete=models.CASCADE, null=True) + location = models.ForeignKey("locations.Location", on_delete=models.CASCADE, null=True) + region = models.ForeignKey("locations.Region", on_delete=models.CASCADE, null=True) slideshowimage_width = models.CharField(max_length=4, blank=True, null=True) slideshowimage_height = models.CharField(max_length=4, blank=True, null=True) slideshowimage_margintop = models.CharField(max_length=4, blank=True, null=True) @@ -462,8 +461,8 @@ class PhotoGallery(models.Model): set_slug = models.CharField(blank=True, max_length=300) primary = models.CharField(blank=True, max_length=300) photos = models.ManyToManyField(Photo) - location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True) - region = models.ForeignKey(Region, on_delete=models.CASCADE, null=True) + location = models.ForeignKey("locations.Location", on_delete=models.CASCADE, null=True) + region = models.ForeignKey("locations.Region", on_delete=models.CASCADE, null=True) pub_date = models.DateTimeField(null=True) class Meta: |