Moved convert_markdown_template to formatters

This commit is contained in:
Anastasia Gradova
2023-12-22 10:03:43 -07:00
parent 86af8fcaa4
commit 0989246334
2 changed files with 19 additions and 21 deletions

View File

@@ -6,11 +6,14 @@ from functools import partial
from math import floor, log10
from numbers import Number
import markdown
import os
import ago
import dateutil
import humanize
import pytz
from flask import Markup, url_for
from flask import Markup, url_for, render_template_string
from flask.helpers import get_root_path
from notifications_utils.field import Field
from notifications_utils.formatters import make_quotes_smart
from notifications_utils.formatters import nl2br as utils_nl2br
@@ -21,6 +24,18 @@ from app.utils.csv import get_user_preferred_timezone
from app.utils.time import parse_naive_dt
def convert_markdown_template(mdf):
APP_ROOT = get_root_path('notifications-admin')
file = 'app/content/' + mdf + '.md'
md_file = os.path.join(APP_ROOT, file)
with open(md_file) as f:
content_text = f.read()
md_render = markdown.markdown(content_text)
jn_render = render_template_string(md_render)
return jn_render
def convert_to_boolean(value):
if isinstance(value, str):
if value.lower() in ["t", "true", "on", "yes", "1"]:

View File

@@ -4,37 +4,19 @@ from flask import (
make_response,
redirect,
render_template,
render_template_string,
request,
url_for
)
from flask_login import current_user
from flask.helpers import get_root_path
from notifications_utils.template import HTMLEmailTemplate
import markdown
import os
from app import email_branding_client, status_api_client
from app.main import main
from app.main.forms import FieldWithNoneOption
from app.main.views.pricing import CURRENT_SMS_RATE
from app.main.views.sub_navigation_dictionaries import features_nav, using_notify_nav
from app.utils.user import user_is_logged_in
#Should find a better home
def get_md(mdf):
APP_ROOT = get_root_path('notifications-admin')
file = 'app/content/' + mdf + '.md'
md_file = os.path.join(APP_ROOT, file)
with open(md_file) as f:
content_text = f.read()
md_render = markdown.markdown(content_text)
jn_render = render_template_string(md_render)
return jn_render
from app.formatters import convert_markdown_template
@main.route("/")
def index():
@@ -274,7 +256,8 @@ def get_started_old():
def get_started():
return render_template(
"views/get-started.html",
navigation_links=using_notify_nav(), content=get_md('get-started')
navigation_links=using_notify_nav(),
content=convert_markdown_template('get-started')
)