How to use the ihatemoney.models.db.session function in ihatemoney

To help you get started, we’ve selected a few ihatemoney examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spiral-project / ihatemoney / ihatemoney / manage.py View on Github external
def run(self, project_name):
        demo_project = Project.query.get(project_name)
        db.session.delete(demo_project)
        db.session.commit()
github spiral-project / ihatemoney / ihatemoney / api.py View on Github external
def put(self, project, bill_id):
        form = get_billform_for(project, True, meta={"csrf": False})
        if form.validate():
            bill = Bill.query.get(project, bill_id)
            form.save(bill, project)
            db.session.commit()
            return bill.id, 200
        return form.errors, 400
github spiral-project / ihatemoney / ihatemoney / api.py View on Github external
def post(self):
        form = ProjectForm(meta={"csrf": False})
        if form.validate() and current_app.config.get("ALLOW_PUBLIC_PROJECT_CREATION"):
            project = form.save()
            db.session.add(project)
            db.session.commit()
            return project.id, 201
        return form.errors, 400
github spiral-project / ihatemoney / ihatemoney / web.py View on Github external
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 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="demonstration",
            password=generate_password_hash("demo"),
            contact_email="demo@notmyidea.org",
        )
        db.session.add(project)
        db.session.commit()
    session[project.id] = True
    return redirect(url_for(".list_bills", project_id=project.id))