Esempio n. 1
0
def explore():#Feedback
    global m
    m=""
    form = FeedbackForm()
    if form.validate_on_submit():
        if request.method == "POST":
            session["stream"] = dict(Streams).get(form.stream.data)
            FeedQ()
            s = Sentiment(m)
            if s.SentimentAnalyzer() == "P":
                del m
                flash('Positive feedback')
                session["interest"]=0
                session["interestedstream"]=session["stream"]
                return redirect(url_for(form.stream.data))
            else:
                flash('Negative feedback') 
                session["interest"]=1
                if(form.stream.data == 'science'):
                    return redirect(url_for('negative'))
                elif(form.stream.data == 'commerce'):
                    session["interestedstream"]='Commerce'
                    return redirect(url_for('humanities'))
                else:
                    session["interestedstream"]='Humanities'
                    return redirect(url_for('humanities'))
    return render_template('explore.html',title='Explore',form=form)
Esempio n. 2
0
def sendFeedback():
    form = FeedbackForm()
    if form.validate_on_submit():
        flash('Feedback sent. Thank you for your submission!')
        the_form = Feedback(name=form.name.data, email=form.email.data, body=form.body.data)
        db.session.add(the_form)
        db.session.commit()
        return redirect(url_for('category'))
    return render_template('feedback.html', title='New feedback form', form=form)
Esempio n. 3
0
def feeds():
    form = FeedbackForm()
    if form.validate_on_submit():
        feedback = Feedback(name=form.name.data,
                            email=form.email.data,
                            message=form.message.data)
        db.session.add(feedback)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('index.html', form=form)
Esempio n. 4
0
def index():
    form = FeedbackForm()
    if form.validate_on_submit():
        f = Feedback(first_name=form.first_name.data,
                     last_name=form.last_name.data,
                     email=form.email.data,
                     feedback=form.feedback.data)
        db.session.add(f)
        db.session.commit()
        flash(f'Thanks for the feedback {form.first_name.data}!')
        redirect(url_for('index'))
    return render_template('index.html', title='Give Feedback', form=form)
    def create(data) -> (FeedbackForm, int):
        """
        Create "Feedback".
        :param data: data for the FeedbackForm.
        :return: Form and status code (200/400).
        """
        form = FeedbackForm(data)

        if form.is_valid():
            form.save()
            return form, 200
        return form, 400
Esempio n. 6
0
def index():
    form = FeedbackForm()
    if form.validate_on_submit():
        feedback = Feedback(body=form.feedback.data, author=current_user)
        db.session.add(feedback)
        db.session.commit()
        flash('Your post is now live!')
        return redirect(url_for('index'))
    page = request.args.get('page', 1, type=int)
    few_feedback = current_user.followed_few_feedback().paginate(
        page, app.config['POSTS_PER_PAGE'], False)
    return render_template('index.html',
                           title='Home',
                           form=form,
                           few_feedback=few_feedback)
Esempio n. 7
0
def feedback():
    form = FeedbackForm()
    if request.method == 'POST':
        if not form.validate_on_submit():
            flash('All fields are required.', "warning")
            return render_template('feedback.html', form=form)
        else:
            email_feedback(name=form.name.data,
               subject=form.subject.data,
               sender=form.email.data,
               recipient="*****@*****.**",
               feedback_body=form.feedbackBody.data)
        flash('Thank you for your feedback.', "success")
        return redirect(url_for('index'))
    elif request.method == 'GET':
        return render_template("feedback.html", form=form)
Esempio n. 8
0
def feedback(request,host_id):
    host=get_object_or_404(Hosting,id=host_id)
    if request.method == "POST":
         form = FeedbackForm(data=request.POST)
         if form.is_valid():
              j=form.save(commit=False)
              j.hosting=host
              j.ip=get_client_ip(request)
              j.email=form.cleaned_data['email']
              j.name=form.cleaned_data['name']
              j.comment=form.cleaned_data['comment']
              j.save()
              messages.add_message(request, messages.INFO, 'Thank you.Your feedback is sent !')
              return HttpResponseRedirect('/')
    else:
         form = FeedbackForm()
    return render_to_response('app/feedback.html', context_instance=RequestContext(request, {'form': form,'host':host}))
