def index(fraction_id, year_of_growth): """collects overview of all products with succsesions(Sätze) of one fraction in one year_of_growth """ fraction = FractionModel(fraction_id) #productlist = fraction.get_product_list() productlist = fraction.cheata_menue() #implement list2nested!!! entries = vegetables_concept_model.get_overview(fraction_id, year_of_growth) summary = vegetables_concept_model.get_overview_summary( fraction_id, year_of_growth) area_info = vegetables_concept_model.get_involved_areas( fraction_id, year_of_growth) if not entries: return redirect( url_for('.create', fraction_id=fraction_id, year_of_growth=year_of_growth)) else: return render_template('conception/conception_index.html', entries=entries, productlist=productlist, summary=summary, area_info=area_info, fraction=fraction, year_of_growth=year_of_growth)
def twopack(fraction_id, source_fraction_id): # init fractions fraction = FractionModel(fraction_id) source_fraction = FractionModel(source_fraction_id) transactions = TransactionModel(fraction_id,source_fraction_id) #get all transactions for the actuall date if 'acquiredate' in session: print('acquiredateInSession:',session['acquiredate'][0]) trdata = transactions.get_simple(date=session['acquiredate'][0]) #trdata = False else: trdata = False #get last inputs history_entries = transactions.acqusitions_get_last(12) # track productgroup if request.args.get('productgroup',''): session['productgroup']= request.args.get('productgroup','') return render_template('acquisition/acquisition.html', fraction=fraction, source_fraction=source_fraction, history_entries=history_entries, transactions= trdata)
def imp_by_product_id(fraction_id, year_of_growth, product_id): """render all sets (Sätze) of one procuct that were realised by one fraction in a year """ #is one element of entries pivot? if request.args.get('pivot'): pivot = int(request.args.get('pivot')) else: pivot = 0 fraction = FractionModel(fraction_id) product = ProductModel(product_id, fraction_id) productlist = fraction.get_first_product_list() the_product = product.get_data() #one dict if the_product['tree_diff'] == 1: # is leaf node entries = vegetables_implement_model.get_by_product_id(fraction_id, year_of_growth, product_id) return render_template('implementation/implementation_one.html', entries=entries, productlist=productlist, fraction=fraction, the_product=the_product, year_of_growth=year_of_growth, pivot=pivot) else: return str(the_product)
def new(fraction_id, year_of_growth, product_id): """ formular """ fraction = FractionModel(fraction_id) product = ProductModel(product_id, fraction_id) diversity = DiversityModel(product_id, fraction_id) growkind = GrowKindModel() the_product = product.get_data() #productlist = fraction.get_productlist() productlist = fraction.get_first_product_list() the_diversity = diversity.get() summary = vegetables_concept_model.get_summary_by_id( fraction_id, year_of_growth, product_id) form = VegetablesConceptionForm(request.form) #before validating wtf choises (<option>) must be given form.diversity_id.choices = diversity.get_wtform_choices() form.area_id.choices = fraction.area.get_wtform_choices() form.grow_kind_id.choices = growkind.get_wtform_choices() if form.validate_on_submit(): new_id = vegetables_concept_model.insert(form) #print(">>>>>>>>> new_id: "+ str(new_id)) if new_id: flash(u'Erfolgreich angelegt:#' + str(new_id), 'success') return redirect( url_for('.by_product_id', fraction_id=fraction.fraction_id, year_of_growth=year_of_growth, product_id=product.product_id, pivot=new_id)) else: abort(500) #manualy poke initial form.values with the_product specs form.name.data = the_product['item_name'] form.fraction_id.data = fraction.fraction_id form.year_of_growth.data = year_of_growth form.product_id.data = the_product['product_id'] form.grow_kind_id.data = (the_product['grow_kind_id']) form.planting_interval.data = the_product['planting_interval'] return render_template('conception/conception_input_form.html', form=form, fraction=fraction, summary=summary, productlist=productlist, the_product=the_product, the_diversity=the_diversity, year_of_growth=year_of_growth, edit=False)
def edit(conception_id): """update""" data = vegetables_concept_model.get_by_id(conception_id) fraction_id = data['fraction_id'] product_id = data['product_id'] year_of_growth = data['year_of_growth'] fraction = FractionModel(fraction_id) product = ProductModel(product_id, fraction_id) diversity = DiversityModel(product_id, fraction_id) growkind = GrowKindModel() #area = AreaModel() the_product = product.get_data() #productlist = fraction.get_productlist() productlist = fraction.get_first_product_list() the_diversity = diversity.get() summary = vegetables_concept_model.get_summary_by_id( fraction_id, year_of_growth, product_id) form = VegetablesConceptionForm(request.form, data=data) #obj=data #before validating choises must be given form.diversity_id.choices = diversity.get_wtform_choices() form.area_id.choices = fraction.area.get_wtform_choices() form.grow_kind_id.choices = growkind.get_wtform_choices() #print('>>>>>>>>>>>>>diversity_ID:'+str(form.diversity_id.data)) if form.validate_on_submit(): check = vegetables_concept_model.update(form, conception_id) if check == 1: flash(u'Erfolgreich geändert', 'success') if check == 0: flash(u'nichts verändert', 'primary') return redirect( url_for('.by_product_id', fraction_id=fraction.fraction_id, year_of_growth=year_of_growth, product_id=product.product_id, pivot=conception_id)) return render_template('conception/conception_input_form.html', form=form, fraction=fraction, summary=summary, productlist=productlist, the_product=the_product, the_diversity=the_diversity, year_of_growth=year_of_growth, edit=True, data=data)
def imp_index(fraction_id, year_of_growth): fraction = FractionModel(fraction_id) #productlist = fraction.get_first_product_list() productlist = fraction.cheata_menue() entries = vegetables_implement_model.get(fraction_id, year_of_growth) print(fraction.name) print(fraction.fraction_id) return render_template('implementation/implementation_index.html', entries=entries, productlist=productlist, fraction=fraction, year_of_growth=year_of_growth)
def seed(fraction_id, year_of_growth): fraction = FractionModel(fraction_id) entries = vegetables_concept_model.seed(fraction_id, year_of_growth) return render_template('conception/seed.html', fraction=fraction, entries=entries)
def onepack(fraction_id): fraction = FractionModel(fraction_id) if request.args.get('productgroup',''): session['productgroup']= request.args.get('productgroup','') return render_template('acquisition/acquisition.html', fraction=fraction)
def imp_edit(implementation_id): """update""" data = vegetables_implement_model.get_by_id(implementation_id) fraction_id = data['fraction_id'] product_id = data['product_id'] year_of_growth = data['year_of_growth'] fraction = FractionModel(fraction_id) product = ProductModel(product_id, fraction_id) diversity = DiversityModel(product_id, fraction_id) growkind = GrowKindModel() the_product = product.get_data() #productlist = fraction.get_first_product_list() productlist = fraction.cheata_menue() #implement list2nested!!! the_diversity = diversity.get() form = VegetablesImplementationForm(request.form, data=data) #obj=data #before validating choises must be given form.diversity_id.choices = diversity.get_wtform_choices() form.area_id.choices = fraction.area.get_wtform_choices() form.grow_kind_id.choices = growkind.get_wtform_choices() if form.validate_on_submit(): check = vegetables_implement_model.update(form,implementation_id) if check == 1: flash(u'Erfolgreich geändert', 'success') if check == 0: flash(u'nichts verändert', 'primary') return redirect(url_for('.imp_by_product_id', fraction_id=fraction.fraction_id, year_of_growth=year_of_growth, product_id=product.product_id, pivot=conception_id)) return render_template('implementation/implementation_input_form.html', form=form, fraction=fraction, productlist=productlist, the_product=the_product, the_diversity=the_diversity, year_of_growth=year_of_growth)
def create(fraction_id, year_of_growth): """make the farmland right and hack manualy import a pre existing plan [1997] acording with croprotation and/or croprotate manualy.... """ fraction = FractionModel(fraction_id) return 'Begin planing on' + str( fraction.name) + ' anno ' + str(year_of_growth)
def buy(fraction_id, year_of_growth): fraction = FractionModel(fraction_id) entries = vegetables_concept_model.buy(fraction_id, year_of_growth) return render_template('conception/buy.html', fraction=fraction, year_of_growth=year_of_growth, entries=entries)
def table(fraction_id, year_of_growth): fraction = FractionModel(fraction_id) entries = vegetables_concept_model.ex_plan(fraction_id, year_of_growth) return render_template('conception/plan.html', entries=entries, year_of_growth=year_of_growth, fraction=fraction)
def by_product_id(fraction_id, year_of_growth, product_id): """render all sets (Sätze) of one product""" start = time.time() #performence time start if request.args.get('pivot'): pivot = int(request.args.get('pivot')) #or_test (trinity operator) else: pivot = 0 fraction = FractionModel(fraction_id) product = ProductModel(product_id, fraction_id) transact = TransactionModel(fraction_id) #productlist = fraction.get_product_list() productlist = fraction.cheata_menue() #implement list2nested!!! the_product = product.get_data() #:one dict area_info = vegetables_concept_model.get_involved_areas( fraction_id, year_of_growth) #t=transact.get_transactions(product_id) #print('Transactions:'+str(t)) if the_product['tree_diff'] == 1: entries = vegetables_concept_model.get_product_by_id( fraction_id, year_of_growth, product_id) summary = vegetables_concept_model.get_summary_by_id( fraction_id, year_of_growth, product_id) end = time.time() #performence time end print('Performence conception.by_product_id:' + str(end - start) + 'sec.') return render_template('conception/conception_one.html', entries=entries, summary=summary, productlist=productlist, fraction=fraction, the_product=the_product, area_info=area_info, year_of_growth=year_of_growth, pivot=pivot) else: return str(the_product)
def getsome(fraction_id, source_fraction_id, product_id): """ GET ready to fire a POST to the acquisitions table the flow is: from source_fraction to fraction WHAT happens IF fraction_id is to drive the boxes and units, like DEPOT wants to have 264' boxes in Pounds of a product??? """ #init destination fractions fraction = FractionModel(fraction_id) #init source fraction source_fraction = FractionModel(source_fraction_id) #init one product product = ProductModel(product_id, source_fraction_id) #dict of product spec data (one db row) product_entries = product.get_data() #init units unit = UnitModel(product_entries['unit_set_id']) #init boxes box = BoxModel(product_entries['boxes_set_id']) #init vehicles vehicle = VehicleModel() #transactionmodel transactions = TransactionModel(fraction_id,source_fraction_id) #the latest entries in acquisitions table #TODO variable count history_entries = transactions.acqusitions_get_last(12) form = Acquisition_Retraction_Form() if 'acquiredate' in session: form.aq_date.raw_data = session['acquiredate'] #before validating wtf choises (<option>) must be given form.unit_id.choices = unit.get_wtform_choices() form.vehicle_id.choices = vehicle.get_wtform_choices() form.box_id.choices = box.get_wtform_choices() #with boxes we css-style <options> in the template (render_kw?) boxset = box.get_set_by_id(product_entries['boxes_set_id']) form.alternate_unit_id.choices = unit.get_wtform_choices() if form.validate_on_submit(): session['acquiredate'] = form.aq_date.raw_data res = transactions.acqusition_insert(form) print(">>>>>>>>>aqcuisition_insert_result: "+ str(res)) if res: flash(u'Die Angaben und Werte wurden erfolgreich übernommen und gespeichert.','success') return redirect(url_for('.getsome', fraction_id=fraction_id, source_fraction_id=source_fraction_id, product_id=product_id)) else: abort(500) #manualy set wtform.data preselected form.fraction_id.data = fraction.fraction_id form.source_fraction_id.data = source_fraction.fraction_id form.product_id.data = product_entries['product_id'] form.unit_id.data = product_entries['unit_pivot_id'] form.box_id.data = product_entries['box_pivot_id'] form.box_count.data = 0 form.vehicle_count.data =0 return render_template('acquisition/acquisition.html', fraction=fraction, source_fraction=source_fraction, product_entries=product_entries, boxset=boxset, history_entries=history_entries, form=form)