Exemplo n.º 1
0
def other():
    other_search_form = search.OtherSearch()
    if other_search_form.validate_on_submit():
        query = other_search_form.query
        sort = other_search_form.sort
        postcode = other_search_form.postcode
        max_distance = other_search_form.max_distance
        condition = other_search_form.condition
        filters = json.dumps({
            "query": query.data,
            "sort": sort.data,
            "postcode": postcode.data.replace(" ", "").upper(),
            "max distance": max_distance.data,
            "condition": condition.data
        })
        return flask.redirect(flask.url_for("other", filters=filters))
    try:
        filters = json.loads(flask.request.args.get('filters', None))
        displayed_posts = display_posts(posts, component_dict, "other",
                                        filters["query"], filters["sort"],
                                        filters["postcode"],
                                        filters["max distance"],
                                        filters["condition"])
        for post in displayed_posts:
            post["readable time"] = get_time_created(post["time created"])
    except:
        displayed_posts = display_posts(posts, component_dict, "other")
        for post in displayed_posts:
            post["readable time"] = get_time_created(post["time created"])
    return flask.render_template("other_posts.html",
                                 title="Other Posts",
                                 displayed_posts=displayed_posts,
                                 other_search_form=other_search_form)
Exemplo n.º 2
0
def power_supplies():
    psu_search_form = search.PSUSearch()
    psu_search_form.efficiency.choices = [
        (i, i) for i in search.get_choices("psus", "efficiency")
    ]
    psu_search_form.form_factor.choices = [
        (i, i) for i in search.get_choices("psus", "form factor")
    ]
    psu_search_form.wattage.choices = [
        (i, i) for i in search.get_choices("psus", "wattage")
    ]
    psu_search_form.modular.choices = [
        (i, i) for i in search.get_choices("psus", "modular")
    ]
    if psu_search_form.validate_on_submit():
        query = psu_search_form.query
        sort = psu_search_form.sort
        postcode = psu_search_form.postcode
        max_distance = psu_search_form.max_distance
        condition = psu_search_form.condition
        efficiency = psu_search_form.efficiency
        wattage = psu_search_form.wattage
        modular = psu_search_form.modular
        form_factor = psu_search_form.form_factor
        filters = json.dumps({
            "query": query.data,
            "sort": sort.data,
            "postcode": postcode.data.replace(" ", "").upper(),
            "max distance": max_distance.data,
            "condition": condition.data,
            "specific": {
                "efficiency": efficiency.data,
                "wattage": wattage.data,
                "modular": modular.data,
                "form factor": form_factor.data
            }
        })
        return flask.redirect(flask.url_for("power_supplies", filters=filters))
    try:
        filters = json.loads(flask.request.args.get('filters', None))
        displayed_posts = display_posts(posts,
                                        component_dict,
                                        "psus",
                                        query_param=filters["query"],
                                        sort=filters["sort"],
                                        postcode=filters["postcode"],
                                        max_distance=filters["max distance"],
                                        conditions_param=filters["condition"],
                                        filters_param=filters["specific"])
        for post in displayed_posts:
            post["readable time"] = get_time_created(post["time created"])
    except:
        displayed_posts = display_posts(posts, component_dict, "psus")
        for post in displayed_posts:
            post["readable time"] = get_time_created(post["time created"])
    return flask.render_template("psu_posts.html",
                                 title="Power Supply Posts",
                                 displayed_posts=displayed_posts,
                                 psu_search_form=psu_search_form)
Exemplo n.º 3
0
def memory():
    ram_search_form = search.RAMSearch()
    ram_search_form.module_type.choices = [
        (i, i) for i in search.get_choices("ram", "type")
    ]
    ram_search_form.speed.choices = [
        (i, i) for i in search.get_choices("ram", "speed")
    ]
    ram_search_form.size.choices = [(i, i)
                                    for i in search.get_choices("ram", "size")]
    ram_search_form.form_factor.choices = [
        (i, i) for i in search.get_choices("ram", "form factor")
    ]
    if ram_search_form.validate_on_submit():
        query = ram_search_form.query
        sort = ram_search_form.sort
        postcode = ram_search_form.postcode
        max_distance = ram_search_form.max_distance
        condition = ram_search_form.condition
        module_type = ram_search_form.module_type
        speed = ram_search_form.speed
        size = ram_search_form.size
        form_factor = ram_search_form.form_factor
        filters = json.dumps({
            "query": query.data,
            "sort": sort.data,
            "postcode": postcode.data.replace(" ", "").upper(),
            "max distance": max_distance.data,
            "condition": condition.data,
            "specific": {
                "type": module_type.data,
                "speed": speed.data,
                "size": size.data,
                "form factor": form_factor.data
            }
        })
        return flask.redirect(flask.url_for("memory", filters=filters))
    try:
        filters = json.loads(flask.request.args.get('filters', None))
        displayed_posts = display_posts(posts,
                                        component_dict,
                                        "ram",
                                        query_param=filters["query"],
                                        sort=filters["sort"],
                                        postcode=filters["postcode"],
                                        max_distance=filters["max distance"],
                                        conditions_param=filters["condition"],
                                        filters_param=filters["specific"])
        for post in displayed_posts:
            post["readable time"] = get_time_created(post["time created"])
    except:
        displayed_posts = display_posts(posts, component_dict, "ram")
        for post in displayed_posts:
            post["readable time"] = get_time_created(post["time created"])
    return flask.render_template("ram_posts.html",
                                 title="Memory Posts",
                                 displayed_posts=displayed_posts,
                                 ram_search_form=ram_search_form)