Esempio n. 9
0
    def submit_and_feedback(course_id, test_id, student_id):
        test = Test.query.filter_by(id=test_id).first()
        result = Result.query.filter_by(test_id=test_id,
                                        user_id=student_id).first()
        submissions = test.get_user_submissions(student_id)

        form = FeedbackForm()
        if form.validate_on_submit():
            result.feedback = form.feedback.data
            result.score = sum((sub.score for sub in submissions))
            if not any(sub.needs_marking for sub in submissions):
                result.needs_marking = False

            db.session.commit()

        return redirect(
            url_for('test_view', course_id=course_id, test_id=test_id))
Esempio n. 10
0
def text():
    form = ModelLanguageForm()
    h_form = HashtagForm()
    fb_form = FeedbackForm()
    if form.validate_on_submit():
        if form.text.data:
            if form.model_language.data == 'en':
                message, hate_speech = analyze_eng_text(form.text.data)
            else:
                message, hate_speech = analyze_ger_text(form.text.data)
            flash('{}'.format(message))
            form.text_color = hate_speech
            session['text'] = form.text.data
            session['hate_speech'] = hate_speech
            session['lang'] = form.model_language.data
        return render_template('text_check.html',
                               form=form,
                               h_form=h_form,
                               fb_form=fb_form)
    if fb_form.validate_on_submit():
        if fb_form.submit_da.data and session['hate_speech']:
            label = " NOT_OFFENSIVE_PER_USER"
            save_text(session['text'], label, session['lang'])
        elif fb_form.submit_da.data and not session['hate_speech']:
            label = " OFFENSIVE_PER_USER"
            save_text(session['text'], label, session['lang'])
    if h_form.validate_on_submit():
        if h_form.hashtag.data:
            tweet_url = get_twitter_url(h_form.hashtag.data)
            if not tweet_url:
                h_form.ht = h_form.hashtag.data
                h_form.iframe = "No Tweets were found."
                return render_template('text_check.html',
                                       form=form,
                                       h_form=h_form)
            h_form.ht = h_form.hashtag.data
            h_form.iframe = tweet_url
            return render_template('text_check.html',
                                   form=form,
                                   h_form=h_form,
                                   fb_form=fb_form)
    return render_template('text_check.html',
                           form=form,
                           h_form=h_form,
                           fb_form=fb_form)
Esempio n. 11
0
def navigation():
    # add version to the track usage
    g.track_var["version"] = getCurrentVersion()
    # do everything
    form = FeedbackForm()
    try:
        arguments_GET_request = request.args
        params_research = interface.retrieve_parameters_from_GET(
            arguments_GET_request)

        # usiamo questo per dirgli cosa disegnare!
        # assumiamo nulla per ora
        # geo_type = -2
        # f_ponti = False

        # se e stato inviato il form, scriviamo sul feedback file
        # anche questo da spostare su un metodo

        # form.searched_string.data = params_research['da'] # equivalente al precedente "da"
        t0 = time.perf_counter()
        if request.method == 'POST':
            feedbacksent = interface.take_care_of_the_feedback(
                form, feedback_folder)
            results_dictionary = interface.create_first_dictionary()
            # return render_template(html_file, geo_type=geo_type, start_coordx=-1,
            #     searched_name=da, start_name=start_name,
            #     form=form, feedbacksent=feedbacksent)
            return render_template(html_file,
                                   form=form,
                                   results_dictionary=results_dictionary,
                                   feedbacksent=feedbacksent)
            # non sono 100% sicuro che form vada ritornato sempre (nel caso precedente era ritornato solo in caso di 0)
            # ma dovrebbe funzionare
        # altrimenti, dobbiamo fare qualocsa
        else:
            dictionary_of_stuff_found = interface.find_what_needs_to_be_found(
                params_research)
            return render_template(
                html_file,
                form=form,
                results_dictionary=dictionary_of_stuff_found,
                feedbacksent=0)

    except Exception as e:
        interface.take_care_of_the_error(request, e, error_folder)
        dictionary_of_err = {
            "error": True,
            "repr": repr(e),
            "type": type(e).__name__,
            "msg": str(e),
            "traceback": traceback.format_exc()
        }
        #app.logger.info("error: {}".format(traceback.format_exc()))
        return render_template(html_file,
                               form=form,
                               results_dictionary=dictionary_of_err,
                               feedbacksent=0)
