Exemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        """Run _checkrep on instantiation"""
        super(Video, self).__init__(*args, **kwargs)

        # Convert any http:// protocols to https://
        if self.url[:7] == "http://":
            self.url = force_https(self.url)

        #When adding a new instance (e.g. in admin), their will be no
        #datamembers, so only check existing instances eg. from db load.
        if self.pk != None:
            self._checkrep()
Exemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        """Run _checkrep on instantiation"""
        super(Video, self).__init__(*args, **kwargs)
        
        # Convert any http:// protocols to https://
        if self.url[:7] == "http://":
            self.url = force_https(self.url)

        #When adding a new instance (e.g. in admin), their will be no 
        #datamembers, so only check existing instances eg. from db load.
        if self.pk != None:
            self._checkrep()
Exemplo n.º 3
0
    def _checkrep(self):
        if self.name == "":
            logger.warning("Video {0} lacks name".format(self.id))
            return False
        if self.url == "":
            logger.warning("Video {0} lacks url".format(self.id))
            return False
        # Convert any http:// protocols to https://
        if self.url[:7] == "http://":
            self.url = force_https(self.url)
            logger.info("Rewriting https protocol on video {0}".format(self.id))
            self.save()

        # At least one of these should not be zero:
        if not (self.course or self.lesson): 
            logger.error("Orphaned video")
            raise CheckRepError("Video has no FK to course or lesson")
        return True
Exemplo n.º 4
0
    def _checkrep(self):
        if self.name == "":
            logger.warning("Video {0} lacks name".format(self.id))
            return False
        if self.url == "":
            logger.warning("Video {0} lacks url".format(self.id))
            return False
        # Convert any http:// protocols to https://
        if self.url[:7] == "http://":
            self.url = force_https(self.url)
            logger.info("Rewriting https protocol on video {0}".format(
                self.id))
            self.save()

        # At least one of these should not be zero:
        if not (self.course or self.lesson):
            logger.error("Orphaned video")
            raise CheckRepError("Video has no FK to course or lesson")
        return True