def save_changes(feature_detail, form, priority=None): if form: #saving the data into the database feature_detail.title = form.title.data feature_detail.description = form.description.data feature_detail.client = form.client.data feature_detail.client_priority = form.client_priority.data feature_detail.target_date = form.target_date.data feature_detail.product_area = form.product_area.data if priority: new_feature = Feature.query.filter(Feature.client==feature_detail.client).first() feature_2 = Feature() feature_2.title = new_feature.title feature_2.description = new_feature.description feature_2.client = new_feature.client feature_2.client_priority = priority feature_2.target_date = new_feature.target_date feature_2.product_area = new_feature.product_area db.session.remove() db_session.delete(new_feature) db_session.add(feature_2) db_session.commit() db.session.remove() else: db_session.add(feature_detail) db_session.commit() db.session.remove()
def feature(): form = FeatureForm(request.form) if request.method == 'POST' and form.validate(): # save the New Feature feature = Feature() feature.title = form.title.data feature.description = form.description.data feature.client = form.client.data feature.client_priority = form.client_priority.data feature.target_date = form.target_date.data feature.product_area = form.product_area.data priority=form.client_priority.data #right here I call the save_duplicates function save_duplicates(feature, form, priority, True) flash('Feature Request Submitted successfully!') return redirect(url_for('feature')) return render_template('feature.html', title='Feature Request', form=form)