Esempio n. 12
0
def feedback():
    formpage = FeedbackForm()

    if formpage.validate_on_submit():
        event = Event.query.filter_by(id=session.get('event_id')).first()
        student = Student.query.filter_by(id=session.get('id')).first()
        print "Your feedback's been posted bro"
        feedback = Feedback(student_id=student.id,
                            event_id=event.id,
                            title=formpage.title.data,
                            content=formpage.content.data)

        db.session.add(feedback)
        db.session.commit()
        flash('Your feedback has been posted', 'success')
        return redirect(url_for('home'))

    return render_template('feedback_post.html', formpage=formpage)
Esempio n. 13
0
def feedbackform():
    title = request.args.get('title', None)
    form = FeedbackForm(fbSubject=title)
    if request.method == 'POST':
        if 'submit' in request.form:
            if form.validate_on_submit():
                feedback = Feedback(item=form.fbSubject.data,
                                    fname=form.yourname.data,
                                    contact=form.contact.data,
                                    copyright=form.copyright.data,
                                    privacy=form.privacy.data,
                                    message=form.message.data)
                db.session.add(feedback)
                db.session.commit()
                flash('Thank you, your feedback about: {} has been recorded'.
                      format(form.fbSubject.data))
                return redirect(url_for('map1'))
        else:
            return redirect(url_for('map1'))
    return render_template('FeedBackForm.html', title=title, form=form)
Esempio n. 14
0
def feedback():
    form = FeedbackForm()
    if form.validate_on_submit():
        msg = Feedback(feedback=form.feedback.data, author=current_user)
        db.session.add(msg)
        db.session.commit()
        flash('Message sent succesfully!')
        return redirect(url_for('feedback'))
    page = request.args.get('page', 1, type=int)
    msgs = Feedback.query.order_by(Feedback.timestamp.desc()).paginate(
        page, 9, False)  # 6 is the posts per page
    next_url = url_for('feedback',
                       page=msgs.next_num) if msgs.has_next else None
    prev_url = url_for('feedback',
                       page=msgs.prev_num) if msgs.has_prev else None
    rows = math.ceil(len(msgs.items) / 3)
    return render_template('feedback.html',
                           form=form,
                           posts=msgs.items,
                           next_url=next_url,
                           prev_url=prev_url,
                           rows=rows)
def feedback():
    feedback_form = FeedbackForm()
    all_feedback = Feedback.query.filter_by(user_id=current_user.id).all()

    if feedback_form.validate_on_submit():
        new_feedback = Feedback(user_id=current_user.id,
                                job_id=feedback_form.job.data,
                                body=feedback_form.body.data)

        db.session.add(new_feedback)
        db.session.commit()

        flash('Feedback submitted.', 'success')
        return redirect(url_for('user.feedback'))

    data = {
        'title': 'Your Feedback',
        'form': feedback_form,
        'all_feedback': all_feedback
    }

    return render_template('user/feedback.html', **data)
Esempio n. 16
0
def feedback(request):
    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            selfEmail(request)
            form.save()
            return HttpResponseRedirect(reverse('home'))
        mailform = MailForm(request.POST)
        if mailform.is_valid():
            mailform.save()
        return HttpResponseRedirect(reverse('home'))
    else:
        form = FeedbackForm()
        mailform = MailForm()
        return render(request, 'index.html', {'mailform': mailform})
Esempio n. 17
0
    def mark_test(course_id, test_id, student_id):
        course = Course.query.filter_by(id=course_id).first()
        test = Test.query.filter_by(id=test_id).first()
        questions = test.questions
        student = User.query.filter_by(id=student_id).first()

        submissions = test.get_user_submissions(student_id)

        course_form = NewCourseForm()
        feedback_form = FeedbackForm()

        form = MarkTestForm()

        return render_template('mark-test.html',
                               course=course,
                               course_form=course_form,
                               student=student,
                               test=test,
                               questions=questions,
                               submissions=submissions,
                               form=form,
                               feedback_form=feedback_form)
