コード例 #1
0
def schools(request, page):
    template = loader.get_template("browse/schools.html")
    context = RequestContext(request)
    context["schoolForm"] = SchoolForm()

    # Get our page numbers to display, our page, all objects, and the
    # range of that all we're going to send back.
    context["pages"], context["page"], all, start, end = paginate(page, School)
    context["schools"] = all[start:end]

    return HttpResponse(template.render(context))
コード例 #2
0
def reports(request, page):
    template = loader.get_template("browse/reports.html")
    context = RequestContext(request)

    reports = []
    context["reports"] = reports
    context["pages"], context["page"], all, start, end \
        = paginate(page, Report, "-target_log__created_ts")

    for p in Report.objects.order_by('-target_log__created_ts')[start:end]:
        reports.append(p)

    return HttpResponse(template.render(context))
コード例 #3
0
def professors(request, page):
    template = loader.get_template("browse/professors.html")
    context = RequestContext(request)
    context["schoolForm"] = SchoolForm()

    professors = []
    context["professors"] = professors
    context["pages"], context["page"], all, start, end = paginate(page,
                                                                  Professor)

    for p in Professor.objects.order_by('-created_ts')[start:end]:
        professors.append(p)

    return HttpResponse(template.render(context))
コード例 #4
0
def logs(request, page=0):
    """
    The view for listing all log entries.
    """
    template = "browse/logs.html"
    context = {}

    logs = []
    context["logs"] = logs
    context["pages"], context["page"], all, start, end \
        = paginate(page, Log, "-created_ts", 15)

    for p in Log.objects.order_by('-created_ts')[start:end]:
        logs.append(p)

    return render(request, template, context)
コード例 #5
0
def reviews(request, type="all", first_id=None, second_id=None, page=1):
    """
    This is the general-purpose review-viewing page. It allows for returning
    views of specific requests from the user.

    :Parameters:
        * *page*: (``int``) --
            The page to start listing from.
        * *type*: (``str``) --
            The type of review view page to get. Valid types are:
                * all (default)
                * by_school
                * by_professor
                * by_school_professor
        * *first_id*: (``int``) --
            The first id of the requested view type (ie professor).
        * *second_id*: (``int``) --
            The second id of the requested view type (ie school).
    """
    template = "browse/reviews.html"
    context = RequestContext(request)
    context["pages"], context["page"], all, start, end = paginate(page, Review)
    context["review_votes"] = _get_all_review_votes(request)[start:end]
    context["schoolForm"] = SchoolForm()

    if type == "by_school":
        context["message"] =\
            "This is the page that lists all reviews for school {1}"\
            "(pg {0}).".format(page, first_id)
    elif type == "by_professor":
        context["message"] =\
            "This is the page that lists all reviews for professor"\
            " {1} (pg {0}).".format(page, first_id)

    elif type == "by_school_professor":
        context["message"] =\
            "This is the page for reviews of professor {1} from "\
            "school {0} (pg {2})."\
            .format(first_id, second_id, page)
    else:
        context["message"] =\
            "This is the page that lists all reviews (pg {0})."\
            .format(page)
    return render(request, template, context)