def save(self, parent_doc, **kwargs): """Persist the Document form, and return the saved Document.""" doc = super(DocumentForm, self).save(commit=False, **kwargs) doc.parent = parent_doc # If document doesn't need change, clear out the comment. if not doc.needs_change: doc.needs_change_comment = "" # Create the share link if it doesn't exist and is in # a category it should show for. doc.save() if doc.category in settings.IA_DEFAULT_CATEGORIES and not doc.share_link: # This operates under the constraints of passing in a list. add_short_links.delay([doc.pk]) self.save_m2m() if parent_doc: # Products are not set on translations. doc.products.remove(*[p for p in doc.products.all()]) return doc
def save(self, parent_doc, **kwargs): """Persist the Document form, and return the saved Document.""" doc = super(DocumentForm, self).save(commit=False, **kwargs) doc.parent = parent_doc # If document doesn't need change, clear out the comment. if not doc.needs_change: doc.needs_change_comment = '' # Create the share link if it doesn't exist and is in # a category it should show for. doc.save() if (doc.category in settings.IA_DEFAULT_CATEGORIES and not doc.share_link): # This operates under the constraints of passing in a list. add_short_links.delay([doc.pk]) self.save_m2m() if parent_doc: # Products are not set on translations. doc.products.remove(*[p for p in doc.products.all()]) return doc