Allow Vimeo as well as YouTube URLs. Closes #26.
This commit is contained in:
@ -423,13 +423,11 @@ class CaseStudy(models.Model):
|
||||
|
||||
# 1.16.1
|
||||
video = models.URLField(
|
||||
verbose_name=_("YouTube Video"),
|
||||
help_text=_("Copy the URL to a related YouTube™ video that relates to the case study."),
|
||||
max_length=43,
|
||||
validators=[validators.YoutubeURLValidator()],
|
||||
blank=True,
|
||||
default=None,
|
||||
null=True,
|
||||
verbose_name=_("Video URL"),
|
||||
help_text=_("Copy the URL to a YouTube or Vimeo video that relates to the case study."),
|
||||
max_length=80,
|
||||
validators=[validators.YouTubeOrVimeoValidator()],
|
||||
blank=True
|
||||
)
|
||||
|
||||
# 1.16.2
|
||||
@ -1030,10 +1028,23 @@ class CaseStudy(models.Model):
|
||||
# Continue normal save method by calling original save method.
|
||||
super(CaseStudy, self).save(*args, **kwargs)
|
||||
|
||||
def get_video_id(self):
|
||||
|
||||
def is_video_youtube(self):
|
||||
return self.video.count("youtube.com") > 0
|
||||
|
||||
def get_youtube_id(self):
|
||||
"""Gets the 11 character YouTube video ID from the video field."""
|
||||
return parse.parse_qs(parse.urlparse(self.video).query)["v"][0]
|
||||
|
||||
|
||||
def is_video_vimeo(self):
|
||||
return self.video.count("vimeo.com") > 0
|
||||
|
||||
def get_vimeo_id(self):
|
||||
"""Gets the 11 number video ID from the video field."""
|
||||
return parse.urlparse(self.video).path
|
||||
|
||||
|
||||
def get_negative_case_reasons_no_other(self):
|
||||
"""Return a list of negative case reasons, minus the 'other' choice (if selected)"""
|
||||
choices = self.get_negative_case_reasons_list()
|
||||
|
Reference in New Issue
Block a user