Esempio n. 18
0
def feedback():
    form = FeedbackForm()
    if request.method == 'POST':
        name = request.form['name']
        topic = request.form['topic']
        email = request.form['email']
        text = request.form['text']
        if len(name) > 2 and len(topic) > 2 and '@' in email:
            try:
                feedback = Feedback(name=name,
                                    topic=topic,
                                    email=email,
                                    text=text)
                db.session.add(feedback)
                db.session.commit()
                flash('Сообщение отправлено', category='success')
            except:
                flash('Ошибка отправки - ошибка сервера', category='error')
        else:
            flash(
                'Ошибка отправки (имя, тема должны содержать хотябы 3 символа и почта должна быть валидна)',
                category='error')
    return render_template('feedback.html', form=form)
Esempio n. 19
0
def feedback(request, host_id):
    host = get_object_or_404(Hosting, id=host_id)
    if request.method == "POST":
        form = FeedbackForm(data=request.POST)
        if form.is_valid():
            j = form.save(commit=False)
            j.hosting = host
            j.ip = get_client_ip(request)
            j.email = form.cleaned_data['email']
            j.name = form.cleaned_data['name']
            j.comment = form.cleaned_data['comment']
            j.save()
            messages.add_message(request, messages.INFO,
                                 'Thank you.Your feedback is sent !')
            return HttpResponseRedirect('/')
    else:
        form = FeedbackForm()
    return render_to_response('app/feedback.html',
                              context_instance=RequestContext(
                                  request, {
                                      'form': form,
                                      'host': host
                                  }))
