Пример #1
0
def groups():
    data = EnterpriseAPI.GroupList()
    if request.method == 'POST':
        if request.form['submit'] == 'Submit':
            try:
                EnterpriseAPI.AddGroup(session['username'],
                                       session['password'],
                                       request.form['Name'],
                                       request.form['description'])
                flash('Group added successfully', category='success')
                return redirect(url_for('invoices.groups'))
            except Exception as e:
                flash(str(e), category='fail')
                return redirect(url_for('invoices.groups'))
    return render_template('invoices/groups.html',
                           username=session['username'],
                           role=session['role'],
                           data=data)
Пример #2
0
def edit_group(id):
    data = EnterpriseAPI.GetGroup(id)
    data1 = EnterpriseAPI.GroupList()
    if request.method == 'POST':
        if request.form['submit'] == 'Submit':
            try:
                EnterpriseAPI.UpdateGroup(session['username'],
                                          session['password'], id,
                                          request.form['Name'],
                                          request.form['description'])
                flash('Group Updated Successfully', category='success')
                return redirect(url_for('invoices.groups'))
            except Exception as e:
                flash(str(e), category='fail')
                return redirect(url_for('invoices.groups'))
    return render_template('invoices/edit_group.html',
                           data=data,
                           data1=data1,
                           username=session['username'],
                           role=session['role'])