def load_upcoming_tweet_events(): # so we don't reload events loaded_tweet_google_ids = MCBTweetEvent.objects.values_list( 'google_id', flat=True).exclude(google_id='') #print 'loaded_tweet_google_ids', loaded_tweet_google_ids # retrieve new future events today = datetime.now() events_to_add = CalendarEvent.objects.filter(start_time__gte=today\ , visible=True\ ).exclude(google_id__in=loaded_tweet_google_ids) # process events: # - Iterate through upcoming CalendarEvent objects and create MCBTweetEvent objects # - For lectures and seminars, create 2 MCBTweetEvent objects: # - 1 for the event day # - 1 for a week before the event day # new_tweet_cnt = 0 new_tweets = [] for cal_evt in events_to_add: mcb_tweet = MCBTweetEvent.create_tweet_from_calendar_event(cal_evt) new_tweets.append(mcb_tweet) new_tweet_cnt += 1 if is_potential_lecture(cal_evt.title) or is_potential_lecture( cal_evt.description): #print '\nYes! potential lecture: %s' % cal_evt.title one_week_notice_date = mcb_tweet.tweet_pubdate + timedelta(days=-7) #print 'one_week_notice_date: [%s] today [%s]' % (one_week_notice_date, today) if one_week_notice_date > today: mcb_tweet_copy = copy.copy(mcb_tweet) mcb_tweet_copy.tweet_pubdate = one_week_notice_date mcb_tweet_copy.tweet_text = 'Next Week! %s' % mcb_tweet.tweet_text[: 129] mcb_tweet_copy.id = None mcb_tweet_copy.save() new_tweets.append(mcb_tweet_copy) new_tweet_cnt += 1 print 'new text: %s' % mcb_tweet_copy.tweet_text return new_tweets
def load_upcoming_tweet_events(): # so we don't reload events loaded_tweet_google_ids = MCBTweetEvent.objects.values_list('google_id', flat=True).exclude(google_id='') #print 'loaded_tweet_google_ids', loaded_tweet_google_ids # retrieve new future events today = datetime.now() events_to_add = CalendarEvent.objects.filter(start_time__gte=today\ , visible=True\ ).exclude(google_id__in=loaded_tweet_google_ids) # process events: # - Iterate through upcoming CalendarEvent objects and create MCBTweetEvent objects # - For lectures and seminars, create 2 MCBTweetEvent objects: # - 1 for the event day # - 1 for a week before the event day # new_tweet_cnt = 0 new_tweets = [] for cal_evt in events_to_add: mcb_tweet = MCBTweetEvent.create_tweet_from_calendar_event(cal_evt) new_tweets.append(mcb_tweet) new_tweet_cnt +=1 if is_potential_lecture(cal_evt.title) or is_potential_lecture(cal_evt.description): #print '\nYes! potential lecture: %s' % cal_evt.title one_week_notice_date = mcb_tweet.tweet_pubdate + timedelta(days=-7) #print 'one_week_notice_date: [%s] today [%s]' % (one_week_notice_date, today) if one_week_notice_date > today: mcb_tweet_copy = copy.copy(mcb_tweet) mcb_tweet_copy.tweet_pubdate = one_week_notice_date mcb_tweet_copy.tweet_text = 'Next Week! %s' % mcb_tweet.tweet_text[:129] mcb_tweet_copy.id = None mcb_tweet_copy.save() new_tweets.append(mcb_tweet_copy) new_tweet_cnt+=1 print 'new text: %s' % mcb_tweet_copy.tweet_text return new_tweets
def view_event_list(request, **kwargs): """ Success page after report form has been filled out. """ #lu = get_common_lookup(request) lu = { 'page_title' : 'MCB Event Tweets'\ , 'IS_TWEET_EVENT_PAGE' : True , 'TWEET_SUCCESS' : kwargs.get('success_msg', False) } if not request.user.is_authenticated(): return HttpResponse('not logged in') if not is_user_in_group(request, TWEET_GROUP_NAME): return HttpResponse('not in tweet group') upcoming_events = MCBTweetEvent.get_events_awaiting_approval() lu.update({ 'upcoming_events' : upcoming_events\ #, 'my_checked_codes' : get_previously_checked_expense_codes(request)\ }) # return render_to_response('tweet/events/event_list.html', lu, context_instance=RequestContext(request))