Pengin-Open-Source / pengin-pi

PENGIN PI! A CRM with the back bone of a feature light ERP system. Utilitarian in design, easy to extend, customize, and deploy. Made by a community, supported by Tobu Pengin.
GNU General Public License v3.0
9 stars 1 forks source link

[TASK] app init before_task function for chat_bool toggle #413

Open stuart909 opened 6 months ago

stuart909 commented 6 months ago

Description We need to setup a toggle mechanism in a route function with the @app.before_task() decorator to ensure the function is run before the endpoint.

Details This can live in the routes/message.py or the app init.

Will look kind of like:

#might need to include endpoint for chat routes to better handle chat_bool processing
    @app.before_request()
    def chat_messenger_activater(ID):
        if app.context_processor(chat_bool):
            if request.method == "POST":
                if ID == "chat_btn":
                    chat_bool == False
                    #ensure the javascript deletes or hides the overlay
                    #alternative is using endpoints in routes, and this simply toggles chat_bool
        else:
            if request.method == "POST":
                if ID == "chat_btn":
                    chat_bool = True
                    #javascript sending post, gets html response, and dynamically loads chat
                    #alternative is using endpoints in routes, and this simply toggles chat_bool
                    return "append / forcefully return html template"

Additional