def dictionary_load(self): form = forms.LoadDictionaryForm(self.request.POST) if not form.is_valid(): return self.json_error( 'linguistics.words.load_dictionary.form_errors', form.errors) with transaction.atomic(): for word in form.c.words: prototypes.WordPrototype._db_filter( parent__normal_form=word.normal_form(), type=word.type).delete() parents_ids = prototypes.WordPrototype._db_filter( normal_form=word.normal_form(), type=word.type).values_list('parent_id', flat=True) prototypes.WordPrototype._db_filter( id__in=parents_ids).delete() prototypes.WordPrototype._db_filter( normal_form=word.normal_form(), type=word.type).delete() prototypes.WordPrototype.create( word, parent=None, author=self.account, state=relations.WORD_STATE.IN_GAME) storage.game_dictionary.refresh() storage.game_dictionary.update_version() return self.json_ok()
def dictionary_operations(self): return self.template('linguistics/words/dictionary_operations.html', { 'page_type': 'dictionary', 'form': forms.LoadDictionaryForm() })