
#    Imports
 
import os
import pymongo
from flask import Flask, render_template, url_for, request, redirect, flash
from flask_bootstrap import Bootstrap
from os import path
from bson.objectid import ObjectId
# Load Environment Variables
'''
Please ensure that the environment variable has
been set on your local system.
If on heroku set the app system variables!!!
'''
MONGODB_URI = os.environ.get("MONGO_URI")
DBS_NAME = "rmrdb"
COLLECTION_USER_NAME = "users"
COLLECTION_REVIEWS = "reviews"

# Database Connection
def mongo_connect(url):
    try:
        conn = pymongo.MongoClient(url)
        print("Mongo is connected!")
        return conn
    except pymongo.errors.ConnectionFailure as e:
        print("Could not connect to MongoDB: %s") % e
conn = mongo_connect(MONGODB_URI)  # Connect database with environment string
coll_users = conn[DBS_NAME][COLLECTION_USER_NAME]
coll_reviews = conn[DBS_NAME][COLLECTION_REVIEWS]
app = Flask(__name__)
Bootstrap(app)
 
#     G L O B A L - V A R S - S E C T I O N                          
 
users = {}
# Footer Message
siteText = {
    "footer-message": " ~ Copyright 2020, Code-Institute Milestone\
         Project-3 - Clement Ofoedu ~ ",
}
# Legal Message
legalFooter = {
    "legal-message": "Blockbusters McGuffins and Moes is a trademarked\
    operation title of BAA holdings.  All rights reserved. Note all\
    views made on this site are the views of their respective reviewers\
    and are not those of the site owners or associated business. Images\
    presented here are purely for demonstration purposes. The site does\
    not condone foul or incendiary language. All our reviewers are mandated\
    to present balanced reviews with citations supporting their review. This\
     site is a demo site for the purpose of a course. You will not receive any\
    emails in response to registration. Registering with the site will not\
    give you access to posting reviews, this ability will be activated manually\
     by those that are responsible for maintain the site. The site owners\
     reserve the right to change the site contents or its availability at any time."
}
rev_result = {}
rev_bag = []
crv_em = ""  # current reviewer email
updaterev = ""
ul=0

 
#     M A I N  - C O D E - S E C T I O N                             
 
'''
CHECK FOR DUPLICATE OBJECT ID
'''
def checkDup(id):
    matchid = 0
    store = coll_reviews.find()
    for stuff in store:
        if id == stuff['_id']:
            matchid = 1
            return matchid
 
#     M A I N  - VIEWS - S E C T I O N                              
 
@app.route('/')
def index():
    return render_template('index.html',\
    page='Blockbusters, McGuffins & Moes',\
    fm=siteText["footer-message"], lg=legalFooter["legal-message"])


# About
@app.route('/about')
def about():
    '''
    #ABOUT PAGE VIEW
    '''
    return render_template('about.html', page='About Us',\
    fm=siteText["footer-message"], lg=legalFooter["legal-message"])


@app.route('/contact', methods=["GET", "POST"])
def contact():
    # CONTACT PAGE VIEW
    if request.method == "POST":
        return redirect(url_for('contactSuccessOk'))
    return render_template('contact.html', page='Contact us',\
    fm=siteText["footer-message"], lg=legalFooter["legal-message"])


# Contact Success
@app.route('/contact-success', methods=["GET", "POST"])
def contactSuccessOk():
     
    # VIEW SHOWN ON COMPLETION & POST OF CONTACT FORM
    
    return render_template('contact-success.html',\
    page='Thank You for contacting us!', fm=siteText["footer-message"],\
    lg=legalFooter["legal-message"])


@app.route('/contribute', methods=["GET", "POST"])
def contribute():
    if request.method == "POST":
        return redirect(url_for('contributeS'))
    return render_template('contribute.html',\
    page='Contribute Movie Suggestions For Review',\
    fm=siteText["footer-message"], lg=legalFooter["legal-message"])


