How to use the ihatemoney.models.Person 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 / web.py View on Github external
def add_member():
    # FIXME manage form errors on the list_bills page
    form = MemberForm(g.project)
    if request.method == "POST":
        if form.validate():
            member = form.save(g.project, Person())
            db.session.commit()
            flash(_("%(member)s had been added", member=member.name))
            return redirect(url_for(".list_bills"))

    return render_template("add_member.html", form=form)
github spiral-project / ihatemoney / ihatemoney / api.py View on Github external
def post(self, project):
        form = MemberForm(project, meta={"csrf": False})
        if form.validate():
            member = Person()
            form.save(project, member)
            db.session.commit()
            return member.id, 201
        return form.errors, 400
github spiral-project / ihatemoney / ihatemoney / models.py View on Github external
def get(self, project, id):
            try:
                return (
                    self.join(Person, Project)
                    .filter(Bill.payer_id == Person.id)
                    .filter(Person.project_id == Project.id)
                    .filter(Project.id == project.id)
                    .filter(Bill.id == id)
                    .one()
                )
            except orm.exc.NoResultFound:
                return None
github spiral-project / ihatemoney / ihatemoney / forms.py View on Github external
def validate_name(form, field):
        if field.data == form.name.default:
            raise ValidationError(_("User name incorrect"))
        if (
            not form.edit
            and Person.query.filter(
                Person.name == field.data,
                Person.project == form.project,
                Person.activated == True,
            ).all()
        ):  # NOQA
            raise ValidationError(_("This project already have this member"))
github spiral-project / ihatemoney / ihatemoney / forms.py View on Github external
def validate_name(form, field):
        if field.data == form.name.default:
            raise ValidationError(_("User name incorrect"))
        if (
            not form.edit
            and Person.query.filter(
                Person.name == field.data,
                Person.project == form.project,
                Person.activated == True,
            ).all()
        ):  # NOQA
            raise ValidationError(_("This project already have this member"))
github spiral-project / ihatemoney / ihatemoney / models.py View on Github external
def get_bills(self):
        """Return the list of bills related to this project"""
        return (
            Bill.query.join(Person, Project)
            .filter(Bill.payer_id == Person.id)
            .filter(Person.project_id == Project.id)
            .filter(Project.id == self.id)
            .order_by(Bill.date.desc())
            .order_by(Bill.creation_date.desc())
            .order_by(Bill.id.desc())
        )