aboutsummaryrefslogtreecommitdiff
path: root/budget
diff options
context:
space:
mode:
Diffstat (limited to 'budget')
-rw-r--r--budget/default_settings.py2
-rw-r--r--budget/templates/home.html2
-rw-r--r--budget/tests/tests.py7
-rw-r--r--budget/web.py13
4 files changed, 22 insertions, 2 deletions
diff --git a/budget/default_settings.py b/budget/default_settings.py
index 5ee6de8..210b3f2 100644
--- a/budget/default_settings.py
+++ b/budget/default_settings.py
@@ -8,3 +8,5 @@ SQLALCHEMY_TRACK_MODIFICATIONS = False
SECRET_KEY = "tralala"
MAIL_DEFAULT_SENDER = ("Budget manager", "budget@notmyidea.org")
+
+ACTIVATE_DEMO_PROJECT = True
diff --git a/budget/templates/home.html b/budget/templates/home.html
index 399343a..edbee61 100644
--- a/budget/templates/home.html
+++ b/budget/templates/home.html
@@ -5,7 +5,9 @@
<header id="header" class="row">
<div class="col-5 offset-md-2">
<h2>{{ _("Manage your shared <br>expenses, easily") }}</h2>
+ {% if is_demo_project_activated %}
<a href="{{ url_for(".demo") }}" class="tryout btn">{{ _("Try out the demo") }}</a>
+ {% endif %}
</div>
<div class="col-4">
<p class="additional-content">{{ _("You're sharing a house?") }}<br /> {{ _("Going on holidays with friends?") }}<br /> {{ _("Simply sharing money with others?") }} <br /><strong>{{ _("We can help!") }}</strong></p>
diff --git a/budget/tests/tests.py b/budget/tests/tests.py
index d979a29..e18e9c3 100644
--- a/budget/tests/tests.py
+++ b/budget/tests/tests.py
@@ -331,6 +331,13 @@ class BudgetTestCase(TestCase):
self.app.get("/demo")
self.assertTrue(models.Project.query.get("demo") is not None)
+ def test_deactivated_demo(self):
+ run.app.config['ACTIVATE_DEMO_PROJECT'] = False
+
+ # test redirection to the create project form when demo is deactivated
+ resp = self.app.get("/demo")
+ self.assertIn('<a href="/create?project_id=demo">', resp.data.decode('utf-8'))
+
def test_authentication(self):
# try to authenticate without credentials should redirect
# to the authentication page
diff --git a/budget/web.py b/budget/web.py
index 18867c5..efb427c 100644
--- a/budget/web.py
+++ b/budget/web.py
@@ -121,8 +121,11 @@ def authenticate(project_id=None):
def home():
project_form = ProjectForm()
auth_form = AuthenticationForm()
+ is_demo_project_activated = current_app.config['ACTIVATE_DEMO_PROJECT']
+
return render_template("home.html", project_form=project_form,
- auth_form=auth_form, session=session)
+ is_demo_project_activated=is_demo_project_activated,
+ auth_form=auth_form, session=session)
@main.route("/create", methods=["GET", "POST"])
@@ -258,9 +261,15 @@ def demo():
the bills list for this project.
Create a demo project if it doesnt exists yet (or has been deleted)
+ If the demo project is deactivated, one is redirected to the create project form
"""
+ is_demo_project_activated = current_app.config['ACTIVATE_DEMO_PROJECT']
project = Project.query.get("demo")
- if not project:
+
+ if not project and not is_demo_project_activated:
+ raise Redirect303(url_for(".create_project",
+ project_id='demo'))
+ if not project and is_demo_project_activated:
project = Project(id="demo", name=u"demonstration", password="demo",
contact_email="demo@notmyidea.org")
db.session.add(project)