Exemple #1
0
def updatePin(userId,boardName,pinId):

    couch = couchdb.Server()
    mydb = couch['userdb']
    board = couch['boards']
    pin=couch['pinsdb']
    global storage
    storage = Storage()
    bId = storage.getBoardId(boardName)

    if userId in mydb:
        if bId in board:
            if pinId in pin:
                pname = request.POST.get('pinName')
                pdesc = request.POST.get('pinDesc')
                image = request.POST.get('image')

                boardId = storage.updatePin(userId,bId, pinId,pname, pdesc,image )
                return boardId
            else:
                return "Invalid Pin Id!"
        else:
            return "Invalid Board Id!"
    else:
        return "User not authorized"
Exemple #2
0
def deleteComment(userId,boardName,pinId):
    print
    '--in moo.deleteComment'
    global storage
    storage = Storage()
    bId = storage.getBoardId(boardName)
    couch = couchdb.Server()
    mydb = couch['userdb']
    board = couch['boards']
    pins= couch ['pinsdb']
    if userId in mydb:
        if bId in board:
            if pinId in pins:

               # desc=request.POST.get('description')

                #print desc
                global storage
                storage = Storage()
                pinId = storage.deleteComment(userId,bId,pinId)
                return pinId
            else:
                return "Pin not found!"

        else:
            return "Board not Found!"
    else:
        return "User Not Authorized!"
Exemple #3
0
def deleteBoard(userId,boardName):
    print '--in moo.deleteBoard'
    couch = couchdb.Server()
    mydb = couch['userdb']
    myboardDB = couch['boards']
    global storage
    storage = Storage()
    bId = storage.getBoardId(boardName)

    if userId in mydb:
        if bId in myboardDB:
            boardId = storage.deleteBoard(userId,bId)
        else:
            return "Board not Authorized!"
    else:
        return "User not authorized"
Exemple #4
0
def getBoardDetails(userId,boardName):
    print '--in moo.getBoardList'

    couch = couchdb.Server()
    myUserdb = couch['userdb']
    myboardDB = couch['boards']
    storage = Storage()
    bId = storage.getBoardId(boardName)

    if userId in myUserdb:
         if bId in myboardDB:
             doc = storage.viewBoard(bId)
             return doc
         else:
             return "Board Id does not exist"
    else:
        return "User not Authorized!"
Exemple #5
0
def viewAllPin(userId,boardName):
    print
    '--in moo.viewAllPins'
    couch = couchdb.Server()

    board = couch['boards']
    myUserdb = couch['userdb']
    global storage
    storage = Storage()
    bId = storage.getBoardId(boardName)

    if id in myUserdb:
        if bId in board:
            doc=storage.viewAllPins(id,bId)
            return doc
        else:
            return "Board Id not Found!"
    else:
        return "User Id Not Found!"
Exemple #6
0
def updateBoard(userId,boardName):
    print '--in moo.createBoard'
    global storage
    storage = Storage()
    couch = couchdb.Server()
    mydb = couch['userdb']
    myboardDB = couch['boards']
    bId = storage.getBoardId(boardName)
    if userId in mydb:
        if bId in myboardDB:
            bname = request.POST.get('name')
            bdesc = request.POST.get('boardDesc')
            category = request.POST.get('category')
            boardType = request.POST.get('isPrivate')

            boardId = storage.updateBoard(userId,bId, bname, bdesc, category, boardType)
            return boardId
        else:
            return "Board not Authorized!"
    else:
        return "User not authorized"
Exemple #7
0
def createPin(userId,boardName):
    print '--in moo.createBoard'
    print "id", userId

    couch = couchdb.Server()
    mydb = couch['userdb']
    board = couch['boards']
    global storage
    storage = Storage()
    bId = storage.getBoardId(boardName)
    if userId in mydb:
        if bId in board:
            pname=request.POST.get('pinName')
            pdesc = request.POST.get('pinDesc')
            image=request.POST.get('image')
            pinId = storage.insertPin(userId,boardName,pname,pdesc,image)
            return pinId
        else:
            return "Board not found!"

    else:
        return "User not Found!"
Exemple #8
0
def deletePin(userId,boardName,pinId):
    print
    '--in moo.viewAllPins'

    global storage
    storage = Storage()
    bId = storage.getBoardId(boardName)

    couch = couchdb.Server()
    mydb = couch['userdb']
    board = couch['boards']
    pin = couch['pinsdb']
    if userId in mydb:
        if bId in board:
            if pinId in pin:
               global storage
               storage = Storage()
               storage.deletePin(userId,bId,pinId)
            else:
                return "Pin not found!"
        else:
            return "Board not Found!"
    else:
        return "User Not Found!"
Exemple #9
0
def viewPin(userId,boardName,pinId):
    print
    '--in moo.viewAllPins'

    couch = couchdb.Server()
    mydb = couch['userdb']
    board = couch['boards']
    pins = couch['pinsdb']

    global storage
    storage = Storage()
    bId = storage.getBoardId(boardName)

    if userId in mydb:
        if bId in board:
            if pinId in pins:
                doc=storage.viewPin(userId,bId,pinId)
                return doc
            else:
                return "Pin not found!"
        else:
            return "Board not Found!"
    else:
        return "User Not Found!"