def insertDataset():

    try:
        if session['loginRole'] == 'admin':

            datasetVO = DatasetDAO()
            datasetDAO = DatasetDAO()
            UPLOAD_FOLDER = 'C:/Users/Admin/Desktop/admin/project/static/adminResources/dataset'

            app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

            file = request.files['file']
            print(file)

            filename = secure_filename(file.filename)
            # print(filename)

            filepath = os.path.join(app.config['UPLOAD_FOLDER'])
            # print(filepath)

            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

            datasetVO.datasetFilename = filename
            datasetVO.datasetFilepath = filepath
            datasetVO.datasetDescription = request.form['datasetDescription']
            datasetVO.datasetActiveStatus = 'active'

            datasetDAO.insertDataset(datasetVO)

        return redirect(url_for('loadDataset'))
    except:
        return redirect(url_for('login'))
Пример #2
0
def adminInsertDataset():
    try:
        if adminLoginSession() == 'admin':

            UPLOAD_FOLDER = 'project/static/adminResources/dataset/'  # setting path of storage data
            app.config[
                'UPLOAD_FOLDER'] = UPLOAD_FOLDER  # update config path of folder
            datasetVO = DatasetVO()
            datasetDAO = DatasetDAO()

            file = request.files['file']  # getting filename from addDataset
            datasetFilename = secure_filename(file.filename)
            datasetFilepath = os.path.join(
                app.config['UPLOAD_FOLDER'])  # setting value in variable
            file.save(os.path.join(datasetFilepath, datasetFilename)
                      )  # saving file in dataset folder with filename

            datasetVO.datasetFilename = datasetFilename  # saving filename in database
            todayDate = date.today()
            datasetVO.uploadDate = todayDate  # saving current date in database
            nowTime = datetime.now()
            datasetVO.uploadTime = nowTime.strftime(
                "%H:%M:%S")  # saving current date in database
            filepath = datasetFilepath.replace("project", "..")
            datasetVO.datasetFilePath = str(
                filepath)  # saving filepath in database

            datasetDAO.insertDataset(datasetVO)

            return redirect(url_for('adminViewDataset'))
        else:
            adminLogoutSession()
    except Exception as ex:
        print(ex)
Пример #3
0
def adminDeleteDataset():
    try:
        if adminLoginSession() == 'admin':
            datasetVO = DatasetVO()

            datasetDAO = DatasetDAO()

            datasetId = request.args.get('datasetId')

            datasetVO.datasetId = datasetId
            datasetList = datasetDAO.deleteDataset(datasetVO)

            print(datasetList)

            datasetFileName = datasetList.datasetFileName
            datasetFilePath = datasetList.datasetFilePath

            fullPath = datasetFilePath.replace('..',
                                               'project') + datasetFileName
            os.remove(fullPath)

            return redirect(url_for('adminViewDataset'))
        elif adminLoginSession() == 'user':
            return adminLogoutSession()
    except Exception as ex:
        print(ex)
def adminDeleteDataset():
    try:
        if adminLoginSession() == 'admin':
            datasetVO = DatasetVO()

            datasetDAO = DatasetDAO()

            datasetId = request.args.get('datasetId')
            datasetFileName = request.args.get('datasetFileName')

            print(datasetFileName)

            datasetVO.datasetId = datasetId
            datasetVO.datasetFileName = datasetFileName

            os.remove(
                os.path.join(app.config['UPLOAD_FOLDER'], datasetFileName))
            datasetDAO.deleteDataset(datasetVO)

            return redirect(url_for('adminViewDataset'))
        else:
            return adminLogoutSession()

    except Exception as ex:
        print(ex)
def adminInsertDataset():
    try:
        if adminLoginSession() == 'admin':
            datasetVO = DatasetVO()
            datasetDAO = DatasetDAO()

            file = request.files['file']
            print(file)

            datasetFileName = secure_filename(file.filename)
            print(datasetFileName)

            datasetFilePath = os.path.join(app.config['UPLOAD_FOLDER'])
            print(datasetFilePath)

            file.save(os.path.join(datasetFilePath, datasetFileName))

            datasetUploadDate = datetime.date(datetime.now())
            datasetUploadTime = datetime.time(datetime.now())

            datasetVO.datasetFileName = datasetFileName
            datasetVO.datasetFilePath = datasetFilePath.replace("project", "..")

            datasetVO.datasetUploadDate = datasetUploadDate
            datasetVO.datasetUploadTime = datasetUploadTime

            datasetDAO.insertDataset(datasetVO)

            return redirect(url_for('adminViewDataset'))

        else:
            return adminLogoutSession()

    except Exception as ex:
        print(ex)
