コード例 #1
0
ファイル: home.py プロジェクト: safetiesoff/ocfweb
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),
    )
コード例 #2
0
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(),
        },
    )
コード例 #3
0
ファイル: home.py プロジェクト: chriskuehl/ocfweb
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),
    )
コード例 #4
0
ファイル: home.py プロジェクト: n-patel/ocfweb
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),
    )
コード例 #5
0
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(),
    }
コード例 #6
0
ファイル: staff_hours.py プロジェクト: ziyaointl/ocfweb
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(),
        },
    )
コード例 #7
0
ファイル: context_processors.py プロジェクト: n-patel/ocfweb
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')),
    }
コード例 #8
0
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),
    )
コード例 #9
0
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(),
    }
コード例 #10
0
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),
    }
コード例 #11
0
ファイル: context_processors.py プロジェクト: jvperrin/ocfweb
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),
    }
コード例 #12
0
ファイル: context_processors.py プロジェクト: sberkun/ocfweb
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),
    }
コード例 #13
0
ファイル: home.py プロジェクト: andycui97/ocfweb
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(),
        },
    )
コード例 #14
0
ファイル: home.py プロジェクト: andycui97/ocfweb
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(),
        },
    )
コード例 #15
0
ファイル: home.py プロジェクト: jvperrin/ocfweb
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(),
        },
    )
コード例 #16
0
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,
    }