diff options
author | luxagraf <sng@luxagraf.net> | 2016-12-13 14:16:50 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2016-12-13 14:16:50 -0500 |
commit | c2b4eee457e3b527795b674716d3d09688192fcf (patch) | |
tree | e70511a5c0150ddd19a138fab8f8ddec417c8af1 /app/photos/models.py | |
parent | 59efbaf5415adedde575fcc026b247800491b039 (diff) |
Added video upload tools and inserting
Diffstat (limited to 'app/photos/models.py')
-rw-r--r-- | app/photos/models.py | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/app/photos/models.py b/app/photos/models.py index 4249e6f..0d123c3 100644 --- a/app/photos/models.py +++ b/app/photos/models.py @@ -25,6 +25,8 @@ from django.db.models.signals import m2m_changed def get_upload_path(self, filename): return "images/original/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename) +def get_vid_upload_path(self, filename): + return "images/videos/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename) class LuxImageSize(models.Model): name = models.CharField(null=True, blank=True, max_length=30) @@ -49,7 +51,7 @@ class LuxImage(models.Model): photo_credit_source = models.CharField(null=True, blank=True, max_length=300) photo_credit_url = models.CharField(null=True, blank=True, max_length=300) caption = models.TextField(blank=True, null=True) - pub_date = models.DateTimeField() + pub_date = models.DateTimeField(default=datetime.datetime.now) exif_raw = models.TextField(blank=True, null=True) exif_aperture = models.CharField(max_length=50, blank=True, null=True) exif_make = models.CharField(max_length=50, blank=True, null=True) @@ -64,7 +66,6 @@ class LuxImage(models.Model): point = models.PointField(null=True, blank=True) location = models.ForeignKey(Location, null=True, blank=True) is_public = models.BooleanField(default=True) - is_video = models.BooleanField(default=False) sizes = models.ManyToManyField(LuxImageSize, blank=True) flickr_id = models.CharField(null=True, blank=True, max_length=80) twitter_link = models.CharField(null=True, blank=True, max_length=300) @@ -81,17 +82,15 @@ class LuxImage(models.Model): else: return "%s" % self.pk + def get_type(self): + return str(self.__class__.__name__) + def get_admin_image(self): for size in self.sizes.all(): if size.width and size.width <= 820 or size.height and size.height<=800: print("Size name" +size.name) return self.get_image_by_size(size.name) - def get_video_base_url(self): - if self.is_video: - return self.image.url[:-4] - - def get_largest_image(self): t = [] for size in self.sizes.all(): @@ -255,6 +254,26 @@ class LuxGallery(models.Model): thumbs.allow_tags = True +class LuxVideo(models.Model): + video_mp4 = models.FileField(blank=True, null=True, upload_to=get_vid_upload_path) + video_webm = models.FileField(blank=True, null=True, upload_to=get_vid_upload_path) + video_poster = models.FileField(blank=True, null=True, upload_to=get_vid_upload_path) + title = models.CharField(null=True, blank=True, max_length=300) + pub_date = models.DateTimeField(default=datetime.datetime.now) + youtube_url = models.CharField(null=True, blank=True, max_length=80) + vimeo_url = models.CharField(null=True, blank=True, max_length=300) + + def __str__(self): + return self.title + + def get_type(self): + return str(self.__class__.__name__) + + class Meta: + ordering = ('-pub_date', 'id') + verbose_name_plural = 'Videos' + get_latest_by = 'pub_date' + class Photo(models.Model): description = models.TextField(blank=True, null=True) title = models.CharField(blank=True, max_length=300) |