def deletePropertyCategory():
    propertyCategoryDAO = PropertyCategoryDAO()
    propertyCategoryVO = PropertyCategoryVO()
    propertyCategoryVO.propertyCategoryId = request.args.get(
        'propertyCategoryId')
    propertyCategoryVO.propertyCategoryActiveStatus = 'deactive'

    propertyCategoryDAO.deletePropertyCategory(propertyCategoryVO)

    return redirect(url_for('viewPropertyCategory'))
def viewPropertyCategory():

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

    propertyCategoryDAO = PropertyCategoryDAO()

    propertyCategoryDict = propertyCategoryDAO.searchPropertyCategory()

    return render_template('admin/viewPropertyCategory.html',
                           propertyCategoryDict=propertyCategoryDict)
def loadPostProperty():
    if session['loginRole']!= 'user':
        return redirect(url_for('login'))

    propertyCategoryDAO = PropertyCategoryDAO()
    propertySubcategoryDAO = PropertySubcategoryDAO()

    propertyCategoryDict = propertyCategoryDAO.searchPropertyCategory()
    propertySubcategoryDict = propertySubcategoryDAO.searchPropertySubcategory()

    return render_template('user/propertyBasicDetails.html',propertyCategoryDict=propertyCategoryDict,propertySubcategoryDict=propertySubcategoryDict)
def editPropertyCategory():

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

    propertyCategoryDAO = PropertyCategoryDAO()
    propertyCategoryVO = PropertyCategoryVO()
    propertyCategoryVO.propertyCategoryId = request.args.get(
        'propertyCategoryId')
    propertyCategoryDict = propertyCategoryDAO.editPropertyCategory(
        propertyCategoryVO)

    return render_template('admin/editPropertyCategory.html',
                           propertyCategoryDict=propertyCategoryDict)
def editPropertySubcategory():

    propertyCategoryDAO = PropertyCategoryDAO()
    propertySubcategoryDAO = PropertySubcategoryDAO()
    propertySubcategoryVO = PropertySubcategoryVO()
    propertySubcategoryVO.propertySubcategoryId = request.args.get(
        'propertySubcategoryId')
    propertySubcategoryDict = propertySubcategoryDAO.editPropertySubcategory(
        propertySubcategoryVO)
    propertyCategoryDict = propertyCategoryDAO.searchPropertyCategory()

    return render_template(
        'admin/editPropertySubcategory.html',
        propertySubcategoryDict=propertySubcategoryDict,
        propertyCategoryDict=propertyCategoryDict,
        propertySubcategoryId=propertySubcategoryVO.propertySubcategoryId)
def updatePropertyCategory():

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

    propertyCategoryVO = PropertyCategoryVO()
    propertyCategoryDAO = PropertyCategoryDAO()

    propertyCategoryVO.propertyCategoryName = request.form[
        'propertyCategoryName']
    propertyCategoryVO.propertyCategoryDescription = request.form[
        'propertyCategoryDescription']
    propertyCategoryVO.propertyCategoryId = request.form['propertyCategoryId']

    propertyCategoryDAO.updatePropertyCategory(propertyCategoryVO)

    return redirect(url_for('viewPropertyCategory'))
def insertPropertyCategory():

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

    propertyCategoryVO = PropertyCategoryVO()
    propertyCategoryDAO = PropertyCategoryDAO()

    propertyCategoryVO.propertyCategoryName = request.form[
        'propertyCategoryName']
    propertyCategoryVO.propertyCategoryDescription = request.form[
        'propertyCategoryDescription']
    propertyCategoryVO.propertyCategoryActiveStatus = 'active'

    propertyCategoryDAO.insertPropertyCategory(propertyCategoryVO)

    return redirect(url_for('loadPropertyCategory'))
def loadPropertySubcategory():
    propertyCategoryDAO = PropertyCategoryDAO()
    propertyCategoryDict = propertyCategoryDAO.searchPropertyCategory()

    return render_template('admin/addPropertySubcategory.html',
                           propertyCategoryDict=propertyCategoryDict)