Write an user ot the database.

    :param User user: User to write

def write_user(user):
    """Write an user ot the database.

    :param User user: User to write
    """

    udata = {}

    for f in USER_FIELDS:
        udata[f] = getattr(user, f)

    for p in PERMISSIONS:
        udata[p] = '1' if getattr(user, p) else '0'
    db.hmset('user:{0}'.format(user.uid), udata)