Esempio n. 1
0
    def save(self, *args, **kwargs):
        if not self.md5:
            self.md5 = md5sum(self.image_orig)

        if not self.orig_width or not self.orig_height:
            self.orig_width = self.image_orig.width
            self.orig_height = self.image_orig.height

        if not self.aspect_ratio:
            self.aspect_ratio = (float(self.image_orig.width) /
                                 float(self.image_orig.height))

        if not self.focal_y and self.fov:
            dim = max(self.image_orig.width, self.image_orig.height)
            self.focal_y = 0.5 * dim / (self.image_orig.height *
                                        math.tan(math.radians(self.fov / 2)))

        if not self.license and self.flickr_user and self.flickr_id:
            self.license = License.get_for_flickr_photo(
                self.flickr_user, self.flickr_id)

        super(Photo, self).save(*args, **kwargs)
Esempio n. 2
0
def update_photo_license(photo_id):
    p = Photo.objects.get(id=photo_id)
    p.license = License.get_for_flickr_photo(p.flickr_user, p.flickr_id)
    p.save()
Esempio n. 3
0
def update_photo_license(photo_id):
    p = Photo.objects.get(id=photo_id)
    p.license = License.get_for_flickr_photo(p.flickr_user, p.flickr_id)
    p.save()