def addDictionary(self, name, description): name = functions.trim(name) description = functions.trim(description) if not self._dict.isExist(current_user, name): self._dict.add(current_user, name, description) return True else: raise DictionaryAlreadyExistError
def changeWord(self, name, old, new, translate, transcription, time): new = functions.trim(new) translate = functions.trim(translate) transcription = functions.trim(transcription) if self._dict.isExist(current_user, name): self._dict.changeWord(current_user, name, old, new, translate, transcription, time) return True else: raise DictionaryNotExistError
def addWord(self, dictName, original, translate, transcription, time, replace=False): original = functions.trim(original) translate = functions.trim(translate) transcription = functions.trim(transcription) if self._dict.isExist(current_user, dictName): self._dict.addWord(current_user, dictName, original, translate, transcription, time, replace) return True else: raise DictionaryNotExistError
def changeDictionary(self, oldName, newName, description): newName = functions.trim(newName) description = functions.trim(description) if self._dict.isExist(current_user, oldName): if self._dict.isExist(current_user, newName)\ and oldName != newName: raise DictionaryAlreadyExistError else: self._dict.change(current_user, oldName, newName, description) return True else: raise DictionaryNotExistError
def registerUser(self, name, password): name = functions.trim(name) if self._user.register(name, password): self.loginUser(name, password, True) self.addDictionary('Dict', 'Default dictionary') else: raise UserAlreadyExistError
def loginUser(self, name, password, remember): name = functions.trim(name) if not self._user.login(name, password, remember): raise InvalidUsernameOrPasswordError
def addAnswer(self, question, answer): # answer - tuple() self._testManager.setAnswer(current_user.id, functions.trim(question.lower()), functions.trim(answer.lower()))