Пример #6
0
def adminDeleteDataset():
    try:
        if adminLoginSession() == 'admin':
            datasetVO = DatasetVO()

            datasetDAO = DatasetDAO()

            datasetId = request.args.get('datasetId')

            datasetVO.datasetId = datasetId

            datasetlist = datasetDAO.deleteDataset(datasetVO)

            path = datasetlist.datasetFilePath.replace(
                '..', 'project') + datasetlist.datasetFilename
            try:
                os.remove(path)
            except Exception as ex:
                print(ex)

            return redirect(url_for('adminViewDataset'))
        else:
            adminLogoutSession()
    except Exception as ex:
        print(ex)
Пример #7
0
def insertDataset():
    try:
        if session['sessionloginDict']['loginRole'] == 'admin':
            datasetDAO=DatasetDAO()
            datasetVO=DatasetVO()

            UPLOAD_FOLDER = r'C:\Users\User\PycharmProjects\gbsc\project\static\dataset'
            app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

            print("kreykfjsdkmlerksd.j,m")
            file = request.files['datasetFile']


            print(file)
            datasetVO.datasetName = secure_filename(file.filename)

            datasetVO.datasetPath = os.path.join(app.config['UPLOAD_FOLDER'])

            file.save(os.path.join(app.config['UPLOAD_FOLDER'],datasetVO.datasetName))
            datasetVO.datasetDescription = request.form['datasetDescription']
            datasetVO.datasetActiveStatus='active'
            datasetDAO.insertDataset(datasetVO)

            return  render_template("admin/addDataset.html")
        else:
            flash('you are not admin !, Please Login as Admin. ', 'danger')
            return redirect(url_for('loadLogin'))
    except:
        flash('Plese Login First !', 'danger')
        return redirect(url_for('loadLogin'))
Пример #8
0
def loadIndex():
    try:
        if session['loginRole'] == 'admin':
            registerDAO = RegisterDAO()
            datasetDAO = DatasetDAO()
            blogDAO = BlogDAO()
            videoDAO = VideoDAO()
            complaintDAO = ComplaintDAO()
            feedbackDAO = FeedbackDAO()
            predictDAO = PredictDAO()

            userdict = registerDAO.countuser()
            companydict = datasetDAO.countcompany()
            blogDict = blogDAO.countBlog()
            videoDict = videoDAO.countVideo()
            complaintDict = complaintDAO.countComplaint()
            feedbackDict = feedbackDAO.countfeedback()
            predictDict = predictDAO.searchDPrediction()

            return render_template('admin/index.html',
                                   userdict=userdict,
                                   companydict=companydict,
                                   blogDict=blogDict,
                                   videoDict=videoDict,
                                   feedbackDict=feedbackDict,
                                   complaintDict=complaintDict,
                                   predictDict=predictDict)
        else:
            blogDAO = BlogDAO()
            blogDict = blogDAO.searchBlog()
            return render_template('user/index.html', blogDict=blogDict)
    except:
        return render_template('admin/login.html')
def insertDataset():

    try:
        if session['loginRole'] == 'admin':
            datasetVO = DatasetVO()
            datasetDAO = DatasetDAO()
            UPLOAD_FOLDER = 'C:/project/admin/project/static/adminResources/dataset'

            app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

            file = request.files['datasetFile']

            filename = secure_filename(file.filename)

            filepath = os.path.join(app.config['UPLOAD_FOLDER'])

            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            datasetVO.datasetFilename = filename
            datasetVO.datasetFilepath = filepath
            datasetVO.datasetDescription = request.form['datasetDescription']
            datasetVO.datasetActiveStatus = 'active'

            datasetDAO.insertDataset(datasetVO)
            return render_template('admin/addDataset.html')
        else:
            return render_template('admin/login.html')
    except:
        return render_template('admin/login.html')
Пример #10
0
def userInsertDataset(file):
    try:
        if adminLoginSession() == 'user':
            datasetVO = DatasetVO()
            datasetDAO = DatasetDAO()

            file = file  # getting filename from addDataset
            datasetFilename = secure_filename(file.filename)
            datasetFilepath = os.path.join(
                app.config['UPLOAD_FOLDER'])  # setting value in variable
            file.save(os.path.join(datasetFilepath, datasetFilename))

            datasetVO.datasetFilename = datasetFilename  # saving filename in database
            todayDate = date.today()
            datasetVO.uploadDate = todayDate  # saving current date in database
            nowTime = datetime.now()
            datasetVO.uploadTime = nowTime.strftime(
                "%H:%M:%S")  # saving current date in database
            filepath = datasetFilepath.replace("project", "..")
            datasetVO.datasetFilePath = str(
                filepath)  # saving filepath in database
            filepath = str(filepath)

            datasetDAO.insertDataset(datasetVO)
            return datasetFilename, filepath
        else:
            adminLogoutSession()
    except Exception as ex:
        print(ex)
