def home(request): hours = [get_hours(date.today() + timedelta(days=i)) for i in range(3)] blog_posts = [ post for post in get_blog_posts() if timezone.now() - post.published < timedelta(days=365) ][:2] return render_to_response( 'home.html', { 'fulltitle': 'Open Computing Facility at UC Berkeley', 'description': ('The Open Computing Facility is an all-volunteer student ' 'organization dedicated to free and open-source computing for all UC ' 'Berkeley students.' ''), 'staff_hours': get_staff_hours_soonest_first()[:2], 'hours': hours, 'today': hours[0], 'blog_posts': blog_posts, 'lab_status': get_lab_status(), }, context_instance=RequestContext(request), )
def home(request: Any) -> HttpResponse: hours_listing = get_hours_listing() hours = [( date.today() + timedelta(days=i), hours_listing.hours_on_date(date.today() + timedelta(days=i)), ) for i in range(3)] return render( request, 'main/home.html', { 'fulltitle': 'Open Computing Facility at UC Berkeley', 'description': ('The Open Computing Facility is an all-volunteer student ' 'organization dedicated to free and open-source computing for all UC ' 'Berkeley students.'), 'staff_hours': get_staff_hours(), 'hours': hours, 'announcements': sorted( get_blog_posts() + list(announcements), key=attrgetter('datetime'), reverse=True, )[:2], 'today': hours[0], 'lab_status': get_lab_status(), }, )
def home(request): hours = [ get_hours(date.today() + timedelta(days=i)) for i in range(7) ] blog_posts = [ post for post in get_blog_posts() if timezone.now() - post.published < timedelta(days=365) ][:2] return render_to_response( 'home.html', { 'fulltitle': 'Open Computing Facility at UC Berkeley', 'description': ( 'The Open Computing Facility is an all-volunteer student ' 'organization dedicated to free and open-source computing for all UC ' 'Berkeley students.''' ), 'staff_hours': get_staff_hours_soonest_first()[:2], 'hours': hours, 'today': hours[0], 'blog_posts': blog_posts, 'lab_status': get_lab_status(), }, context_instance=RequestContext(request), )
def home(request): try: # fetching blog posts is hella flaky, we don't want to 500 if it fails # TODO: do in a background job to avoid this blog_posts = get_blog_posts()[:2] except RequestException: blog_posts = [] hours = [Day.from_date(date.today() + timedelta(days=i)) for i in range(3)] return render_to_response( 'home.html', { 'fulltitle': 'Open Computing Facility at UC Berkeley', 'description': ( 'The Open Computing Facility is an all-volunteer student ' 'organization dedicated to free and open-source computing for all UC ' 'Berkeley students.' ), 'staff_hours': get_staff_hours(), 'hours': hours, 'today': hours[0], 'blog_posts': blog_posts, 'lab_status': get_lab_status(), }, context_instance=RequestContext(request), )
def index(request): return render( request, 'announcements/index.html', { 'title': 'News from the staff team', 'announcements': announcements, 'blog_posts': get_blog_posts()[:10], }, )
def index(request): return render( request, 'announcements/index.html', { 'title': 'News from the staff team', 'announcements': sorted( announcements, key=lambda announcement: announcement.date, reverse=True, ), 'blog_posts': get_blog_posts()[:10], }, )
def home(request): hours = [Day.from_date(date.today() + timedelta(days=i)) for i in range(3)] return render( request, "main/home.html", { "fulltitle": "Open Computing Facility at UC Berkeley", "description": ( "The Open Computing Facility is an all-volunteer student " "organization dedicated to free and open-source computing for all UC " "Berkeley students." ), "staff_hours": get_staff_hours(), "hours": hours, "today": hours[0], "blog_posts": get_blog_posts()[:2], "lab_status": get_lab_status(), }, )
def home(request): hours = [Day.from_date(date.today() + timedelta(days=i)) for i in range(3)] return render( request, 'main/home.html', { 'fulltitle': 'Open Computing Facility at UC Berkeley', 'description': ( 'The Open Computing Facility is an all-volunteer student ' 'organization dedicated to free and open-source computing for all UC ' 'Berkeley students.' ), 'staff_hours': get_staff_hours(), 'hours': hours, 'today': hours[0], 'blog_posts': get_blog_posts()[:2], 'lab_status': get_lab_status(), }, )
def home(request): hours = [Day.from_date(date.today() + timedelta(days=i)) for i in range(3)] return render( request, 'main/home.html', { 'fulltitle': 'Open Computing Facility at UC Berkeley', 'description': ( 'The Open Computing Facility is an all-volunteer student ' 'organization dedicated to free and open-source computing for all UC ' 'Berkeley students.' ), 'staff_hours': get_staff_hours(), 'hours': hours, 'announcements': sorted( get_blog_posts() + list(announcements), key=attrgetter('datetime'), reverse=True, )[:2], 'today': hours[0], 'lab_status': get_lab_status(), }, )