# Contribute Success
@app.route('/contribute-success', methods=["GET", "POST"])
def contributeS():
    return render_template('contribute-success.html',\
    page='Contribution success!', fm=siteText["footer-message"],\
    lg=legalFooter["legal-message"])


@app.route('/search', methods=["GET", "POST"])
def search():
    users_with_reviews=[]
    all_reviews=[]
    all_users=coll_users.find()
    '''
     # Grab Release Dates from Reviews
    '''
    datefound=[]
    dates=[]
    all_reviews=coll_reviews.find()
    for each in all_reviews:
        if each['m-sub-title'] !="":
            dt=each['m-sub-title']
            if  not(dt in datefound):
                dates.append(dt)
                datefound.append(dt)
    # Start search when
    if request.method == "POST":
        rev_results = []
        ss=""
        joiner=" + "
        limit_value = int(request.form.get('s-count'))
        # Search criteria
        search_tit = request.form["s-title"]
        search_sub = request.form["s-sub-title"]
        search_rev = request.form["s-reviewer-name"]
        search_gen = request.form["s-genre"]
        search_stars = request.form["s-stars"]
        search_m = "none"
        


        #TITLE
        if search_tit != "":
            ss=ss+search_tit+joiner
            rev_results =\
            coll_reviews.find\
            ({"$text": {"$search": search_tit}}).limit(limit_value)
            return render_template('search-results.html',\
            rev_results=rev_results, fm=siteText["footer-message"],\
            page='Search Result Page..', lg=legalFooter["legal-message"])
        
        #RELEASE DATE
        if search_sub != "":
            search_tit = ""
            search_sub = search_sub
            search_rev = ""
            search_gen = ""
            search_stars = ""
            rev_results =\
            coll_reviews.find({'m-sub-title': search_sub }).limit(limit_value )
            return render_template('search-results.html',\
            rev_results=rev_results, fm=siteText["footer-message"],\
            page='Search Result Page..', lg=legalFooter["legal-message"])

         
        #SEARCH REVIEWER
        if search_rev != "":
            search_tit = ""
            search_sub = ""
            search_rev = search_rev
            search_gen = ""
            search_stars = ""
            rev_results =\
            coll_reviews.find({"$text": {"$search": search_rev }})\
            .limit(limit_value)
            return render_template('search-results.html',\
            rev_results=rev_results, fm=siteText["footer-message"],\
            page='Search Result Page..', lg=legalFooter["legal-message"])
        

        #SEARCH GENRE
        if search_gen != "":
            search_tit =""
            search_sub ="" 
            search_rev =""
            search_gen =search_gen
            search_stars =""
            rev_results =\
                coll_reviews.find({'m-genre': search_gen }).limit(limit_value)
            return render_template('search-results.html',\
                rev_results=rev_results, fm=siteText["footer-message"],\
                    page='Search Result Page..',\
                        lg=legalFooter["legal-message"])
       

        #SEARCH STARS
        if search_stars != "":
            search_tit =""
            search_sub ="" 
            search_rev =""
            search_gen ="" 
            search_stars = search_stars
            rev_results =\
            coll_reviews.find({'m-stars': search_stars }).limit(limit_value)

            return render_template('search-results.html',\
                rev_results=rev_results, fm=siteText["footer-message"],\
                    page='Search Result Page..', lg=legalFooter["legal-message"])
         

        #DEFAULT SEARCH ON BLANK PARAMS
        if search_tit == "" and search_sub == "" and search_gen == "" and\
            search_rev == "" and search_stars == "":
            
            search_m = "active"
            rev_results =\
            coll_reviews.find({'m-process': search_m}).limit(limit_value)
        return render_template('search-results.html', rev_results=rev_results,\
            fm=siteText["footer-message"], page='Search Result Page..',\
                lg=legalFooter["legal-message"])
    
    return render_template('search.html', dates=dates, page='Search',\
        fm=siteText["footer-message"], lg=legalFooter["legal-message"],\
        all_users=all_users, users_with_reviews=users_with_reviews )


