예제 #1
0
def search_result():
    info = None
    form = Search()
    if form.validate_on_submit():
        game_name = form.game_name.data
        info = meta('playstation-4', game_name)
    return render_template('search_result.html', form=form, info=info)
예제 #2
0
def pretraga():
    form = Search()
    if form.validate_on_submit():
        search = form.search.data
        izlet = Izlet.query.filter(Izlet.mjesto.like("%" + search + "%")).all()
        return render_template("pretraga.html", form=form, izlet=izlet)
    izlet = Izlet.query.all()
    return render_template("pretraga.html", form=form, izlet=izlet)
예제 #3
0
def search():
    """ Renders the main page with data based on a user input search """
    # List of dates from search
    date_list = []
    # +/- Sentiment for each date
    pos_sentiment_list = neg_sentiment_list = []
    # Hashtag list from search
    hash_list = []
    # Image handle to allow unique images
    img_handle = []
    # Default search
    search = ' '
    # Init form object
    form = Search()
    # Total tweets each day
    total_search = []
    # If the user sends an HTTP POST method, this means that a search has
    # been done and the program needs to act
    if request.method == 'POST':
        search = request.form['search']
        handle_search_errors(search)
        db = create_large_db('app/database/test.db')
        query = get_query(search, db)
        date_list, pos_sentiment_list, neg_sentiment_list, total_search, hash_list = get_sentiment(
            query)
        img_handle = create_wordcloud(hash_list)

    return render_template('index.html',
                           form=form,
                           labels=date_list,
                           pos_values=pos_sentiment_list,
                           neg_values=neg_sentiment_list,
                           total_search=total_search,
                           title=search,
                           hash_list=json.dumps(hash_list),
                           handle=img_handle)
예제 #4
0
def search():
	form = Search()
	return render_template('form.html', title='Search', form=form)
예제 #5
0
def home():
    form = Search()
    if request.method == 'GET':
        return render_template('homepage.html', form=form)
    if request.method == 'POST':
        return search()
예제 #6
0
def about():
    form = Search()
    return render_template('about.html', form=form)
예제 #7
0
def index():
    form = Search()
    info1 = meta('playstation 4', 'mass effect andromeda')
    info2 = meta('playstation 4', 'horizon zero dawn')
    info3 = meta('playstation 4', 'grand theft auto v')
    return render_template('index.html', form=form, info1=info1, info2=info2, info3=info3)
예제 #8
0
def all():
    set = Set_paid()
    archive = Archive()
    history_cancel = History_cancel()
    history_clear = History_clear()
    search = Search()
    search_close = Search_close()
    deals = get_non_deleted_deals()

    nav = [
        'Все договоры',
        [['Архив', '/archive'], ['Добавить договор', '/add-user'],
         ['Лист неоплативших', '/unpaid'], ['История', '/history'],
         ['Удалить контракт', '/delete']]
    ]
    searched = [{'id': 0, 'number': 0, 'is_arch': 0, 'date': 0, 'paid': 0}]

    status_active = ''
    bcg_stat = ''
    contracts = get_contracts(Contract, 'all')
    print(contracts)

    if set.validate_on_submit() and set.submit.data:
        old = Contract.query.get(set.id.data)
        name_add = str(old.number) + ' продлить на ' + str(
            set.paid.data) + ' с датой ' + str(set.date.data)
        add_deal = Deals(num=old.id,
                         name=name_add,
                         type='0',
                         old_paid=old.paid,
                         old_date=old.date,
                         revert=False,
                         deleted=False)
        to_change = Contract.query.filter_by(id=set.id.data).update({
            'paid':
            set.paid.data,
            'date':
            set.date.data
        })
        db.session.add(add_deal)
        print('Deal type 0 has been added')
        db.session.commit()

        return redirect(url_for('all'))

    if archive.validate_on_submit() and archive.add.data:
        old = Contract.query.get(set.id.data)
        if old.is_arch == 'Действующий':
            to_changes = Contract.query.filter_by(id=set.id.data).update(
                {'is_arch': 'В архиве'})
            name_add = str(old.number) + ' арихивирован'
            add_deal = Deals(num=old.id,
                             name=name_add,
                             type='1',
                             old_paid=old.paid,
                             old_date=old.date,
                             revert=False,
                             deleted=False)
            db.session.add(add_deal)
            db.session.commit()
            return redirect(url_for('all'))

        if old.is_arch == 'В архиве':
            to_changes = Contract.query.filter_by(id=set.id.data).update(
                {'is_arch': 'Действующий'})
            name_add = str(old.number) + ' задействован'
            add_deal = Deals(num=old.id,
                             name=name_add,
                             type='2',
                             old_paid=old.paid,
                             old_date=old.date,
                             revert=False,
                             deleted=False)
            db.session.add(add_deal)
            db.session.commit()
            return redirect(url_for('all'))

    if history_clear.validate_on_submit() and history_clear.clear.data:
        for deal in deals:
            change = Deals.query.filter_by(id=int(deal['id'])).update(
                {'deleted': True})
            db.session.commit()
        return redirect(url_for('all'))

    if history_cancel.validate_on_submit and history_cancel.cancel.data:
        i = 0
        deal = Deals.query.filter_by(id=int(history_cancel.id.data)).first()
        contract_id = int(deal.num)
        contract = Contract.query.get(contract_id)

        if deal.type == 0:
            backed_up = Contract.query.filter_by(id=contract_id).update({
                'date':
                deal.old_date,
                'paid':
                deal.old_paid
            })
            deleted_deal = Deals.query.filter_by(id=int(deal.id)).update({
                'deleted':
                True,
                'revert':
                True
            })

        if deal.type == 1:
            backed_up = Contract.query.filter_by(id=contract_id).update(
                {'is_arch': 'Действющий'})
            deleted_deal = Deals.query.filter_by(id=int(deal.id)).update({
                'deleted':
                True,
                'revert':
                True
            })

        if deal.type == 2:
            backed_up = Contract.query.filter_by(id=contract_id).update(
                {'is_arch': 'В архиве'})
            deleted_deal = Deals.query.filter_by(id=int(deal.id)).update({
                'deleted':
                True,
                'revert':
                True
            })

        db.session.commit()
        return redirect(url_for('all'))

    if search.validate_on_submit() and search.search.data:
        searched = get_contracts_by_id(search.search.data)
        status_active = 'activated'
        bcg_stat = 'search_bcg_active'

    if search_close.validate_on_submit() and search_close.close.data:
        status_active = 'q'
        bcg_stat = 'q'

    return render_template('unpaid.html',
                           contracts=contracts,
                           set=set,
                           archive=archive,
                           nav=nav,
                           history_clear=history_clear,
                           deals=deals,
                           history_cancel=history_cancel,
                           search=search,
                           searched=searched,
                           status_active=status_active,
                           search_close=search_close,
                           bcg_stat=bcg_stat)