def year(request, year, queryset=None,
    template_name="jellyroll/calendar/year.html", template_loader=loader,
    extra_context=None, context_processors=None, mimetype=None):
    """
    Jellyroll'd items for a particular year.

    Works a bit like a generic view in that you can pass a bunch of optional
    keyword arguments which work just like they do in generic views. Those
    arguments are: ``template_name``, ``template_loader``, ``extra_context``,
    ``context_processors``, and ``mimetype``.
    
    You can also pass a ``queryset`` argument; see the module's docstring
    for information about how that works.

    Templates: ``jellyroll/calendar/year.html`` (default)
    Context:
        ``items``
            Items from the year, earliest first.
        ``year``
            The year.
        ``previous``
            The previous year; ``None`` if that year was before jellyrolling
            started..
        ``previous_link``
            Link to the previous year
        ``next``
            The next year; ``None`` if it's in the future.
        ``next_year``
            Link to the next year
    """
    # Make sure we've requested a valid year
    year = int(year)
    try:
        first = Item.objects.order_by("timestamp")[0]
    except __HOLE__:
        raise Http404("No items; no views.")
    today = datetime.date.today()
    if year < first.timestamp.year or year > today.year:
        raise Http404("Invalid year (%s .. %s)" % (first.timestamp.year, today.year))
    
    # Calculate the previous year
    previous = year - 1
    previous_link = urlresolvers.reverse("jellyroll.views.calendar.year", args=[previous])
    if previous < first.timestamp.year:
        previous = previous_link = None
    
    # And the next year
    next = year + 1
    next_link = urlresolvers.reverse("jellyroll.views.calendar.year", args=[next])
    if next > today.year:
        next = next_link = None
        
    # Handle the initial queryset
    if not queryset:
        queryset = Item.objects.all()
    queryset = queryset.filter(timestamp__year=year)
    if not queryset.query.order_by:
        queryset = queryset.order_by("timestamp")
        
    # Build the context
    context = RequestContext(request, {
        "items"         : queryset.filter(timestamp__year=year).order_by("timestamp"),
        "year"          : year,
        "previous"      : previous,
        "previous_link" : previous_link,
        "next"          : next,
        "next_link"     : next_link
    }, context_processors)
    if extra_context:
        for key, value in extra_context.items():
            if callable(value):
                context[key] = value()
            else:
                context[key] = value
    
    # Load, render, and return
    t = template_loader.get_template(template_name)
    return HttpResponse(t.render(context), mimetype=mimetype)
dataset/ETHPy150Open jacobian-archive/jellyroll/src/jellyroll/views/calendar.py/year