def apply(self, applier): """Apply this edit to the song to which it is attached, setting it as applied by applier""" if not (self.applied or self.denied): for edit in self.field_edits.all(): if edit.field == "artist": self.song.artist = getObj(Artist, edit.new_value) elif edit.field == "album": self.song.album = getObj(Album, edit.new_value) else: setattr(self.song, edit.field, edit.new_value) self.song.save() self.applied = True self.actioned_by = applier self.actioned_at = datetime.datetime.today() self.save()
def clean(self, value): if not isinstance(value, self.model): return getObj(self.model, value) return value
def to_python(self, value): value = super(forms.CharField, self).to_python(value) return getObj(self.model, value)