From 3a5898afca1f3f00ff84e3d2eb310405df00e567 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 25 Sep 2019 11:46:35 -0500 Subject: Added option to edit most of the help pages except for Links --- wqflask/wqflask/docs.py | 15 ++++++++++++--- wqflask/wqflask/templates/docedit.html | 3 +++ wqflask/wqflask/templates/docs.html | 6 ++++-- wqflask/wqflask/views.py | 30 +++++++++++++----------------- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/wqflask/wqflask/docs.py b/wqflask/wqflask/docs.py index 9777f170..f45202af 100644 --- a/wqflask/wqflask/docs.py +++ b/wqflask/wqflask/docs.py @@ -7,7 +7,7 @@ logger = getLogger(__name__) class Docs(object): - def __init__(self, entry): + def __init__(self, entry, start_vars={}): sql = """ SELECT Docs.title, Docs.content FROM Docs @@ -15,8 +15,17 @@ class Docs(object): """ result = g.db.execute(sql, str(entry)).fetchone() self.entry = entry - self.title = result[0] - self.content = result[1] + if result == None: + self.title = self.entry.capitalize() + self.content = "" + else: + self.title = result[0] + self.content = result[1] + + if 'edit' in start_vars and start_vars['edit'] == "true": + self.editable = "true" + else: + self.editable = "false" def update_text(start_vars): content = start_vars['ckcontent'] diff --git a/wqflask/wqflask/templates/docedit.html b/wqflask/wqflask/templates/docedit.html index 8c3d5e7c..e8aa7da1 100644 --- a/wqflask/wqflask/templates/docedit.html +++ b/wqflask/wqflask/templates/docedit.html @@ -8,6 +8,9 @@
+ {% if editable is defined %} + + {% endif %} diff --git a/wqflask/wqflask/templates/docs.html b/wqflask/wqflask/templates/docs.html index 1a241ce7..1e5a7aef 100644 --- a/wqflask/wqflask/templates/docs.html +++ b/wqflask/wqflask/templates/docs.html @@ -6,9 +6,11 @@

{{title}}

- + {% if editable == "true" %} + - + + {% endif %}
{{content|safe}}
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index cef5f8ec..70748040 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -216,7 +216,7 @@ def gsearch_updating(): @app.route("/docedit") def docedit(): logger.info(request.url) - doc = docs.Docs(request.args['entry']) + doc = docs.Docs(request.args['entry'], request.args) return render_template("docedit.html", **doc.__dict__) @app.route('/generated/') @@ -227,7 +227,7 @@ def generated_file(filename): @app.route("/help") def help(): logger.info(request.url) - doc = docs.Docs("help") + doc = docs.Docs("help", request.args) return render_template("docs.html", **doc.__dict__) @app.route("/wgcna_setup", methods=('POST',)) @@ -260,46 +260,42 @@ def ctl_results(): result = ctl.process_results(ctlA) # After the analysis is finished store the result return render_template("ctl_results.html", **result) # Display them using the template -#@app.route("/news") -#def news_route(): -# newsobject = news.News() -# return render_template("news.html", **newsobject.__dict__) - @app.route("/news") def news(): - doc = docs.Docs("news") + doc = docs.Docs("news", request.args) return render_template("docs.html", **doc.__dict__) @app.route("/references") def references(): - # doc = docs.Docs("references") - # return render_template("docs.html", **doc.__dict__) - return render_template("reference.html") + doc = docs.Docs("references", request.args) + return render_template("docs.html", **doc.__dict__) + # return render_template("reference.html") @app.route("/intro") def intro(): - doc = docs.Docs("intro") + doc = docs.Docs("intro", request.args) return render_template("docs.html", **doc.__dict__) @app.route("/policies") def policies(): - doc = docs.Docs("policies") + doc = docs.Docs("policies", request.args) return render_template("docs.html", **doc.__dict__) @app.route("/links") def links(): - doc = docs.Docs("links") - return render_template("docs.html", **doc.__dict__) + #doc = docs.Docs("links") + #return render_template("docs.html", **doc.__dict__) + return render_template("links.html") @app.route("/environments") def environments(): - doc = docs.Docs("environments") + doc = docs.Docs("environments", request.args) return render_template("docs.html", **doc.__dict__) @app.route("/update_text", methods=('POST',)) def update_page(): docs.update_text(request.form) - doc = docs.Docs(request.form['entry_type']) + doc = docs.Docs(request.form['entry_type'], request.form) return render_template("docs.html", **doc.__dict__) @app.route("/submit_trait") -- cgit v1.2.3