mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 17:32:38 +02:00
Add ACTIVATE_DEMO_PROJECT setting (#209)
When set to False (True by default), it deactivates the demo project
This commit is contained in:
parent
4410aaa504
commit
091553be56
4 changed files with 22 additions and 2 deletions
|
@ -8,3 +8,5 @@ SQLALCHEMY_TRACK_MODIFICATIONS = False
|
|||
SECRET_KEY = "tralala"
|
||||
|
||||
MAIL_DEFAULT_SENDER = ("Budget manager", "budget@notmyidea.org")
|
||||
|
||||
ACTIVATE_DEMO_PROJECT = True
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue