Skip to content

Commit

Permalink
Merge pull request #80 from dgc08/add-dimiss-demo-option
Browse files Browse the repository at this point in the history
Exit demo mode option added
  • Loading branch information
jzohrab authored Dec 27, 2023
2 parents f175bf8 + 0d37849 commit 99a830e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ venv.bak/
# Rope project settings
.ropeproject

# PyCharm project settings
.idea/

# mkdocs documentation
/site

Expand Down
12 changes: 12 additions & 0 deletions lute/app_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ def wipe_db():
change your <a href="/settings/index">Settings</a> as needed.)</i>
"""
flash(msg)
return redirect("/", 302)\

@app.route("/remove_demo_flag")
def remove_demo():
if lute.db.demo.contains_demo_data():
lute.db.demo.remove_flag()
msg = """
Demo mode deactivated. Have fun! <br /><br />
<i>(Lute has automatically enabled backups --
change your <a href="/settings/index">Settings</a> as needed.)</i>
"""
flash(msg)
return redirect("/", 302)

@app.route("/version")
Expand Down
3 changes: 3 additions & 0 deletions lute/db/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def remove_flag():
"""
Remove IsDemoData setting.
"""
if not contains_demo_data():
raise RuntimeError("Can't delete non-demo data.")

SystemSetting.delete_key("IsDemoData")
db.session.commit()

Expand Down
3 changes: 3 additions & 0 deletions lute/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<p>When you're done trying out the demo, <a href="/wipe_database"
style="text-decoration: underline;">click here</a> to clear out the
database. <i>Note: this removes everything in the db.</i></p>
<p>Or instead,
<a href="/remove_demo_flag" style="text-decoration: underline;">dimiss</a>
this message.
</p>
</div>
{% endif %}
Expand Down

0 comments on commit 99a830e

Please sign in to comment.