예제 #1
0
 def extra_context(self):
     extra = super(SearchPastView, self).extra_context()
     
     # pass all past events, grouped by date
     extra['grouped_past_results'] = group_events(self.get_results())
     
     return extra
예제 #2
0
    def extra_context(self):
        extra = super(SearchUpcomingView, self).extra_context()
        
        # Removing top results for now, as possibly unhelpful to users. Can reinstate later if desired by uncommenting these lines.
        # extra['top_results'] = self.get_results()[:5]
        
        
        # for top_event in extra['top_results']:
        #     ox_date = date_to_oxford_date(top_event.start)
        #     comps = ox_date.components
        #     date_str = comps['day_name']+ " " +str(comps['day_number'])+ " " +comps['month_long']+ " "
        #     date_str+= str(comps['year'])+ " ("+ str(comps['week']) + comps['ordinal']+ " Week, " +comps['term_long']+ " Term)"
        #     hours = datetime.strftime(top_event.start, '%I')
        #     minutes = datetime.strftime(top_event.start, ':%M')
        #     if minutes==":00":
        #         minutes = ""
        #     ampm = datetime.strftime(top_event.start, '%p')
        #     top_event.oxford_date_time = date_str +" "+ str(int(hours))+minutes+ampm.lower()

        now = datetime.now()
        extra['future_results'] = self.get_results().filter(start__gte=now).order_by('start')

        # return all top results and future_results. These will be displayed on a single page.
        
        extra['grouped_future_results'] = group_events(extra['future_results'])
        
        return extra
예제 #3
0
def view_collection(request, collection_slug):
    collection = Collection.objects.get(slug=collection_slug)
    if collection.public:
        pass
    elif not collection.user_can_view(request.user):
        raise PermissionDenied

    show_all = request.GET.get('show_all', False)
    allEvents = collection.get_all_events().order_by('start')

    if not show_all:
        allEvents = allEvents.filter(start__gte=date.today())

    grouped_events = group_events(allEvents)

    series = collection.get_event_groups().order_by('title')

    collectedDeps = collection.get_departments()
    departments = map(
        lambda cdep: DEPARTMENT_DATA_SOURCE.get_object_by_id(cdep.department),
        collectedDeps)

    collectionContributors = None
    if request.tuser:
        collectionContributors = TalksUser.objects.filter(
            talksusercollection__collection=collection,
            talksusercollection__role=COLLECTION_ROLES_EDITOR)

    collectionOwner = None
    if request.tuser:
        collectionOwner = TalksUser.objects.filter(
            talksusercollection__collection=collection,
            talksusercollection__role=COLLECTION_ROLES_OWNER)

    context = {
        'collection': collection,
        'show_all': show_all,
        'events': allEvents,
        'grouped_events': grouped_events,
        'event_groups': series,
        'contributors': collectionContributors,
        'departments': departments,
        'owner': collectionOwner
    }

    if request.GET.get('format') == 'txt':
        return render(request, 'users/collection_view.txt.html', context)
    else:
        return render(request, 'users/collection_view.html', context)
예제 #4
0
def my_talks(request):
    grouped_events = None
    collections = request.tuser.collections.all()
    if collections:
        user_events = collections[0].get_all_events()
        for collection in collections[1:]:
            user_events = user_events | collection.get_all_events()
        #context['collections'] = collections
        user_events = user_events.filter(start__gte=date.today())
        grouped_events = group_events(user_events)

    context = {'grouped_events': grouped_events}

    if request.GET.get('format') == 'txt':
        return render(request, 'users/my_talks.txt.html', context)
    else:
        return render(request, 'users/my_talks.html', context)
예제 #5
0
파일: views.py 프로젝트: ox-it/talks.ox
def view_collection(request, collection_slug):
    collection = Collection.objects.get(slug=collection_slug)
    if collection.public:
        pass
    elif not collection.user_can_view(request.user):
        raise PermissionDenied

    show_all = request.GET.get('show_all', False)
    allEvents = collection.get_all_events().order_by('start')


    if not show_all:
        allEvents = allEvents.filter(start__gte=date.today())

    grouped_events = group_events(allEvents)

    series = collection.get_event_groups().order_by('title')

    collectedDeps = collection.get_departments()
    departments = map(lambda cdep:DEPARTMENT_DATA_SOURCE.get_object_by_id(cdep.department), collectedDeps)

    collectionContributors = None
    if request.tuser:
        collectionContributors = TalksUser.objects.filter(talksusercollection__collection=collection, talksusercollection__role=COLLECTION_ROLES_EDITOR)

    collectionOwner = None
    if request.tuser:
        collectionOwner = TalksUser.objects.filter(talksusercollection__collection=collection, talksusercollection__role=COLLECTION_ROLES_OWNER)
    
    context = {
        'collection' : collection,
        'show_all' : show_all,
        'events' : allEvents,
        'grouped_events': grouped_events,
        'event_groups' : series,
        'contributors' : collectionContributors,
        'departments' : departments,
        'owner': collectionOwner
    }

    if request.GET.get('format') == 'txt':
        return render(request, 'users/collection_view.txt.html', context)
    else:
        return render(request, 'users/collection_view.html', context)
예제 #6
0
파일: views.py 프로젝트: ox-it/talks.ox
def my_talks(request):
    grouped_events = None
    collections = request.tuser.collections.all()
    if collections:
            user_events = collections[0].get_all_events()
            for collection in collections[1:]:
                user_events = user_events | collection.get_all_events()
            #context['collections'] = collections
            user_events = user_events.filter(start__gte=date.today())
            grouped_events = group_events(user_events)

    context = {
        'grouped_events': grouped_events
    }

    if request.GET.get('format') == 'txt':
        return render(request, 'users/my_talks.txt.html', context)
    else:
        return render(request, 'users/my_talks.html', context)