Ejemplo n.º 1
0
def new_store():
    if request.method == 'POST':
        name = request.form['name']
        url_prefix = request.form['url_prefix']
        tag_name = request.form['tag_name']
        # converts string into json
        query = json.loads(request.form['query'])

        store = Store(name, url_prefix, tag_name, query)
        store.save_to_mongo()

        return redirect(url_for('.new_store_success'))

    return render_template('stores/new_store.html.j2')
 def __init__(self, name, url, price=None, _id=None):
     store = Store.get_by_url(url)
     self.tag_name = store.tag_name
     self.query = store.query
     self.name = name
     self.url = url
     self._id = uuid.uuid4().hex if not None else _id
     self.price = price if not None else self.load_price()
Ejemplo n.º 3
0
 def __init__(self, name, url, price=None, _id=None):
     self.name = name
     self.url = url
     store = Store.find_by_url(url)
     self.tag_name = store.tag_name
     self.query = store.query
     self.price = None if price is None else price
     self._id = uuid.uuid4().hex if _id is None else _id
Ejemplo n.º 4
0
def create_store():
    if request.method == 'POST':
        name = request.form['name']
        url_prefix = request.form['url_prefix']
        tag_name = request.form['tag_name']
        query = json.loads(request.form['query'])

        Store(name, url_prefix, tag_name, query).save_to_mongo()
        return redirect(url_for('.index'))
    return render_template('stores/new_store.html')
Ejemplo n.º 5
0
def edit_store(store_id):
    store = Store.get_by_id(store_id)
    if request.method == 'POST':
        name = request.form['name']
        url_prefix = request.form['url-prefix']
        tag_name = request.form['tag-name']
        query = json.loads(request.form['query'])

        store = Store.get_by_id(store_id)

        store.name = name
        store.url_prefix = url_prefix
        store.tag_name = tag_name
        store.query = query

        store.save_to_mongo()

        return redirect(url_for('.index'))
    return render_template('stores/edit_store.html', store=store)
Ejemplo n.º 6
0
def create_store():
    if request.method == 'POST':
        name = request.form['name']
        url_prefix = request.form['url_prefix']
        tag_name = request.form['tag_name']
        query = json.loads(request.form['query'])

        Store(name, url_prefix, tag_name, query).save_to_mongo()

    # What happens if it's a GET request
    return render_template("stores/new_store.html")
Ejemplo n.º 7
0
def edit_store(store_id):
    if request.method == 'POST':
        name = request.form['name']
        url_prefix = request.form['url_prefix']
        tag_name = request.form['tag_name']
        query = json.loads(request.form['query'])

        store = Store.get_by_id(store_id)

        store.name = name
        store.url_prefix = url_prefix
        store.tag_name = tag_name
        store.query = query

        store.save_to_mongo()

        return redirect(url_for('.index'))

    # What happens if it's a GET request
    return render_template("stores/edit_store.html",
                           store=Store.get_by_id(store_id))
Ejemplo n.º 8
0
def create_store():
    if request.method == 'POST':
        name = request.form['name']
        url_prefix = request.form['url_prefix']
        tag_name = request.form['tag_name']
        query = json.loads(
            request.form['query']
        )  # converts the string from request into a python dictionary to be used with beautiful soup

        Store(name, url_prefix, tag_name, query).save_to_mongo()

        return redirect(url_for('.index'))
    return render_template('stores/new_store.jinja2')
Ejemplo n.º 9
0
 def __init__(self, name, url, price=None, _id=None):
     self.name = name
     self.url = url
     #self.store = store
     store = Store.get_by_url(url)
     #tag_name = store.get_tag_name()
     #query = store.get_query()
     #tag_name = store.tag_name
     #query = store.query
     self.tag_name = store.tag_name
     self.query = store.query
     #self.price = self.load_price(tag_name, query)
     #self.price = None
     self.price = None if price is None else price
     self._id = uuid.uuid4().hex if _id is None else _id
Ejemplo n.º 10
0
 def __post_init__(self):
     store = Store.find_by_url(self.url)
     self.tag_name = store.tag_name
     self.query = store.query
Ejemplo n.º 11
0
def delete_store(store_id):
    Store.get_by_id(store_id).delete()
    return redirect(url_for('.delete_store_success'))
Ejemplo n.º 12
0
def store_page(store_id):
    return render_template('stores/store.jinja2',
                           store=Store.find_one_store(query_name="_id",
                                                      query=store_id))
Ejemplo n.º 13
0
def index():
    stores = Store.get_all()
    return render_template('stores/store_index.html.j2', stores=stores)
Ejemplo n.º 14
0
def store_page(store_id):
    store = Store.get_by_id(store_id)
    return render_template('stores/store.html.j2', store=store)
Ejemplo n.º 15
0
def delete_store(store_id):
    Store.find_one_store("_id", store_id).delete()
    return redirect(url_for('.index'))
Ejemplo n.º 16
0
def store_page(store_id):
    return render_template('stores/store.html',
                           store=Store.get_by_id(store_id))
Ejemplo n.º 17
0
def index():
    stores = Store.all()
    return render_template('stores/store_index.jinja2', stores=stores)
Ejemplo n.º 18
0
def delete_store(store_id):
    Store.get_by_id(store_id).delete()
Ejemplo n.º 19
0
def delete_store(store_id):
    Store.get_by_id(store_id).remove_from_mongo()