def clean_promotion_media_content_id(self): content_type = self.data.get('promotion_media_content_type') content_id = self.data.get('promotion_media_content_id') if content_type and content_id: if not media_content_extract_id(content_type, content_id): raise forms.ValidationError(_('Invalid content id or url')) elif content_type and not content_id: raise forms.ValidationError(_('Invalid content id or url')) return content_id
def clean_promotion_media_content_id(self): content_type = self.data.get('promotion_media_content_type') content_id = self.data.get('promotion_media_content_id') if content_type and content_id: if not media_content_extract_id(content_type, content_id): raise forms.ValidationError(_('Invalid content id or url')) elif content_type and not content_id: raise forms.ValidationError(_('Invalid content id or url')) return content_id
def save(self, *args, **kwargs): if self.promotion_media_content_type and self.promotion_media_content_id: self.promotion_media_content_id = media_content_extract_id(self.promotion_media_content_type, self.promotion_media_content_id) super(Course, self).save(*args, **kwargs) if self.thumbnail: metadata = {'width':self.THUMBNAIL_WIDTH, 'height':self.THUMBNAIL_HEIGHT, 'force': True} image_path = self.thumbnail.path self._resize_image(image_path, metadata)
def save(self, *args, **kwargs): if self.promotion_media_content_type and self.promotion_media_content_id: self.promotion_media_content_id = media_content_extract_id(self.promotion_media_content_type, self.promotion_media_content_id) super(Course, self).save(*args, **kwargs) if self.thumbnail: metadata = { 'width': self.THUMBNAIL_WIDTH, 'height': self.THUMBNAIL_HEIGHT, 'force': True } image_path = self.thumbnail.path self._resize_image(image_path, metadata)
def save(self, *args, **kwargs): if self.solution_media_content_type and self.solution_media_content_id: self.solution_media_content_id = media_content_extract_id(self.solution_media_content_type, self.solution_media_content_id) return super(Question, self).save(*args, **kwargs)
def save(self, *args, **kwargs): if self.media_content_type and self.media_content_id: self.media_content_id = media_content_extract_id(self.media_content_type, self.media_content_id) return super(KnowledgeQuantum, self).save(*args, **kwargs)
def save(self, *args, **kwargs): if self.promotion_media_content_type and self.promotion_media_content_id: self.promotion_media_content_id = media_content_extract_id(self.promotion_media_content_type, self.promotion_media_content_id) return super(Course, self).save(*args, **kwargs)
def save(self, *args, **kwargs): if self.promotion_media_content_type and self.promotion_media_content_id: self.promotion_media_content_id = media_content_extract_id( self.promotion_media_content_type, self.promotion_media_content_id) return super(Course, self).save(*args, **kwargs)