Пример #11
0
def adminDeleteDataset():
    try:
        if adminLoginSession() == "admin":
            datasetVO = DatasetVO()

            datasetDAO = DatasetDAO()

            datasetId = request.args.get('datasetId')

            datasetVO.datasetId = datasetId

            datasetList = datasetDAO.deleteDataset(datasetVO)

            datasetFileName = datasetList.datasetFileName
            datasetFilePath = datasetList.datasetFilePath

            path = datasetFilePath.replace("..", "project") + datasetFileName

            os.remove(path)

            return redirect(url_for('adminViewDataset'))
        else:
            return adminLogoutSession()
    except Exception as ex:
        print(ex)
def viewDataset():

    if session['loginRole'] != 'admin':
        return redirect(url_for('login'))

    datasetDAO = DatasetDAO()
    datasetDict = datasetDAO.searchDataset()
    return render_template('admin/viewDataset.html', datasetDict=datasetDict)
Пример #13
0
def adminViewDataset():
    try:
        if adminLoginSession() == 'admin':
            datasetDAO = DatasetDAO()
            datasetVOList = datasetDAO.viewDataset()
            return render_template('admin/viewDataset.html',
                                   datasetVOList=datasetVOList)
        else:
            adminLogoutSession()
    except Exception as ex:
        print(ex)
def loadManagePrediction():
    try:
        if session['loginRole'] == 'admin':
            datasetDAO = DatasetDAO()
            datasetDict = datasetDAO.searchDataset()
            return render_template('admin/managePrediction.html',
                                   datasetDict=datasetDict)
        else:
            return render_template('admin/login.html')
    except:
        return render_template('admin/login.html')
def viewDataset():

    try:
        if session['loginRole'] == 'admin':
            datasetDAO = DatasetDAO()
            datasetDict = datasetDAO.searchDataset()
            return render_template('admin/viewDataset.html',
                                   datasetDict=datasetDict)
        else:
            return render_template('admin/login.html')
    except:
        return render_template('admin/login.html')
def loadPredictNow():

    try:
        if session['loginRole'] == 'admin':
            return render_template('admin/login.html')
        else:
            datasetDAO = DatasetDAO()
            companyDict = datasetDAO.selectcompany()
            return render_template('user/predictNow.html',
                                   companyDict=companyDict)
    except:
        return render_template('admin/login.html')
def deleteDataset():

    if session['loginRole'] != 'admin':
        return redirect(url_for('login'))

    datasetVO = DatasetVO()
    datasetDAO = DatasetDAO()
    datasetVO.datasetId = request.args.get('datasetId')
    datasetVO.datasetActiveStatus = 'deactive'
    datasetDAO.deleteDataset(datasetVO)

    return redirect(url_for('viewDataset'))
Пример #18
0
def viewDataset():
    try:
        if session['sessionloginDict']['loginRole'] == 'admin':
            datasetDAO=DatasetDAO()
            datasetVO=DatasetVO()
            datasetDict=datasetDAO.viewDataset(datasetVO)
            return render_template('admin/viewDataset.html',datasetDict=datasetDict)
        else:
            flash('you are not admin !, Please Login as Admin. ', 'danger')
            return redirect(url_for('loadLogin'))
    except:
        flash('Plese Login First !', 'danger')
        return redirect(url_for('loadLogin'))
def deleteDataSet():

    try:
        if session['loginRole'] == 'admin':
            datasetVO = DatasetVO()
            datasetDAO = DatasetDAO()
            datasetVO.datasetId = request.args.get('datasetId')
            datasetVO.datasetActiveStatus = 'deactive'
            datasetDAO.deleteDataset(datasetVO)
            return redirect(url_for('viewDataset'))
        else:
            return render_template('admin/login.html')
    except:
        return render_template('admin/login.html')
Пример #20
0
def deleteDataset():
    try:
        if session['sessionloginDict']['loginRole'] == 'admin':
            datasetDAO=DatasetDAO()
            datasetVO=DatasetVO()
            datasetVO.datasetId=request.args.get('datasetId')
            datasetVO.datasetActiveStatus="deactive"
            datasetDAO.deleteDataset(datasetVO)
            return redirect(url_for("viewDataset"))
        else:
            flash('you are not admin !, Please Login as Admin. ', 'danger')
            return redirect(url_for('loadLogin'))
    except:
        flash('Plese Login First !', 'danger')
        return redirect(url_for('loadLogin'))
def adminDeleteDataset():
    try:
        if adminLoginSession() == 'admin':
            datasetVO = DatasetVO()

            datasetDAO = DatasetDAO()

            datasetId = request.args.get('datasetId')

            print('datasetId::', datasetId)

            datasetVO.datasetId = datasetId

            datasetDAO.deleteDataset(datasetVO)

            return redirect(url_for('adminViewDataset'))

        else:
            return adminLogoutSession()
    except Exception as ex:
        print(ex)