Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    def loginUser(self, name, password, remember):
        name = functions.trim(name)

        if not self._user.login(name, password, remember):
            raise InvalidUsernameOrPasswordError
Exemplo n.º 7
0
 def addAnswer(self, question, answer):
     # answer - tuple()
     self._testManager.setAnswer(current_user.id,
                                 functions.trim(question.lower()),
                                 functions.trim(answer.lower()))