Ejemplo n.º 1
0
def get_card(url_cid: str, url_semester: str):
    """课程查询"""
    # decrypt identifier in URL
    try:
        _, card_id = decrypt(url_cid, resource_type='klass')
    except ValueError:
        return render_template("common/error.html",
                               message=MSG_INVALID_IDENTIFIER)

    # RPC to get card
    with tracer.trace('rpc_get_card'):
        try:
            card = Entity.get_card(url_semester, card_id)
        except Exception as e:
            return handle_exception_with_error_page(e)

    day, time = lesson_string_to_tuple(card.lesson)

    # 给“文化素质类”等加上“课”后缀
    if card.type and card.type[-1] != '课':
        card.type = card.type + '课'

    # cotc_id = COTeachingClass.get_id_by_card(card)
    # course_review_doc = CourseReview.get_review(cotc_id)

    return render_template(
        'query/card.html',
        card=card,
        card_day=get_day_chinese(day),
        card_time=get_time_chinese(time),
        show_union_class=not card.union_name.isdigit(),  # 合班名称为数字时不展示合班名称
        # cotc_id=cotc_id,
        # cotc_rating=course_review_doc["avg_rate"],
        cotc_id=0,
        cotc_rating=0,
        current_semester=url_semester)
Ejemplo n.º 2
0
def get_card(semester: str, card_id: str) -> CardResult:
    return Entity.get_card(semester, card_id)