コード例 #1
0
ファイル: app.py プロジェクト: pnjha/DropBox
def search():

    userId = RetrieveSessionDetails('userId')
    fileName = request.form.get('fileName')

    print("sddfffffffffffffffffffffffffffffffffffffffffffff1",fileName)
    print("sddfffffffffffffffffffffffffffffffffffffffffffff2",userId)

    UserData = BusinessLayer.searchFile(userId,fileName)
    
    print("sddfffffffffffffffffffffffffffffffffffffffffffff",UserData)

    if UserData != None:

        userclassInstance = UserClass()
        userclassInstance.setUserDetails(RetrieveSessionDetails('userId'),
        RetrieveSessionDetails('userName'),"passwd","name","email","phone")
        userclassInstance.setCurrentFolderId("0")
        userclassInstance.setCurrentFolderName("Search Result")
        userclassInstance.setHomeFolderId(RetrieveSessionDetails('homeFolderId'))

        UserData['UserDetails'] = userclassInstance        
        print("Search Result: ",UserData['FileDetails'][0].filename)

        return render_template('index.html',**UserData)

    else:
        homeFolder = BusinessLayer.getHomeFolderId(userId)
        return redirect(url_for('index',folderId = homeFolder.folderid))
コード例 #2
0
def validate():
    print("-------Inside Validate-------")
    error = None
    # if request.method == 'GET':
    #     print("-------Inside Validate method GET-------")
    #     username = request.form.get('username')
    #     password = request.form.get('password')
    #     print("Username is: ", username, " and Password is: ",password)
    if request.method == 'POST':
        print("-------Inside Validate method POST-------")
        username = request.form.get('username')
        password = request.form.get('password')
        # print("Username is: ", username, " and Password is: ",password)

        UserData = BusinessLayer.ValidateUser(username, password)

        if ("Invalid Login Attempt" in UserData.values()):

            error = "Please check username or password !"
            return render_template("login.html", error=error)

        print("  #### ", UserData['UserDetails'].currentFolderId)

        AddToSession('userId', UserData['UserDetails'].userid)
        AddToSession('userName', UserData['UserDetails'].userName)
        AddToSession('currentFolderId',
                     UserData['UserDetails'].currentFolderId)
        AddToSession('homeFolderId', UserData['UserDetails'].HomeFolderId)
        AddToSession(
            'TotalSize',
            BusinessLayer.getTotalSize(UserData['UserDetails'].userid))

        foldername = UserData['UserDetails'].currentFolderName[:-1]

        AddToSession('currentFolderName', foldername)

        if 'InvalidLogin' in UserData:
            if UserData['InvalidLogin'] == 'Invalid Login Attempt':
                return render_template("login.html", error=error)
        else:
            print("---------User Validated------")
            userId = UserData['UserDetails'].userid
            print("Userid is: ", userId)

            homeFolder = BusinessLayer.getHomeFolderId(userId)
            print("HomeFolderId is: ", homeFolder.folderid)

            return redirect(url_for('index', folderId=homeFolder.folderid))
    else:
        return render_template('login.html')
コード例 #3
0
def search():

    userId = RetrieveSessionDetails('userId')
    fileName = request.form.get('fileName')

    if fileName == '':
        currentFolderId = RetrieveSessionDetails('currentFolderId')
        return redirect(url_for('index', folderId=currentFolderId))

    UserData = BusinessLayer.searchFile(userId, fileName)

    if UserData != None:
        # UserData['searchStatus'] = 'True'

        userclassInstance = UserClass()
        userclassInstance.setUserDetails(RetrieveSessionDetails('userId'),
                                         RetrieveSessionDetails('userName'),
                                         "passwd", "name", "email", "phone")
        userclassInstance.setCurrentFolderId("0")
        userclassInstance.setCurrentFolderName("Search Result")
        userclassInstance.setHomeFolderId(
            RetrieveSessionDetails('homeFolderId'))

        UserData['UserDetails'] = userclassInstance
        UserData["AllFilesource"] = "NotAllFileSource"
        UserData["sourceParameter"] = "searchSource"

        print("Search Result: ", UserData['FileDetails'][0].filename)
        return render_template('index.html', **UserData)
        # return redirect(url_for('indexSearch',folderId = homeFolder.folderid))

    else:
        homeFolder = BusinessLayer.getHomeFolderId(userId)
        # UserData['searchStatus'] = 'False'
        AddToSession('searchResult', 'False')
        return redirect(url_for('index', folderId=homeFolder.folderid))