def load_techloan_type_to_item(item, tech_type):
    if tech_type["name"]:
        item["name"] = tech_type["name"][:50]
    item["category"] = tech_type["_embedded"]["class"]["category"]
    item["subcategory"] = tech_type["_embedded"]["class"]["name"]

    iei = item["extended_info"]
    if tech_type["description"]:
        iei["i_description"] = utils.clean_html(tech_type["description"][:350])
    iei["i_brand"] = tech_type["make"]
    iei["i_model"] = tech_type["model"]
    if tech_type["manual_url"]:
        iei["i_manual_url"] = tech_type["manual_url"]
    iei["i_checkout_period"] = tech_type["check_out_days"]
    if tech_type["stf_funded"]:
        iei["i_is_stf"] = "true"
    else:
        iei.pop("i_is_stf", None)
    iei["i_quantity"] = tech_type["num_active"]
    iei["i_num_available"] = \
        tech_type["_embedded"]["availability"][0]["num_available"]

    if tech_type["reservable"]:
        iei["i_reservation_required"] = "true"
    else:
        iei.pop("i_reservation_required", None)
    iei["i_access_limit_role"] = "true"
    iei["i_access_role_students"] = "true"
Esempio n. 2
0
def load_techloan_type_to_item(item, tech_type):
    if tech_type["name"]:
        item["name"] = tech_type["name"][:50]
    item["category"] = tech_type["_embedded"]["class"]["category"]
    item["subcategory"] = tech_type["_embedded"]["class"]["name"]

    iei = item["extended_info"]
    if tech_type["description"]:
        iei["i_description"] = utils.clean_html(tech_type["description"][:350])
    iei["i_brand"] = tech_type["make"]
    iei["i_model"] = tech_type["model"]
    if tech_type["manual_url"]:
        iei["i_manual_url"] = tech_type["manual_url"]
    iei["i_checkout_period"] = tech_type["check_out_days"]
    if tech_type["stf_funded"]:
        iei["i_is_stf"] = "true"
    else:
        iei.pop("i_is_stf", None)
    iei["i_quantity"] = tech_type["num_active"]
    iei["i_num_available"] = \
        tech_type["_embedded"]["availability"][0]["num_available"]

    # Kludge, customer type 4 ("UW Student") is the only type which can (and
    # must) be reserved on-line. Otherwise treated as first-come, first-serve.
    if tech_type["customer_type_id"] == 4:
        iei["i_reservation_required"] = "true"
    else:
        iei.pop("i_reservation_required", None)
    iei["i_access_limit_role"] = "true"
    iei["i_access_role_students"] = "true"
Esempio n. 3
0
def load_techloan_type_to_item(item, tech_type):
    if tech_type["name"]:
        item["name"] = tech_type["name"][:50]
    item["category"] = tech_type["_embedded"]["class"]["category"]
    item["subcategory"] = tech_type["_embedded"]["class"]["name"]

    iei = item["extended_info"]
    if tech_type["description"]:
        iei["i_description"] = utils.clean_html(tech_type["description"][:350])
    iei["i_brand"] = tech_type["make"]
    iei["i_model"] = tech_type["model"]
    if tech_type["manual_url"]:
        iei["i_manual_url"] = tech_type["manual_url"]
    iei["i_checkout_period"] = tech_type["check_out_days"]
    if tech_type["stf_funded"]:
        iei["i_is_stf"] = "true"
    else:
        iei.pop("i_is_stf", None)
    iei["i_quantity"] = tech_type["num_active"]
    iei["i_num_available"] = \
        tech_type["_embedded"]["availability"][0]["num_available"]

    if tech_type["reservable"]:
        iei["i_reservation_required"] = "true"
    else:
        iei.pop("i_reservation_required", None)
    iei["i_access_limit_role"] = "true"
    iei["i_access_role_students"] = "true"
    def test_clean_html(self):
        html = ("<strong>Html string</strong>", "<bold>Other html</bold>",)
        cleaned_string = ("Html string", "Other html",)

        for string, cleaned in zip(html, cleaned_string):
            result = utils.clean_html(string)
            self.assertEqual(result, cleaned)
Esempio n. 5
0
    def test_clean_html(self):
        html = (
            "<strong>Html string</strong>",
            "<bold>Other html</bold>",
        )
        cleaned_string = (
            "Html string",
            "Other html",
        )

        for string, cleaned in zip(html, cleaned_string):
            result = utils.clean_html(string)
            self.assertEqual(result, cleaned)