Ejemplo n.º 1
0
def complete(id):
    feature_request = FeatureRequest.query.get(id)
    client = feature_request.client
    priority = feature_request.priority
    feature_request.priority = 0
    FeatureRequest.adjust_priorities(client, priority, -1)
    db.session.commit()
    return jsonify({'success': True})
Ejemplo n.º 2
0
def delete(id):
    feature_request = FeatureRequest.query.get(id)
    client = feature_request.client
    priority = feature_request.priority
    db.session.delete(feature_request)
    if priority > 0: # Adjust priorities only for active records
        FeatureRequest.adjust_priorities(client, priority, -1)
    db.session.commit()
    return jsonify({'success': True})
Ejemplo n.º 3
0
def index():
    form = AddUpdateForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            if form.id.data < 1:
                # Insert Mode
                update_priority = True
                FeatureRequest.adjust_priorities(form.client.data, form.priority.data, 1)
                feature_request = FeatureRequest(
                    priority=form.priority.data,
                    title=form.title.data,
                    description=form.description.data,
                    target_date=form.target_date.data,
                    client=form.client.data,
                    product_area=form.product_area.data
                )
                db.session.add(feature_request)

            else:
                # Update mode
                feature_request = FeatureRequest.query.get(form.id.data)
                current_priority = feature_request.priority
                update_priority = True if current_priority != form.priority.data else False
                feature_request.title = form.title.data
                feature_request.description = form.description.data
                feature_request.target_date = form.target_date.data
                feature_request.client = form.client.data
                feature_request.product_area = form.product_area.data
                if update_priority:
                    feature_request.set_priority(form.priority.data)

            db.session.commit()
            return jsonify({'success': True, 'update_priority': update_priority})
        else:
            return jsonify({'success': False, 'errors': form.errors})

    # GET method
    data_choices = {
        'clients': CLIENT_CHOICES,
        'product_areas': PRODUCT_AREA_CHOICES
    }
    return render_template('index.html', form=form, data_choices=data_choices)