예제 #1
0
def registerAdmin(username: str, password: str):
    """Registers a new admin, if the username isn't yet taken

    Parameters
    ----------
    name : username
        The user login
    name : password
        The password set for that user

    Raises
    ----------
    ExistingUserException
        If an already existing username is passed as the first argument.
    """
    if (userExists(username)):
        raise exceptions.ExistingUserException(
            "{0} already exists in the database".format(username))
    else:
        newUser = User(username, password, True)
        jsonUser = newUser.toJSON()

        usersCollection.insert_one(jsonUser)


##link = Link (["Grumbarg"], "<0> es <1> del ejército de <2>", ["general", "Rahash"], "Grumbarg el grande", 1)
##addLink(link)
##newLink = getLink(link.getName())
##print(newLink.getFullText())
##print (existsLink("holaa"))
##print (getLinkByLinks("pájaro").getName())
##print (getLinksByField("alias", "hola"))
##for i in getLinksContainingWord("alias", "guerra"):
##    print (i)
##print (getLink("Ruiseñor escarlata").getFormattedText())
##print (getLink("Ruiseñor escarlata").getFullText())
##print (getLinkByField("alias", "Muertos"))
##for link in getLinksByField("_id", "5fd2bcf54e318fc347906f78"):
#    print (link)
# link = getLink("Mijail")
# print (link.id)
# link.alias.append("Mikhail")
# updateLinkById(link.id, link)
#print (userExists("joaquinollo"))
#registerUser("joaco", "esdla03")
예제 #2
0
def registerUser(username: str, password: str):
    """Registers a new user, if the username isn't yet taken

    Parameters
    ----------
    name : username
        The user login
    name : password
        The password set for that user

    Raises
    ----------
    ExistingUserException
        If an already existing username is passed as the first argument.
    """
    if (userExists(username)):
        raise exceptions.ExistingUserException(
            "{0} already exists in the database".format(username))
    else:
        newUser = User(username, password)
        jsonUser = newUser.toJSON()

        usersCollection.insert_one(jsonUser)