Example #1
0
def create_supervisor():

  """
  Routing to create_supervisor.html

  Returns:
    create_supervisor.html:
      when validator fails with error message.
      when supervisor created with confirm message

  """

  if 'email' not in session:
    return redirect(url_for('home'))

  scraper = ScraperForm()
  scraper.set_supervisor_choices()
  form = SupervisorForm()

  if form.is_submitted():
    if form.validate() == False:
      flash('Missing required fields.')
      return render_template('create_supervisor.html', scraper=scraper, form=form)
    else:
      new_Supervisor = supervisor(form)
      db.session.add(new_Supervisor)
      db.session.commit()
      flash('supervisor created')
      return redirect(url_for('create_supervisor'))

  return render_template('create_supervisor.html', scraper=scraper, form=form)
Example #2
0
def get_Data():

  if 'email' not in session:
    return redirect(url_for('home'))

  scraper = ScraperForm()
  scraper.set_supervisor_choices()
  form = SupervisorForm()

  if scraper.is_submitted():
    if scraper.validate() == False:
      flash('To get supervisor data, pick a name')
      return render_template('create_supervisor.html', scraper=scraper, form=form)
    else:
      scraperInfo = Scraper()
      scraperInfo.getInformation(scraper.supervisorName.data)
      form.insertScraperInfo(scraperInfo)
      flash('Information found shown in form below')
      return render_template('create_supervisor.html', scraper=scraper, form=form)
  return render_template('create_supervisor.html', scraper=scraper, form=form)