def GroupAddPage(request,account=None): name = request.REQUEST.get('name','') short_name = name.replace(' ','_').lower() member_names = request.REQUEST.get('member_names','') auto_gen = request.REQUEST.get('auto_gen',None) errors = [] if 'POST' == request.method: if auto_gen: return render_to_response('group-add.html', { "user": account, "member_names":member_names, }, context_instance=RequestContext(request)) group = Group.by_short_name_and_user(short_name, account) if group: return render_to_response('group-add.html', { "errors":['A group by the short_name \'' + short_name + '\' already exists for you. Please try another.'], "user": account, "short_name":short_name, "name":name, "member_names":member_names, }, context_instance=RequestContext(request)) people = [] if len(short_name) < 1: errors.append("Please ensure the group name is atleast 1 character long.") for member in member_names.strip().split(','): person = Person.by_screen_name(member) if not person: person = collector.person(member,account) if person: people.append(person) tasks.updatePersonTweets(person,account) else: errors.append("Could not find a user named: " + member) if len(errors) > 0: return render_to_response('group-add.html', { "errors":errors, "user": account, "short_name":short_name, "name":name, "member_names":member_names, }, context_instance=RequestContext(request)) else: group = Group.objects.create(short_name=short_name, user=account, name=name) for person in people: group.members.add(person) group.save() return HttpResponseRedirect('/group') return render_to_response('group-add.html', { 'user': account, },context_instance=RequestContext(request))
def GroupTweets(request,short_name,account=None): group = Group.by_short_name_and_user(short_name, account) terms = None filters = {} if request.REQUEST.get('start'): filters['created_at__gte'] = datetime.strptime(request.REQUEST.get('start'),"%Y-%m-%d") if request.REQUEST.get('end'): filters['created_at__lt'] = datetime.strptime(request.REQUEST.get('end'),"%Y-%m-%d") if request.REQUEST.get('q'): terms = request.REQUEST.get('q').split() statuses = group.statuses(20,0,query=terms,**filters) encodeURLs(statuses, account) return render_to_response('group-tweets.html', {'name':group.name, 'statuses':statuses})
def GroupTweetsAdditional(request,short_name,loadCount=0,account=None): group = Group.by_short_name_and_user(short_name, account) filters = {} terms = None tweetCount = 20 loadCount = tweetCount * int(loadCount) if request.REQUEST.get('start'): filters['created_at__gte'] = datetime.strptime(request.REQUEST.get('start'),"%Y-%m-%d") if request.REQUEST.get('end'): filters['created_at__lt'] = datetime.strptime(request.REQUEST.get('end'),"%Y-%m-%d") if request.REQUEST.get('q'): terms = request.REQUEST.get('q').split() statuses = group.statuses(tweetCount,loadCount,query=terms,**filters) encodeURLs(statuses, account) return render_to_response('group-tweets-additional.html', {'statuses':statuses})
def GroupTweetsAdditional(request, short_name, loadCount=0, account=None): group = Group.by_short_name_and_user(short_name, account) filters = {} terms = None tweetCount = 20 loadCount = tweetCount * int(loadCount) if request.REQUEST.get('start'): filters['created_at__gte'] = datetime.strptime( request.REQUEST.get('start'), "%Y-%m-%d") if request.REQUEST.get('end'): filters['created_at__lt'] = datetime.strptime( request.REQUEST.get('end'), "%Y-%m-%d") if request.REQUEST.get('q'): terms = request.REQUEST.get('q').split() statuses = group.statuses(tweetCount, loadCount, query=terms, **filters) encodeURLs(statuses, account) return render_to_response('group-tweets-additional.html', {'statuses': statuses})
def GroupTweets(request, short_name, account=None): group = Group.by_short_name_and_user(short_name, account) terms = None filters = {} if request.REQUEST.get('start'): filters['created_at__gte'] = datetime.strptime( request.REQUEST.get('start'), "%Y-%m-%d") if request.REQUEST.get('end'): filters['created_at__lt'] = datetime.strptime( request.REQUEST.get('end'), "%Y-%m-%d") if request.REQUEST.get('q'): terms = request.REQUEST.get('q').split() statuses = group.statuses(20, 0, query=terms, **filters) encodeURLs(statuses, account) return render_to_response('group-tweets.html', { 'name': group.name, 'statuses': statuses })
def GroupTweetsBackground(request,short_name,account=None): output = {} group = Group.by_short_name_and_user(short_name, account) output['num_statuses'] = group.status_count() complete = not group.isUpdating() output['complete'] = complete if group.oldestStatus(): output['oldest_date'] = group.oldestStatus().status_date() if group.latestStatus(): output['latest_date'] = group.latestStatus().status_date() if account: output['api_calls'] = account.rate_remaining response = HttpResponse() response.write(simplejson.dumps(output)) return response
def GroupTweetsBackground(request, short_name, account=None): output = {} group = Group.by_short_name_and_user(short_name, account) output['num_statuses'] = group.status_count() complete = not group.isUpdating() output['complete'] = complete if group.oldestStatus(): output['oldest_date'] = group.oldestStatus().status_date() if group.latestStatus(): output['latest_date'] = group.latestStatus().status_date() if account: output['api_calls'] = account.rate_remaining response = HttpResponse() response.write(simplejson.dumps(output)) return response
def GroupPage(request,short_name,account=None): group = Group.by_short_name_and_user(short_name, account) for member in group.members.all(): tasks.updatePersonTweets(member, account) return render_to_response('group.html',{'group':group, 'user':account})
def GroupListPage(request,account=None): groups = Group.by_user(account) return render_to_response('group-list.html', {'user':account, 'groups':groups, })
def GroupPage(request, short_name, account=None): group = Group.by_short_name_and_user(short_name, account) for member in group.members.all(): tasks.updatePersonTweets(member, account) return render_to_response('group.html', {'group': group, 'user': account})
def GroupAddPage(request, account=None): name = request.REQUEST.get('name', '') short_name = name.replace(' ', '_').lower() member_names = request.REQUEST.get('member_names', '') auto_gen = request.REQUEST.get('auto_gen', None) errors = [] if 'POST' == request.method: if auto_gen: return render_to_response('group-add.html', { "user": account, "member_names": member_names, }, context_instance=RequestContext(request)) group = Group.by_short_name_and_user(short_name, account) if group: return render_to_response('group-add.html', { "errors": [ 'A group by the short_name \'' + short_name + '\' already exists for you. Please try another.' ], "user": account, "short_name": short_name, "name": name, "member_names": member_names, }, context_instance=RequestContext(request)) people = [] if len(short_name) < 1: errors.append( "Please ensure the group name is atleast 1 character long.") for member in member_names.strip().split(','): person = Person.by_screen_name(member) if not person: person = collector.person(member, account) if person: people.append(person) tasks.updatePersonTweets(person, account) else: errors.append("Could not find a user named: " + member) if len(errors) > 0: return render_to_response('group-add.html', { "errors": errors, "user": account, "short_name": short_name, "name": name, "member_names": member_names, }, context_instance=RequestContext(request)) else: group = Group.objects.create(short_name=short_name, user=account, name=name) for person in people: group.members.add(person) group.save() return HttpResponseRedirect('/group') return render_to_response('group-add.html', { 'user': account, }, context_instance=RequestContext(request))
def GroupListPage(request, account=None): groups = Group.by_user(account) return render_to_response('group-list.html', { 'user': account, 'groups': groups, })