Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, *args, **kwargs):
super(ArticleForm, self).__init__(*args, **kwargs)
# Pass POST data into subforms if available
if self.data and 'instance' in kwargs:
self.featured_image_form = FeaturedImageForm(self.data, instance=self.instance.featured_image)
elif 'instance' in kwargs:
self.featured_image_form = FeaturedImageForm(instance=self.instance.featured_image)
elif self.data:
self.featured_image_form = FeaturedImageForm(self.data)
else:
self.featured_image_form = FeaturedImageForm()
if self.data:
self.save_id = self.data.get('saveid')
else:
self.save_id = str(uuid.uuid4())[:8]
def __init__(self, *args, **kwargs):
super(ArticleForm, self).__init__(*args, **kwargs)
# Pass POST data into subforms if available
if self.data and 'instance' in kwargs:
self.featured_image_form = FeaturedImageForm(self.data, instance=self.instance.featured_image)
elif 'instance' in kwargs:
self.featured_image_form = FeaturedImageForm(instance=self.instance.featured_image)
elif self.data:
self.featured_image_form = FeaturedImageForm(self.data)
else:
self.featured_image_form = FeaturedImageForm()
if self.data:
self.save_id = self.data.get('saveid')
else:
self.save_id = str(uuid.uuid4())[:8]
def save_featured_image(self, revision=True):
if self.instance.featured_image:
self.featured_image_form.data = self.data
if revision:
self.instance.featured_image.pk = None
self.featured_image_form.instance = self.instance.featured_image
else:
self.featured_image_form = FeaturedImageForm(self.data)
if self.featured_image_form.is_valid():
saved = self.featured_image_form.save()
saved.article = self.instance
saved.save()
self.instance.featured_image = saved
def __init__(self, *args, **kwargs):
super(ArticleForm, self).__init__(*args, **kwargs)
# Pass POST data into subforms if available
if self.data and 'instance' in kwargs:
self.featured_image_form = FeaturedImageForm(self.data, instance=self.instance.featured_image)
elif 'instance' in kwargs:
self.featured_image_form = FeaturedImageForm(instance=self.instance.featured_image)
elif self.data:
self.featured_image_form = FeaturedImageForm(self.data)
else:
self.featured_image_form = FeaturedImageForm()
if self.data:
self.save_id = self.data.get('saveid')
else:
self.save_id = str(uuid.uuid4())[:8]
def __init__(self, *args, **kwargs):
super(ArticleForm, self).__init__(*args, **kwargs)
# Pass POST data into subforms if available
if self.data and 'instance' in kwargs:
self.featured_image_form = FeaturedImageForm(self.data, instance=self.instance.featured_image)
elif 'instance' in kwargs:
self.featured_image_form = FeaturedImageForm(instance=self.instance.featured_image)
elif self.data:
self.featured_image_form = FeaturedImageForm(self.data)
else:
self.featured_image_form = FeaturedImageForm()
if self.data:
self.save_id = self.data.get('saveid')
else:
self.save_id = str(uuid.uuid4())[:8]