# Search Result
@app.route('/search-results', methods=["GET", "POST"])
def searchResults():
    '''
    #SEARCH RESULTS PAGE!
    '''
    return render_template('search-results.html',\
        page='Search Result(s) Page..', fm=siteText["footer-message"],\
        lg=legalFooter["legal-message"])


@app.route('/register', methods=["GET", "POST"])
def register(): 
    # Register Users .... Change the role default to Member if you wish\
    #  everyone to be able to submit a review
 
    if request.method == "POST":
        post = {
            "my-info": request.form["info"],
            "username": request.form["username"],
            "f-name": request.form['f-name'],
            "l-name": request.form['l-name'],
            "e-mail": request.form['e-mail'],
            "password": request.form['password'],
            "role": "user",
            "a-state": "no"
        }
        found = False
        unlock = False
        documents = coll_users.find()
        found = 0
        for entry in documents:
            if (entry["e-mail"]).upper() == (request.form["e-mail"]).upper():
                found = 1
                print("Email Already Exists")
                return redirect(url_for('dupEmail'))

            if ("," in request.form['e-mail']):
                return redirect(url_for('dupEmail'))



        for entry in documents:
            if entry['e-mail'] == request.form['e-mail']\
                and entry['password'] == request.form['password']:
                unlock = True
            if entry['e-mail'] == request.form['e-mail']:
                found = True
            # Login success
        if unlock == True:
            return redirect(url_for('loginSuccess'))
        elif found == True:
            return redirect(url_for('errorem'))

        elif entry['e-mail'] != request.form['e-mail']:
            coll_users.insert_one(post)
            return redirect(url_for('index'))


    return render_template('register.html',\
        page='Member Registration Request',\
            fm=siteText["footer-message"],\
                users=users, lg=legalFooter["legal-message"])


@app.route('/duplicate-email')
def dupEmail():
    '''
    # Duplicate Email Address Found
    Email address has already been used in the database record
    '''
    return render_template('duplicate-email.html',\
         page='Error - Duplicate Email!', methods=["GET", "POST"],\
            fm=siteText["footer-message"], lg=legalFooter["legal-message"])


@app.route('/promoteuser', methods=["GET", "POST"])
def promoteUser():
    '''
    PROMOTE USER VIEW
    '''
    if request.method == "POST":
        users = coll_users.find()
        fem = request.form['e-mail']
        for user in users:
            uUsername = user['username']
            uFname = user['f-name']
            uLname = user['l-name']
            uEmail = user['e-mail']
            uPassword = user['password']
            uRole = user['role']
            aff_state = request.form['a-state']
            if fem.upper() == uEmail.upper() and aff_state.upper() == "-"\
                and uRole == "user":
                print("<<>>"+fem.upper())
                nw = {
                    "$set": {
                        "username": uUsername,
                        "f-name": uFname,
                        "l-name": uLname,
                        "e-mail": uEmail,
                        "password": uPassword,
                        "role": 'Admin',
                        "a-state": "no"
                    }
                }
                coll_users.update_one(user, nw)
                print("DONE")
                return redirect(url_for('promoteUserS'))
            if fem.upper() == uEmail.upper() and uRole == "Admin"\
                and aff_state.upper() == "YES":
                print("+//+"+aff_state)
                nw = {
                    "$set": {
                        "username": uUsername,
                        "f-name": uFname,
                        "l-name": uLname,
                        "e-mail": uEmail,
                        "password": uPassword,
                        "role": 'Admin',
                        "a-state": "Yes"
                    }
                }
                coll_users.update_one(user, nw)
                return redirect(url_for('promoteUserS'))
    return render_template('promoteuser.html',\
        page="Grant - Poster Privilege", Methods=["GET", "POST"],\
        fm=siteText["footer-message"], lg=legalFooter["legal-message"])


