Remove unused functions from app.py
This commit is contained in:
44
app.py
44
app.py
@@ -1,5 +1,4 @@
|
|||||||
from datetime import datetime, date, timedelta
|
from datetime import date
|
||||||
from dateutil.relativedelta import relativedelta
|
|
||||||
import os
|
import os
|
||||||
from flask import Flask, abort, render_template, redirect, request, url_for
|
from flask import Flask, abort, render_template, redirect, request, url_for
|
||||||
import jinja_partials
|
import jinja_partials
|
||||||
@@ -9,7 +8,6 @@ from db import DataBase
|
|||||||
from utils import convert_str_to_date, generate_plot
|
from utils import convert_str_to_date, generate_plot
|
||||||
from flask_htmx import HTMX
|
from flask_htmx import HTMX
|
||||||
import minify_html
|
import minify_html
|
||||||
from urllib.parse import quote
|
|
||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
@@ -586,32 +584,10 @@ def search_endpoints():
|
|||||||
def closeConnection(exception):
|
def closeConnection(exception):
|
||||||
db.close_connection()
|
db.close_connection()
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter('list_to_string')
|
|
||||||
def list_to_string(list):
|
|
||||||
return [str(i) for i in list]
|
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter('strftime')
|
@app.template_filter('strftime')
|
||||||
def strftime(date, format="%b %d %Y"):
|
def strftime(date, format="%b %d %Y"):
|
||||||
return date.strftime(format)
|
return date.strftime(format)
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter('get_first_element_from_list_with_matching_attribute')
|
|
||||||
def get_first_element_from_list_with_matching_attribute(list, attribute, value):
|
|
||||||
if not list:
|
|
||||||
return None
|
|
||||||
for element in list:
|
|
||||||
if element[attribute] == value:
|
|
||||||
return element
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter('replace_double_quote_strings_with_single_quote')
|
|
||||||
def replace_double_quote_strings_with_single_quote(str):
|
|
||||||
return str.replace('"', "'")
|
|
||||||
|
|
||||||
|
|
||||||
@ app.context_processor
|
@ app.context_processor
|
||||||
def my_utility_processor():
|
def my_utility_processor():
|
||||||
|
|
||||||
@@ -623,26 +599,10 @@ def my_utility_processor():
|
|||||||
return 'bg-gray-200'
|
return 'bg-gray-200'
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def get_first_element_from_list_with_matching_attribute(list, attribute, value):
|
|
||||||
if not list:
|
|
||||||
return None
|
|
||||||
for element in list:
|
|
||||||
if element[attribute] == value:
|
|
||||||
return element
|
|
||||||
return None
|
|
||||||
|
|
||||||
def in_list(val, checked_vals, attr='checked'):
|
|
||||||
if not checked_vals:
|
|
||||||
return attr
|
|
||||||
return attr if val in checked_vals else ''
|
|
||||||
|
|
||||||
def strftime(date, format="%b %d %Y"):
|
def strftime(date, format="%b %d %Y"):
|
||||||
return date.strftime(format)
|
return date.strftime(format)
|
||||||
|
|
||||||
def list_to_string(list):
|
return dict(is_selected_page=is_selected_page, strftime=strftime)
|
||||||
return [str(i) for i in list]
|
|
||||||
|
|
||||||
return dict(is_selected_page=is_selected_page, get_first_element_from_list_with_matching_attribute=get_first_element_from_list_with_matching_attribute, in_list=in_list, strftime=strftime, datetime=datetime, timedelta=timedelta, relativedelta=relativedelta, list_to_string=list_to_string, quote=quote)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user