def save_existing(self, form, instance, commit=True): """ NOTE: save_new method is completely overridden here, there's no other way to pretend double save otherwise. Just assign translated data to object """ self._prepare_multilingual_object(instance, form) return forms.save_instance(form, instance, exclude=[self._pk_field.name], commit=commit)
def save(self, commit=True): if self.instance.pk is None: fail_message = 'created' else: fail_message = 'changed' self.instance.user = self.user self.instance.enabled = self.should_enable return save_instance(self, self.instance, ['feature','user','enabled'], fail_message, commit, construct=False)
def save(self, commit=True): if self.instance.pk is None: fail_message='created' else: fail_message = 'changed' return save_instance(self, self.instance, self._meta.fields, fail_message, commit, construct=False, )
def save_new(self, form, commit=True): """ NOTE: save_new method is completely overridden here, there's no other way to pretend double save otherwise. Just assign translated data to object """ kwargs = {self.fk.get_attname(): self.instance.pk} new_obj = self.model(**kwargs) self._prepare_multilingual_object(new_obj, form) return forms.save_instance(form, new_obj, exclude=[self._pk_field.name], commit=commit)
def save(self, commit=True): if self.instance.pk is None: fail_message = 'created' else: fail_message = 'changed' return save_instance( self, self.instance, self._meta.fields, fail_message, commit, construct=False, )
def save(self, commit=True): if self.instance.pk is None: fail_message = 'created' else: fail_message = 'changed' newinst = forms.save_instance(self, self.instance, self._meta.fields, fail_message, commit) # processim tagi tags = filter( None, map(lambda x: x.strip().lower(), self.cleaned_data['tags'].split(','))) tags = tuple(set(tags)) newinst.tagstring = ', '.join(tags) if not newinst.published: # просто сохраняем строку hastags = newinst.tags.all() for tag in hastags: if tag.weight <= 1: tag.delete() else: tag.weight -= 1 tag.save() tag.post_set.remove(newinst) else: hastags = map(lambda x: x.name, newinst.tags.all()) tags_to_delete = list(set(hastags) - set(tags)) for li in tags_to_delete: tag = Tag.objects.get(name=li) if tag.weight <= 1: tag.delete() else: tag.weight -= 1 tag.save() tag.post_set.remove(newinst) for li in tags: if li not in hastags: tag, cr = Tag.objects.get_or_create(name=li) newinst.tags.add(tag) if not cr: tag.weight += 1 tag.save() newinst.save() return newinst
def save(self, instance, commit = True): opts = instance.__class__._meta if self.errors: raise ValueError("The %s could not be changed because the data " "didn't validate." % opts.object_name) data = self.cleaned_data # remove 'no change fields' from the data for f in opts.fields: if not f.name in data: continue field = self.fields.get(f.name, None) if not field: continue if field.is_no_change(data[f.name]): del data[f.name] return forms.save_instance(self, instance, self._meta.fields, 'changed', commit)
def save(self, commit=True): if self.instance.pk is None: fail_message = 'created' else: fail_message = 'changed' newinst = forms.save_instance(self, self.instance, self._meta.fields, fail_message, commit) # processim tagi tags = filter(None, map(lambda x: x.strip().lower(), self.cleaned_data['tags'].split(','))) tags = tuple(set(tags)) newinst.tagstring = ', '.join(tags) if not newinst.published: # просто сохраняем строку hastags = newinst.tags.all() for tag in hastags: if tag.weight <= 1: tag.delete() else: tag.weight -= 1 tag.save() tag.post_set.remove(newinst) else: hastags = map(lambda x: x.name, newinst.tags.all()) tags_to_delete = list(set(hastags) - set(tags)) for li in tags_to_delete: tag = Tag.objects.get(name=li) if tag.weight <= 1: tag.delete() else: tag.weight -= 1 tag.save() tag.post_set.remove(newinst) for li in tags: if li not in hastags: tag, cr = Tag.objects.get_or_create(name=li) newinst.tags.add(tag) if not cr: tag.weight += 1 tag.save() newinst.save() return newinst
def save(self, commit=True): return forms.save_instance(self, self.job, commit=commit)
def save(self, commit=True): return forms.save_instance(self, Job(), self.fields, commit=commit)
def save(self, commit=True): return forms.save_instance(self, instance, fields, fail_message, commit)
def save(self, commit=True): self.instance.data = self.data self.instance.info_hash = sha1(bencode(self.data['info'])).hexdigest() del self.instance.data['info']['pieces'] # get rid of piece data fail_message = 'created' if self.instance.pk is None else 'changed' return forms.save_instance(self, self.instance, self._meta.fields, fail_message, commit)
def save(self): pm = PrivateMessage(src_user=self.user, dst_user=self.cleaned_data['recipient']) pm = forms.save_instance(self, pm) return pm
def save(self, commit=True): self.instance.torrent = pickle.dumps(self.decoded) self.instance.info_hash = sha1(encode(self.decoded['info'])).hexdigest() fail_message = 'created' if self.instance.pk is None else 'changed' return forms.save_instance(self, self.instance, self._meta.fields, fail_message, commit)