@app.route('/makeadmin-success', methods=["GET", "POST"])
def promoteUserS():
    # PROMOTE USER SUCCESS OK! ..Successfully converted standard user to an\
    #  Admin, or added Affiliate pass-thru link ability
    return render_template('promoteuser-success.html',\
        page="Promote User - Success", Methods=["GET", "POST"],\
        fm=siteText["footer-message"], lg=legalFooter["legal-message"])


@app.route('/member', methods=["GET", "POST"])
def member():
    usersdb = coll_users.find()

    #INSERTION OF NEW MOVIE REVIEW VIEW PAGE!
    if request.method == "POST":

        reviews = {
                "m-title": request.form["m-title"].upper(),
                "m-sub-title": request.form["m-sub-title"].upper(),
                "m-genre": request.form["m-genre"],
                "m-image-link": request.form["m-image-link"],
                "m-synopsis": request.form["m-synopsis"],
                "m-reviewer-name": request.form["r-name"].upper(),
                "m-review-date": request.form["r-date"].upper(),
                "m-stars": request.form["m-stars"].upper(),
                "m-sc-review": request.form["sc-review"],
                "m-sc-example": request.form["sc-example"],
                "m-ac-review": request.form["ac-review"],
                "m-ac-example": request.form["ac-example"],
                "m-te-review": request.form["te-review"],
                "m-te-example": request.form["te-example"],
                "m-so-review": request.form["so-review"],
                "m-so-example": request.form["so-example"],
                "m-summary": request.form["su-review"],
                "m-affiliate-link": request.form["m-af-link"],
                "m-email": request.form["e-mail"],
                "m-process": "active",
            }


        total_users = coll_users.find()  # Grab User Database
        for auser in total_users:


            user_database_email = (auser['e-mail']).upper()\
                 #...net user in database profiles
            users_database_password = auser['password']\
                 #...next user password in database profiles

            review_user = (request.form.get('e-mail')).upper()\
                #... email entered in form
            user_form_password = request.form.get('password')\
                #... password entered on form



            if user_database_email == review_user and users_database_password\
                != user_form_password:
                return redirect(url_for('loginFailure')) # FAILURE!!!!
 


            if user_database_email == review_user and users_database_password\
                 == user_form_password and auser['role'] == "Admin":
                print("")

                #INC AFF-LINK
                if (auser['a-state']).upper() =='YES':
                    coll_reviews.insert_one(reviews)
                    return render_template(url_for('memberSubmitOk'),\
                        page='Member Review Submission OK!',\
                            fm=siteText["footer-message"])

                # REMOVE AFF-LINK
                if (auser['a-state']).upper() =='NO':
                    reviews["m-affiliate-link"] = "#"
                    coll_reviews.insert_one(reviews)
                    return render_template(url_for('memberSubmitOk'),\
                        page='Member Review Submission OK!',\
                        fm=siteText["footer-message"])

  
    return render_template('member.html', page='Member Add Review - Page',\
         methods=["GET", "POST"], fm=siteText["footer-message"],\
        lg=legalFooter["legal-message"], usersdb=usersdb )


@app.route('/member_d', methods=["GET", "POST"])
def member_d():
    return render_template('member_d.html', page='Member - Delete Page',\
        methods=["GET", "POST"], fm=siteText["footer-message"],\
            rev_bag=rev_bag, lg=legalFooter["legal-message"])


@app.route('/delete-selected', methods=["GET", "POST"])
def deleteSelected():
    return render_template('delete-selected.html',\
        page='Member - Delete Page', methods=["GET", "POST"],\
        fm=siteText["footer-message"],\
        rev_bag=rev_bag, lg=legalFooter["legal-message"])


@app.route('/member_u.html', methods=["GET", "POST"])
def member_u():
    '''
    ** MEMBER REVIEW UPDATE  VIEW **
    '''
    return render_template('member_u.html',\
        page='Member - Update / Delete Page',\
        methods=["GET", "POST"], fm=siteText["footer-message"],\
        lg=legalFooter["legal-message"])


