def lab(doc, request): hours_listing = get_hours_listing() return render( request, 'docs/lab.html', { 'title': doc.title, 'description': ('The Open Computing Facility computer lab is a ' 'free and open-source computer lab located on the ' 'UC Berkeley campus, maintained by OCF volunteers.'), 'hours_this_week': [( date.today() + timedelta(days=i), hours_listing.hours_on_date(date.today() + timedelta(days=i)), ) for i in range(7)], 'regular_hours': hours_listing.regular, # Format dates to look like "month day, year" but with non-breaking # spaces (\xa0) instead of spaces so that the date does not get # broken up across lines: # https://docs.djangoproject.com/en/2.0/ref/templates/builtins/#date 'holiday_format': 'M\xa0j,\xa0o', # Only select current and future holidays (any that have not finished fully) 'holidays': [ holiday for holiday in hours_listing.holidays if holiday.enddate >= date.today() ], }, )
def tv_main(request: HttpRequest) -> HttpResponse: return render( request, 'tv/tv.html', { 'hours': get_hours_listing().hours_on_date(), }, )
def tv_main(request): return render( request, 'tv/tv.html', { 'hours': get_hours_listing().hours_on_date(), }, )
def ocf_template_processor(request): hours_listing = get_hours_listing() real_ip, _ = get_client_ip(request) user = logged_in_user(request) return { 'base_css_classes': ' '.join(get_base_css_classes(request)), 'current_lab_hours': hours_listing.hours_on_date(), 'holidays': hours_listing.holidays, 'is_ocf_ip': is_ocf_ip(ip_address(real_ip)) if real_ip else True, 'join_staff_url': request.build_absolute_uri(reverse('about-staff')), 'lab_is_open': hours_listing.is_open(), 'lab_status': get_lab_status(), 'ocfweb_version': ocfweb_version(), 'request_full_path': request.get_full_path(), 'user': user, 'user_is_group': user is not None and user_is_group(user), }