Esempio n. 20
0
def find_water_path():
    proximity = [0.002, 0.002]
    min_number_of_rive = 10
    name_of_rive_as_poi = "vincolo"
    html_water_file = html_file
    # usiamo questo per dirgli cosa disegnare!
    geo_type = -2
    da = request.args.get('partenza', default='', type=str)
    a = request.args.get('arrivo', default='', type=str)
    form = FeedbackForm()
    form.searched_string.data = da
    t0 = time.perf_counter()
    if request.method == 'POST':
        if form.is_submitted():
            if form.validate_on_submit():
                with open(file_feedback, 'a') as f:
                    f.write('*****\n')
                    f.write(time.asctime(time.localtime(time.time())) + "\n")
                    categoria = dict(form.category.choices).get(
                        form.category.data)
                    f.write(categoria + '\n')
                    f.write(form.name.data + '\n')
                    f.write(form.email.data + '\n')
                    f.write(form.searched_string.data + '\n')
                    f.write(form.found_string.data + '\n')
                    f.write(form.feedback.data + "\n")
                    f.write('*****\n')
                app.logger.info("feedback inviato")
                return render_template(html_water_file,
                                       geo_type=geo_type,
                                       start_coordx=-1,
                                       searched_name=da,
                                       start_name=start_name,
                                       feedbacksent=1)
            else:
                app.logger.info('errore nel feedback')
                return render_template(html_water_file,
                                       geo_type=geo_type,
                                       start_coordx=-1,
                                       searched_name=da,
                                       start_name=start_name,
                                       form=form,
                                       feedbacksent=0)
    else:
        app.logger.info(
            'grazie per aver mandato il tuo indirizzo in find_address')
        if da == '':
            print('primo caricamento')
            app.logger.info('grazie per aver aperto find_address')
            temp = render_template(html_water_file,
                                   results_dictionary="None",
                                   form=form,
                                   feedbacksent=0)
            app.logger.info(
                'ci ho messo {tot} a caricare la prima volta'.format(
                    tot=time.perf_counter() - t0))
            return temp
        elif a == '':
            app.logger.debug('indirizzo: {}'.format(da))
            match_dict = find_address_in_db(da)
            # per ora usiamo solo la coordinata (nel caso di un poligono ritorno il centroide) e il nome, ma poi cambieremo
            app.logger.info(
                'ci ho messo {tot} a calcolare la posizione degli indirizzi'.
                format(tot=time.perf_counter() - t0))
            # 0 significa che stiamo ritornando un indirizzo singolo
            final_dict = prepare_our_message_to_javascript(
                0, da, match_dict)  # aggiunge da solo "no_path" e "no_end"
            print(final_dict)
            #dict_test = {"test":"ma va", "geotype":"0"}
            return render_template(html_water_file,
                                   form=form,
                                   results_dictionary=final_dict,
                                   feedbacksent=0)
        else:
            t0 = time.perf_counter()
            match_dict_da = find_address_in_db(da)
            match_dict_a = find_address_in_db(a)
            app.logger.info(
                'ci ho messo {tot} a calcolare la posizione degli indirizzi'.
                format(tot=time.perf_counter() - t0))
            [start_coord, stop_coord
             ] = find_closest_nodes([match_dict_da[0], match_dict_a[0]],
                                    G_terra_array)
            #rive_vicine=PoiCategoryType.query.filter_by(name="Riva").one().pois.join(Location).filter(and_(db.between(Location.longitude,start_coord[0]-0.0003,start_coord[0]+0.0003),db.between(Location.latitude,start_coord[1]-0.003,start_coord[1]+0.003))).all()
            #per tutti gli accessi all'acqua
            rive_vicine = []
            #app.logger.info("cerco le rive vicine")
            rive_vicine_start, how_many_start = find_POI(
                min_number_of_rive, start_coord, name_of_rive_as_poi)
            #while len(rive_vicine)<10:
            #    app.logger.info("increasing proximity")
            #    proximity += [0.005,0.005]
            #    rive_vicine=Poi.query.join(poi_types).join(PoiCategoryType).join(PoiCategory).filter_by(name="vincolo").join(Location).filter(and_(db.between(Location.longitude,start_coord[0]-proximity[0],start_coord[0]+proximity[0]),db.between(Location.latitude,start_coord[1]-proximity[1],start_coord[1]+proximity[1]))).all()
            app.logger.info(
                "rive vicine alla partenza: {}".format(how_many_start))
            rive_start_list = [{
                "coordinate": (riva.location.longitude, riva.location.latitude)
            } for riva in rive_vicine_start]
            rive_start_nodes_list = find_closest_nodes(rive_start_list,
                                                       G_terra_array)
            start_path = find_path_to_closest_riva(G_terra, start_coord,
                                                   rive_start_nodes_list)
            #print("start path", start_path)
            riva_start = start_path[-1]
            #print("riva start", riva_start)
            # per le rive vere e prorie
            # PoiCategoryType.query.filter_by(name="Riva").one().pois.join(Location).filter(and_(db.between(Location.longitude,stop_coord[0]-0.003,stop_coord[0]+0.003),db.between(Location.latitude,stop_coord[1]-0.03,stop_coord[1]+0.03))).all()
            #rive_vicine_stop=[]
            #while len(rive_vicine_stop)<10:
            #    print("increasing proximity")
            #    proximity += [0.005,0.005]
            #    print(proximity)
            #    rive_vicine_stop=Poi.query.join(poi_types).join(PoiCategoryType).join(PoiCategory).filter_by(name="vincolo").join(Location).filter(and_(db.between(Location.longitude,stop_coord[0]-proximity[0],stop_coord[0]+proximity[0]),db.between(Location.latitude,stop_coord[1]-proximity[1],stop_coord[1]+proximity[1]))).all()
            rive_vicine_stop, how_many_stop = find_POI(min_number_of_rive,
                                                       stop_coord,
                                                       name_of_rive_as_poi)
            app.logger.info("rive vicine all'arrivo: {}".format(how_many_stop))
            rive_stop_list = [{
                "coordinate": (riva.location.longitude, riva.location.latitude)
            } for riva in rive_vicine_stop]
            rive_stop_nodes_list = find_closest_nodes(rive_stop_list,
                                                      G_terra_array)
            stop_path = find_path_to_closest_riva(G_terra, stop_coord,
                                                  rive_stop_nodes_list)
            riva_stop = stop_path[-1]
            #print("riva stop", riva_stop)
            if request.form.get('meno_ponti'):
                f_ponti = True
            else:
                f_ponti = False
            t2 = time.perf_counter()
            # per i casi in cui abbiamo il civico qui andrà estratta la prima coordinate della shape... Stiamo ritornando la shape in quei casi?!? Servirà a java per disegnare il percorso completo!
            # lista degli archi
            list_of_edges_node_with_their_distance = find_closest_edge(
                [riva_start, riva_stop], G_acqua)
            # aggiungere gli archi!
            list_of_added_edges = pyAny_lib.dynamically_add_edges(
                G_acqua, list_of_edges_node_with_their_distance,
                [riva_start, riva_stop])
            #print(list_of_added_edges)
            # trova la strada
            strada, length = pyAny_lib.calculate_path_wkt(G_acqua,
                                                          riva_start,
                                                          riva_stop,
                                                          flag_ponti=f_ponti)
            # togli gli archi
            pyAny_lib.dynamically_remove_edges(G_acqua, list_of_added_edges)
            #print("path, length", strada, length)
            #trada = add_from_strada_to_porta(strada,match_dict_da[0], match_dict_a[0])
            app.logger.info('ci ho messo {tot} a calcolare la strada'.format(
                tot=time.perf_counter() - t2))
            # 1 significa che stiamo ritornando un percorso da plottare
            #strada_totale = add_from_strada_to_porta(strada_totale,match_dict_da[0], match_dict_a[0])
            path_list_of_dictionaries = [{
                "strada": strada,
                "lunghezza": length,
                "tipo": 1
            }, {
                "strada": start_path,
                "lunghezza": length,
                "tipo": 0
            }, {
                "strada": stop_path,
                "lunghezza": length,
                "tipo": 0
            }]
            final_dict = prepare_our_message_to_javascript(
                1, da + " " + a, [match_dict_da[0]], path_list_of_dictionaries,
                [match_dict_a[0]])  # aggiunge da solo "no_path" e "no_end"
            #print(final_dict)
            return render_template(html_water_file,
                                   form=form,
                                   results_dictionary=final_dict,
                                   feedbacksent=0)