@app.route('/member-options', methods=["GET", "POST"])
def memberOptions():
    unlock = False
    rev_bag = []
    crv = {}
    # GET REVIEWS
    if request.method == "POST" and\
        request.form.get('user-options') == "None":
        movies = coll_reviews.find()  # get movie collection
        documents = coll_users.find()  # get users collection
        for u_cred in documents:
            users = {
                "u_my_info": u_cred["my-info"],
                "u_username": u_cred['username'],
                "u_f_name": u_cred['f-name'],
                "u_l_name": u_cred['l-name'],
                "u_email": u_cred['e-mail'],
                "u_password": u_cred['password'],
                "u_role": u_cred['role'],
                "u_state": u_cred['a-state'],
            }
            unlock = False
            crv_em = request.form['e-mail']
            uem = users['u_email']
            rem = request.form['e-mail']
            uem = uem.upper()
            rem = rem.upper()


            if uem == rem and users['u_password'] == request.form['password']\
                and request.form['user-options'] == 'None' and users['u_role']\
                == 'Admin':
                unlock = True
                try:
                    users['u_password'] == request.form['password']
                except:
                    return redirect(url_for('memberOptions'))
                for mr in movies:
                    mem = mr['m-email']
                    mem = mem.upper()
                    crv_em = crv_em.upper()
                    if mem == crv_em and unlock == True:
                        rev_bag.append(mr)

                return render_template('member-options-gr.html',\
                    crv_em=crv_em, page='Member Maintenance Page!',\
                    fm=siteText["footer-message"], rev_bag=rev_bag,\
                    unlock=unlock, lg=legalFooter["legal-message"])
            
            elif uem == rem and users['u_password']\
                != request.form['password']:
                return redirect(url_for('loginFailure'))
    

    # DELETE REVIEWS
    if request.method == "POST"\
        and request.form.get('user-options') == "Delete":
        movies = coll_reviews.find()  # get movie collection
        documents = coll_users.find()  # get users collection
        for u_cred in documents:
            users = {
                "u_my_info": u_cred["my-info"],
                "u_username": u_cred['username'],
                "u_f_name": u_cred['f-name'],
                "u_l_name": u_cred['l-name'],
                "u_email": u_cred['e-mail'],
                "u_password": u_cred['password'],
                "u_role": u_cred['role'],
                "u_state": u_cred['a-state'],
            }
            unlock = False
            uem = (users['u_email']).upper()
            rem = (request.form['e-mail']).upper()
            # uem = uem.upper()
            # rem = rem.upper()
            crv_em = request.form['e-mail']

          
            if uem == rem and users['u_password'] == request.form['password']\
                and request.form['user-options'] == 'Delete' and\
                users['u_role'] == 'Admin':
                unlock = True


                try:
                    updaterev = request.form['movie-list']
                except:
                    return redirect(url_for('memberOptions'))
                deleterev = request.form['movie-list']
                coll_reviews.delete_one({'_id': ObjectId(deleterev)})
                print("DELETED REVIEW!!")
                print(deleterev)
                return render_template('member-options-gr.html',\
                    page='Member Maintenance Page!',\
                    fm=siteText["footer-message"],\
                    lg=legalFooter["legal-message"],\
                    rev_bag=rev_bag, unlock=unlock)
            
            if uem == rem and users['u_password'] != request.form['password']\
                and request.form['user-options'] == 'Delete' and\
                users['u_role'] == 'Admin':
                return redirect(url_for('loginFailure'))


    if request.method == "POST" and\
        request.form.get('user-options') == "Delete":
        movies = coll_reviews.find()  # get movie collection ....@
        documents = coll_users.find()  # get users collection
        for u_cred in documents:
            users = {
                "u_my_info": u_cred["my-info"],
                "u_username": u_cred['username'],
                "u_f_name": u_cred['f-name'],
                "u_l_name": u_cred['l-name'],
                "u_email": u_cred['e-mail'],
                "u_password": u_cred['password'],
                "u_role": u_cred['role'],
                "u_state": u_cred['a-state'],
            }
            unlock = False
            uem = users['u_email']
            rem = request.form['e-mail']
            uem = uem.upper()
            rem = rem.upper()
            crv_em = request.form['e-mail']

            if uem == rem and users['u_password'] != request.form['password']\
                and request.form['user-options'] == 'Delete' and\
                users['u_role'] == 'Admin':
                
                return render_template('member-options.html',\
                page='Member Maintenance Page!',\
                fm=siteText["footer-message"],\
                lg=legalFooter["legal-message"],\
                rev_bag=rev_bag, unlock=unlock)
 

    # UPDATE REVIEWS
    if request.method == "POST" and\
        request.form.get('user-options') == "Update":
        movies = coll_reviews.find()  # get movie collection
        documents = coll_users.find()  # get users collection

        for u_cred in documents:
            users = {
                "u_my_info": u_cred["my-info"],
                "u_username": u_cred['username'],
                "u_f_name": u_cred['f-name'],
                "u_l_name": u_cred['l-name'],
                "u_email": u_cred['e-mail'],
                "u_password": u_cred['password'],
                "u_role": u_cred['role'],
                "u_state": u_cred['a-state'],
            }
            unlock = False
            crv_em = request.form['e-mail']


            if (users['u_email']).upper() ==\
                (request.form.get('e-mail')).upper()\
                and users['u_password'] != request.form['password']\
                and request.form['user-options'] == 'Update' and\
                users['u_role'] == 'Admin':
                return redirect(url_for('loginFailure'))


            if users['u_role'] == 'Admin' and\
                request.form['user-options'] == "Update":
                unlock = True
                movies = coll_reviews.find()


                userdb=coll_users.find()
                trip=0
                for user in userdb:
                    if (user['e-mail']).upper() ==\
                    (request.form.get('e-mail')).upper():
                        trip=1    
                if trip==0:
                    return redirect(url_for('loginFailure'))
                

                try:
                    updaterev = request.form['movie-list']
                except:
                    return redirect(url_for('memberOptions'))
                
                
                for mr in movies:
                    updaterev = request.form['movie-list']
                    with open("templates/crvid","w") as f:
                        f.write(updaterev)


                x = coll_reviews.find_one({"_id": ObjectId(updaterev)})
                # Grab What is in Database
                crv = {
                    "m_title": x['m-title'],
                    "m_sub_title": x['m-sub-title'],
                    "m_genre": x['m-genre'],
                    "m_image_link": x['m-image-link'],
                    "m_synopsis": x['m-synopsis'],
                    "m_reviewer_name": x['m-reviewer-name'],
                    "m_review_date": x['m-review-date'],
                    "m_stars": x['m-stars'],
                    "m_sc_review": x['m-sc-review'],
                    "m_sc_example": x['m-sc-example'],
                    "m_ac_review": x['m-ac-review'],
                    "m_ac_example": x['m-ac-example'],
                    "m_te_review": x['m-te-review'],
                    "m_te_example": x['m-te-example'],
                    "m_so_review": x['m-so-review'],
                    "m_so_example": x['m-so-example'],
                    "m_summary": x['m-summary'],
                    "m_affiliate_link": x['m-affiliate-link'],
                    "m_email": x['m-email'],
                    "m_process": 'active',
                }
                return render_template('update-sheet.html',\
                page='Member Update Sheet', crv_em=crv_em,\
                fm=siteText["footer-message"],\
                lg=legalFooter["legal-message"],\
                rev_bag=rev_bag,  updaterev=updaterev,\
                crv=crv, documents=documents )
    

    # UPDATE INSERT
    if request.method == "POST" and request.form.get('confirm') != "None":

        userdb=coll_users.find()
        trip=0
        for user in userdb:
            if (user['e-mail']).upper() == (request.form.get('e-mail')).upper():
                trip=1    
        if trip==0:
            return redirect(url_for('loginFailure'))
        

        try:
            m_title = request.form.get('m-title')
        except:
            redirect(url_for('loginFailure'))

        m_title = request.form["m-title"]
        m_sub_title = request.form["m-sub-title"]
        m_genre = request.form["m-genre"]
        m_image_link = request.form["m-image-link"]
        m_synopsis = request.form["m-synopsis"]
        m_reviewer_name = request.form["r-name"]
        m_review_date = request.form["r-date"]
        m_stars = request.form["m-stars"]
        m_sc_review = request.form["sc-review"]
        m_sc_example = request.form["sc-example"]
        m_ac_review = request.form["ac-review"]
        m_ac_example = request.form["ac-example"]
        m_te_review = request.form["te-review"]
        m_te_example = request.form["te-example"]
        m_so_review = request.form["so-review"]
        m_so_example = request.form["so-example"]
        m_summary = request.form["su-review"]
        m_affiliate_link = request.form["m-af-link"]
        m_email = request.form["e-mail"]
        m_process = "active"

      
        with open("templates/crvid", "r") as f:
            crev_id = f.read()
         

        x = coll_reviews.find_one({"_id": ObjectId(crev_id)})
        newvalues = {
            "$set": {
                "m-title": m_title,
                "m-sub-title": m_sub_title,
                "m-genre": m_genre,
                "m-image-link": m_image_link,
                "m-synopsis": m_synopsis,
                "m-reviewer-name": m_reviewer_name,
                "m-review-date": m_review_date,
                "m-stars": m_stars,
                "m-sc-review": m_sc_review,
                "m-sc-example": m_sc_example,
                "m-ac-review": m_ac_review,
                "m-ac-example": m_ac_example,
                "m-te-review": m_te_review,
                "m-te-example": m_te_example,
                "m-so-review": m_so_review,
                "m-so-example": m_so_example,
                "m-summary": m_summary,
                "m-affiliate-link": m_affiliate_link,
                "m-email": m_email,
                "m-process": m_process
            }
        }
        coll_reviews.update_one(x, newvalues)
        return render_template('update-success.html',\
        page='Member Update Sheet', fm=siteText["footer-message"],\
        crv=crv, lg=legalFooter["legal-message"], unlock=unlock)
    
    return render_template('member-options.html',\
        page='Member Maintenance Page!', fm=siteText["footer-message"],\
        rev_bag=rev_bag, crv=crv, lg=legalFooter["legal-message"],\
        unlock=unlock)


