Esempio n. 1
0
def tweet_upcoming_events(request):
    today = datetime.utcnow() + timedelta(days=0)
    three_days = datetime.utcnow() + timedelta(days=3)
    event_list = (
        event_service.get_event_query_set()
        .filter(date_time_begin__gte=today)
        .filter(date_time_begin__lte=three_days)
        .order_by("date_time_begin")
    )

    for event in event_list:
        must_tweet, prefix = __must_tweet_and_prefix(event)
        if must_tweet:
            tweet = __format_tweet(event, prefix)
            try:
                __tweet_event(tweet)
                __mark_as_tweeted(event, tweet)
                break
            except TweepError, e:
                logging.error(e.reason)
                if e.reason == u"Status is a duplicate.":
                    __mark_as_tweeted(event, tweet + " (duplicate)")
                    break
                else:
                    raise e
Esempio n. 2
0
def tag(request, tag_name):
    event_list = event_service.get_event_query_set().filter(tags=tag_name).order_by('date_time_begin')
    tags = event_service.get_tags()
    page = __get_paginator_page(request, event_list)
    if page == -1:
        return HttpResponseNotFound()
    return render_to_response('events/index.html', {'event_list': page, 'tags': tags, 'tag_name': tag_name}, context_instance=RequestContext(request))
Esempio n. 3
0
def update_archived_flag(request):
    content = []
    event_list = event_service.get_event_query_set().filter(date_time_begin__lte=datetime.utcnow()).order_by('date_time_begin')
    content.append(u'Processing %s events' % event_list.count())
    for event in event_list:
        __update_archived_flag(event, content)
    response = HttpResponse('\n'.join(content))
    return response
Esempio n. 4
0
def ical(request):
    ninety_days = datetime.utcnow() + timedelta(days=90)
    event_list = event_service.get_event_query_set().filter(date_time_begin__lte=ninety_days).order_by('date_time_begin')
    cal = create_calendar_with_metadata()
    for e in event_list:
        event = create_ical_entry(e, request)
        cal.add_component(event)
    response = create_httpresponse(cal.as_string())
    return response
 def items(self):
     return event_service.get_event_query_set()
Esempio n. 6
0
 def items(self):
     today = datetime.utcnow() + timedelta(days=0)
     seven_days = datetime.utcnow() + timedelta(days=7)
     event_list = event_service.get_event_query_set().filter(date_time_begin__gte=today).filter(date_time_begin__lte=seven_days).order_by('date_time_begin')
     return event_list