Exemplo n.º 4
0
def cpus():
    cpu_search_form = search.CPUSearch()
    cpu_search_form.brand.choices = [
        (i, i) for i in search.get_choices("cpus", "brand")
    ]
    if cpu_search_form.validate_on_submit():
        query = cpu_search_form.query
        sort = cpu_search_form.sort
        postcode = cpu_search_form.postcode
        max_distance = cpu_search_form.max_distance
        condition = cpu_search_form.condition
        brand = cpu_search_form.brand
        filters = json.dumps({
            "query": query.data,
            "sort": sort.data,
            "postcode": postcode.data.replace(" ", "").upper(),
            "max distance": max_distance.data,
            "condition": condition.data,
            "specific": {
                "brand": brand.data
            }
        })
        return flask.redirect(flask.url_for("cpus", filters=filters))
    try:
        filters = json.loads(flask.request.args.get('filters', None))
        displayed_posts = display_posts(posts, component_dict, "cpus",
                                        filters["query"], filters["sort"],
                                        filters["postcode"],
                                        filters["max distance"],
                                        filters["condition"],
                                        filters["specific"])
        for post in displayed_posts:
            post["readable time"] = get_time_created(post["time created"])
    except:
        displayed_posts = display_posts(posts, component_dict, "cpus")
        for post in displayed_posts:
            post["readable time"] = get_time_created(post["time created"])
    return flask.render_template("cpu_posts.html",
                                 title="CPU Posts",
                                 displayed_posts=displayed_posts,
                                 cpu_search_form=cpu_search_form)
Exemplo n.º 5
0
def storage():
    storage_search_form = search.StorageSearch()
    storage_search_form.storage_type.choices = [
        (i, i) for i in search.get_choices("storage", "type")
    ]
    storage_search_form.rpm.choices = [
        (i, i) for i in search.get_choices("storage", "rpm")
    ]
    storage_search_form.size.choices = [
        (i, i) for i in search.get_choices("storage", "size")
    ]
    storage_search_form.form_factor.choices = [
        (i, i) for i in search.get_choices("storage", "form factor")
    ]
    storage_search_form.interface.choices = [
        (i, i) for i in search.get_choices("storage", "interface")
    ]
    if storage_search_form.validate_on_submit():
        query = storage_search_form.query
        sort = storage_search_form.sort
        postcode = storage_search_form.postcode
        max_distance = storage_search_form.max_distance
        condition = storage_search_form.condition
        storage_type = storage_search_form.storage_type
        rpm = storage_search_form.rpm
        size = storage_search_form.size
        form_factor = storage_search_form.form_factor
        interface = storage_search_form.interface
        filters = json.dumps({
            "query": query.data,
            "sort": sort.data,
            "postcode": postcode.data.replace(" ", "").upper(),
            "max distance": max_distance.data,
            "condition": condition.data,
            "specific": {
                "type": storage_type.data,
                "rpm": rpm.data,
                "size": size.data,
                "form factor": form_factor.data,
                "interface": interface.data
            }
        })
        return flask.redirect(flask.url_for("storage", filters=filters))
    try:
        filters = json.loads(flask.request.args.get('filters', None))
        displayed_posts = display_posts(posts,
                                        component_dict,
                                        "storage",
                                        query_param=filters["query"],
                                        sort=filters["sort"],
                                        postcode=filters["postcode"],
                                        max_distance=filters["max distance"],
                                        conditions_param=filters["condition"],
                                        filters_param=filters["specific"])
        for post in displayed_posts:
            post["readable time"] = get_time_created(post["time created"])
    except:
        displayed_posts = display_posts(posts, component_dict, "storage")
        for post in displayed_posts:
            post["readable time"] = get_time_created(post["time created"])
    return flask.render_template("storage_posts.html",
                                 title="Storage Posts",
                                 displayed_posts=displayed_posts,
                                 storage_search_form=storage_search_form)