@app.route('/update-success.html', methods=["GET", "POST"])
def updateSuccess():
    print("UPDATE SUCCESS!")
    return render_template('update-success.html', page=' Page!',\
        fm=siteText["footer-message"], rev_bag=rev_bag,\
        lg=legalFooter["legal-message"])


@app.route('/member-options-gr', methods=["GET", "POST"])
def memberOptionsGr():
    return render_template('member-options-gr.html', page=' Page!',\
        fm=siteText["footer-message"], rev_bag=rev_bag,\
             lg=legalFooter["legal-message"])


@app.route('/delete-success.html', methods=["GET", "POST"])
def deleteSuccessOk():
    return render_template('delete-success.html', page='Delete Success OK!',\
    fm=siteText["footer-message"], lg=legalFooter["legal-message"])


@app.route('/login-failure', methods=["GET", "POST"])
def loginFailure():    
    return render_template('login-failure.html', page='Login Failure!',\
    fm=siteText["footer-message"], lg=legalFooter["legal-message"])


@app.route('/member-submission-ok.html', methods=["GET", "POST"])
def memberSubmitOk():
    # MEMBER REVIEW SUBMISSION OK 
    return render_template('member-submission-ok.html',\
    page='Member Review Submission OK!',\
    fm=siteText["footer-message"],\
    lg=legalFooter["legal-message"])


@app.route('/update-sheet.html', methods=["GET", "POST"])
def updateMyReviews():
    return render_template('update-sheet.html', page='Update Reviews',\
    fm=siteText["footer-message"], lg=legalFooter["legal-message"])


if __name__ == "__main__":
    app.run(host=os.environ.get("IP", "127.0.0.1"), port=int(
        os.environ.get("PORT", 8000)), debug=False)