Esempio n. 1
0
class AuctionsManager:
    def __init__(self, app, database):

        db = SQLAlchemy(app)
        db_session = scoped_session(sessionmaker(autocommit=False,
                                                 autoflush=False,
                                                 bind=db.engine))
        self.database = db_session
        self.items = ItemsService(database=db_session)
        self.auctions = AuctionsService(database=db_session)

    def watch_auctions(self):
        """
        Watches for auctions to complete, and marks the highest bid as won
        """

        # Get all services whos ended field is still 0 and their end date has passed
        services = self.items.get_pending_services()

        for service in services:
            try:
                self.items.mark_service_ended(service.service_id)
            except:
                print('failed to update service')

            if service.winning_bid_id is not None:
                self.auctions.mark_bid_as_won(service.winning_bid_id)

        self.database.close()

    def start(self):
        schedule.every(5).seconds.do(self.watch_auctions)
        while True:
            schedule.run_pending()
            time.sleep(1)
Esempio n. 2
0
class AuctionsManager:
    def __init__(self, app, database):

        db = SQLAlchemy(app)
        db_session = scoped_session(
            sessionmaker(autocommit=False, autoflush=False, bind=db.engine))
        self.database = db_session
        self.items = ItemsService(database=db_session)
        self.auctions = AuctionsService(database=db_session)

    def watch_auctions(self):
        """
        Watches for auctions to complete, and marks the highest bid as won
        """

        # Get all services whos ended field is still 0 and their end date has passed
        services = self.items.get_pending_services()

        for service in services:
            try:
                self.items.mark_service_ended(service.service_id)
            except:
                print('failed to update service')

            if service.winning_bid_id is not None:
                self.auctions.mark_bid_as_won(service.winning_bid_id)

        self.database.close()

    def start(self):
        schedule.every(5).seconds.do(self.watch_auctions)
        while True:
            schedule.run_pending()
            time.sleep(1)
Esempio n. 3
0
    def __init__(self, app, database):

        db = SQLAlchemy(app)
        db_session = scoped_session(
            sessionmaker(autocommit=False, autoflush=False, bind=db.engine))
        self.database = db_session
        self.items = ItemsService(database=db_session)
        self.auctions = AuctionsService(database=db_session)
Esempio n. 4
0
    def __init__(self, app, database):

        db = SQLAlchemy(app)
        db_session = scoped_session(sessionmaker(autocommit=False,
                                                 autoflush=False,
                                                 bind=db.engine))
        self.database = db_session
        self.items = ItemsService(database=db_session)
        self.auctions = AuctionsService(database=db_session)
from flask import abort, Blueprint, flash, request, render_template, redirect, session
from templatesandmoe.modules.core.pagination import Pagination
from templatesandmoe import db_session
from templatesandmoe.modules.items.service import ItemsService
from templatesandmoe.modules.categories.service import CategoriesService
from templatesandmoe.modules.ratings.service import RatingsService
from templatesandmoe.modules.auctions.service import AuctionsService
from templatesandmoe.modules.tags.service import TagsService

itemsModule = Blueprint('items', __name__)
items = ItemsService(database=db_session)
categories = CategoriesService(database=db_session)
ratings = RatingsService(database=db_session)
auctions = AuctionsService(database=db_session)
tags = TagsService(database=db_session)
"""
    Show all templates
"""


@itemsModule.route('/templates/', defaults={'page': 1, 'category': 0})
@itemsModule.route('/templates/<int:category>/page/<int:page>')
def all_templates(category, page):
    price_start = request.args.get('price-start')
    price_end = request.args.get('price-end')
    search = request.args.get('search')

    templates, count = items.get_filtered_templates(page=page,
                                                    templates_per_page=15,
                                                    category=category,
                                                    price_start=price_start,