Esempio n. 21
0
def navigation():

    # this could go in a method retrieve_parameters_from_GET
    da = request.args.get('partenza', default='', type=str)
    a = request.args.get('arrivo', default='', type=str)
    # new code! i bottoni sono 'off' o 'on'
    no_bridges = request.args.get('lazy', default='off', type=str)
    by_boat = request.args.get('boat', default='off', type=str)
    with_tide = request.args.get('tide', default='off', type=str)
    by_ambulance = request.args.get('ambu', default='off', type=str)

    # usiamo questo per dirgli cosa disegnare!
    # assumiamo nulla per ora
    geo_type = -2
    f_ponti = False

    # se e stato inviato il form, scriviamo sul feedback file
    # anche questo da spostare su un metodo
    form = FeedbackForm()
    form.searched_string.data = da
    t0 = time.perf_counter()
    if request.method == 'POST':
        if form.is_submitted():
            if form.validate_on_submit():
                with open(file_feedback, 'a') as f:
                    f.write('*****\n')
                    f.write(time.asctime(time.localtime(time.time())) + "\n")
                    categoria = dict(form.category.choices).get(
                        form.category.data)
                    f.write(categoria + '\n')
                    f.write(form.name.data + '\n')
                    f.write(form.email.data + '\n')
                    f.write(form.searched_string.data + '\n')
                    f.write(form.found_string.data + '\n')
                    f.write(form.feedback.data + "\n")
                    f.write('*****\n')
                app.logger.info("feedback inviato")
                return render_template(html_file,
                                       geo_type=geo_type,
                                       start_coordx=-1,
                                       searched_name=da,
                                       start_name=start_name,
                                       feedbacksent=1)
            else:
                app.logger.info('errore nel feedback')
                return render_template(html_file,
                                       geo_type=geo_type,
                                       start_coordx=-1,
                                       searched_name=da,
                                       start_name=start_name,
                                       form=form,
                                       feedbacksent=0)

    # altrimenti, dobbiamo fare qualocsa
    else:
        #app.logger.info('grazie per aver mandato il tuo indirizzo in find_address')
        if da == '':
            app.logger.info('just loading the page')
            temp = render_template(html_file,
                                   results_dictionary="None",
                                   form=form,
                                   feedbacksent=0)
            app.logger.info(
                'ci ho messo {tot} a caricare la pagina senza ricerche'.format(
                    tot=time.perf_counter() - t0))
            return temp
        elif a == '':
            app.logger.debug('ricerca singolo indirizzo: {}'.format(da))
            match_dict = find_address_in_db(da)
            # per ora usiamo solo la coordinata (nel caso di un poligono ritorno il centroide) e il nome, ma poi cambieremo
            app.logger.info(
                'ci ho messo {tot} a calcolare la posizione degli indirizzi'.
                format(tot=time.perf_counter() - t0))
            # 0 significa che stiamo ritornando un indirizzo singolo
            final_dict = prepare_our_message_to_javascript(
                0, da, match_dict)  # aggiunge da solo "no_path" e "no_end"
            app.logger.debug(final_dict)
            #dict_test = {"test":"ma va", "geotype":"0"}
            return render_template(html_file,
                                   form=form,
                                   results_dictionary=final_dict,
                                   feedbacksent=0)
        else:
            t0 = time.perf_counter()
            match_dict_da = find_address_in_db(da)
            match_dict_a = find_address_in_db(a)
            app.logger.info("ricerca percorso da {} a {}".format(da, a))
            app.logger.info(
                'ci ho messo {tot} a calcolare la posizione degli indirizzi'.
                format(tot=time.perf_counter() - t0))

            # cerchiamo in acqua?
            if by_boat == 'on':
                app.logger.info("andiamo in barca..")
                # anche qua, spostare in un metodo
                proximity = [0.002, 0.002]
                min_number_of_rive = 10
                name_of_rive_as_poi = "vincolo"
                [start_coord, stop_coord
                 ] = find_closest_nodes([match_dict_da[0], match_dict_a[0]],
                                        G_terra_array)
                #per tutti gli accessi all'acqua
                rive_vicine = []
                rive_vicine_start, how_many_start = find_POI(
                    min_number_of_rive, start_coord, name_of_rive_as_poi)
                app.logger.info(
                    "rive vicine alla partenza: {}".format(how_many_start))
                rive_start_list = [{
                    "coordinate":
                    (riva.location.longitude, riva.location.latitude)
                } for riva in rive_vicine_start]
                rive_start_nodes_list = find_closest_nodes(
                    rive_start_list, G_terra_array)
                # ritorna la strada con properties e la riva scelta!
                geojson_path_from_land_to_water, riva_start = find_path_to_closest_riva(
                    G_terra, start_coord, rive_start_nodes_list)
                #    rive_vicine_stop=Poi.query.join(poi_types).join(PoiCategoryType).join(PoiCategory).filter_by(name="vincolo").join(Location).filter(and_(db.between(Location.longitude,stop_coord[0]-proximity[0],stop_coord[0]+proximity[0]),db.between(Location.latitude,stop_coord[1]-proximity[1],stop_coord[1]+proximity[1]))).all()
                rive_vicine_stop, how_many_stop = find_POI(
                    min_number_of_rive, stop_coord, name_of_rive_as_poi)
                app.logger.info(
                    "rive vicine all'arrivo: {}".format(how_many_stop))
                rive_stop_list = [{
                    "coordinate":
                    (riva.location.longitude, riva.location.latitude)
                } for riva in rive_vicine_stop]
                rive_stop_nodes_list = find_closest_nodes(
                    rive_stop_list, G_terra_array)
                # ritorna la strada con properties e la riva scelta!
                geojson_path_from_water_to_land, riva_stop = find_path_to_closest_riva(
                    G_terra, stop_coord, rive_stop_nodes_list)
                #print("riva stop", riva_stop)
                t2 = time.perf_counter()
                # per i casi in cui abbiamo il civico qui andrà estratta la prima coordinate della shape... Stiamo ritornando la shape in quei casi?!? Servirà a java per disegnare il percorso completo!
                # lista degli archi
                list_of_edges_node_with_their_distance = find_closest_edge(
                    [riva_start, riva_stop], G_acqua)
                # aggiungere gli archi!
                list_of_added_edges = pyAny_lib.dynamically_add_edges(
                    G_acqua, list_of_edges_node_with_their_distance,
                    [riva_start, riva_stop])
                # trova la strada
                water_streets_info = pyAny_lib.give_me_the_street(
                    G_acqua,
                    riva_start,
                    riva_stop,
                    flag_ponti=False,
                    water_flag=True)
                app.logger.debug("the dictionary with all the info: {}".format(
                    water_streets_info))
                # togli gli archi
                pyAny_lib.dynamically_remove_edges(G_acqua,
                                                   list_of_added_edges)
                #print("path, length", strada, length)
                #trada = add_from_strada_to_porta(strada,match_dict_da[0], match_dict_a[0])
                app.logger.info(
                    'ci ho messo {tot} a calcolare la strada'.format(
                        tot=time.perf_counter() - t2))
                # 1 significa che stiamo ritornando un percorso da plottare
                #strada_totale = add_from_strada_to_porta(strada_totale,match_dict_da[0], match_dict_a[0])
                # una lista con il dizionario che ha tutte le info sulle strade (una lista perche usiamo un ciclo di la su js)
                path_list_of_dictionaries = [
                    geojson_path_from_land_to_water, water_streets_info,
                    geojson_path_from_water_to_land
                ]
                #path_list_of_dictionaries=[{"strada":strada, "lunghezza":length, "tipo":1},{"strada":start_path, "lunghezza":length, "tipo":0},{"strada":stop_path, "lunghezza":length, "tipo":0}]
                #final_dict = prepare_our_message_to_javascript(1, da+" "+a,[match_dict_da[0]], path_list_of_dictionaries, [match_dict_a[0]]) # aggiunge da solo "no_path" e "no_end"
                #print(final_dict)
                #return render_template(html_file, form=form, results_dictionary=final_dict, feedbacksent=0)

            else:  # cerchiamo per terra
                app.logger.info("andiamo a piedi..")
                t0 = time.perf_counter()
                # per i casi in cui abbiamo il civico qui andrà estratta la prima coordinate della shape... Stiamo ritornando la shape in quei casi?!? Servirà a java per disegnare il percorso completo!
                [start_coord, stop_coord
                 ] = find_closest_nodes([match_dict_da[0], match_dict_a[0]],
                                        G_terra_array)
                app.logger.info(
                    'ci ho messo {tot} a trovare il nodo piu vicino'.format(
                        tot=time.perf_counter() - t0))
                if no_bridges == 'on':
                    f_ponti = True
                    app.logger.info("con meno ponti possibile!")
                t2 = time.perf_counter()
                streets_info = pyAny_lib.give_me_the_street(G_terra,
                                                            start_coord,
                                                            stop_coord,
                                                            flag_ponti=f_ponti)
                app.logger.debug(streets_info)
                #print("path, length", strada, length)
                streets_info = add_from_strada_to_porta(
                    streets_info, match_dict_da[0], match_dict_a[0])
                app.logger.info(
                    'ci ho messo {tot} a calcolare la strada'.format(
                        tot=time.perf_counter() - t2))
                streets_info['tipo'] = 0
                # una lista con il dizionario che ha tutte le info sulle strade (una lista perche usiamo un ciclo di la su js)
                path_list_of_dictionaries = [streets_info]

            # prepara il messaggio da mandare a javascript
            final_dict = prepare_our_message_to_javascript(
                1, da + " " + a, [match_dict_da[0]], path_list_of_dictionaries,
                [match_dict_a[0]])
            return render_template(html_file,
                                   form=form,
                                   results_dictionary=final_dict,
                                   feedbacksent=0)
Esempio n. 22
0
def index():
    form = FeedbackForm()
    return render_template('index.html', form=form)
 def get_form() -> FeedbackForm:
     return FeedbackForm()
Esempio n. 24
0
def feedback():
    form = FeedbackForm()
    if form.validate_on_submit():
        return redirect(url_for('home'))
    return render_template('feedback.html', title='Feedback', form=form)
Esempio n. 25
0
def contact():
    form = FeedbackForm()
    if form.validate_on_submit():
        flash('Your feedback is very important to us, thank you!')
    return render_template('contact.html', title='Contact', form=form)