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 ocf_template_processor(request): now = datetime.now() today = date.today() hours = DayHours.from_date(today) return { 'lab_is_open': hours.is_open(now), 'current_lab_hours': hours, 'lab_status': get_lab_status(), }
def staff_hours(request): return render( request, 'main/staff-hours.html', { 'title': 'Staff Hours', 'staff_hours': get_staff_hours(), 'today': time.strftime('%A'), 'lab_status': get_lab_status(), }, )
def ocf_template_processor(request): hours = Day.from_date(date.today()) real_ip = get_real_ip(request) return { 'lab_is_open': hours.is_open(), 'current_lab_hours': hours, 'lab_status': get_lab_status(), 'base_css_classes': ' '.join(get_base_css_classes(request)), 'is_ocf_ip': is_ocf_ip(real_ip) if real_ip else True, 'join_staff_url': request.build_absolute_uri(reverse('about-staff')), }
def staff_hours(request): return render_to_response( 'staff-hours.html', { 'title': 'Staff Hours', 'staff_hours': get_staff_hours(), 'today': time.strftime('%A'), 'lab_status': get_lab_status(), }, context_instance=RequestContext(request), )
def ocf_template_processor(request): hours = Day.from_date(date.today()) real_ip = get_real_ip(request) return { 'lab_is_open': hours.is_open(), 'current_lab_hours': hours, 'lab_status': get_lab_status(), 'base_css_classes': ' '.join(get_base_css_classes(request)), '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')), 'ocfweb_version': ocfweb_version(), }
def ocf_template_processor(request): hours = Day.from_date(date.today()) real_ip = get_real_ip(request) user = logged_in_user(request) return { 'base_css_classes': ' '.join(get_base_css_classes(request)), 'current_lab_hours': hours, '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.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), }
def ocf_template_processor(request: HttpRequest) -> Dict[str, Any]: 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), }
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(), }, )
def ocf_template_processor(request): now = datetime.now() today = date.today() hours = DayHours.from_date(today) base_css_classes = [] if request.resolver_match.url_name: page_class = 'page-' + request.resolver_match.url_name base_css_classes.append(page_class) for arg in request.resolver_match.args: page_class += '-' + re.sub('[^a-zA-Z_\-]', '-', arg) base_css_classes.append(page_class) real_ip = get_real_ip(request) return { 'lab_is_open': hours.is_open(now), 'current_lab_hours': hours, 'lab_status': get_lab_status(), 'base_css_classes': ' '.join(base_css_classes), 'is_ocf_ip': is_ocf_ip(real_ip) if real_ip else True, }