Ejemplo n.º 1
0
def organisation_add():
    form = OrganisationsForm()
    if form.validate_on_submit():
        organisation = Organisations(form.name.data)
        organisation.description = form.description.data

        db.session.add(organisation)
        db.session.commit()
        flash(_("Organisation added"))
        return redirect(url_for("organisations.organisation"))
    return render_template("organisation_add.html", form=form)
Ejemplo n.º 2
0
def wizard():
    if current_user.organisation_name:
        organisation = Organisations.query.filter_by(id=current_user.organisation_id).first()
        form = OrganisationsForm(obj=organisation)
        form.name.data = current_user.organisation_name
    else:
        form = OrganisationsForm()
    if form.validate_on_submit():
        if current_user.organisation_name:
            form.populate_obj(organisation)
        else:
            organisation = Organisations(form.name.data)
            organisation.domain = form.domain.data
            user = User.query.get_or_404(current_user.id)
            organisation.users = [user]
        db.session.add(organisation)
        db.session.commit()
        flash(_('Organisation added'))
        return redirect(url_for("home.homepage"))
    return render_template('wizard.html', form=form)