def retweets(request): profile = request.user.get_profile() api = user_api(profile) twitter_user = api.me() return render(request, 'retweets.html', { 'profile': profile, 'twitter_user': twitter_user, })
def retweet(user_name): profile = UserProfile.objects.get(user__username=user_name) profile.retweet_task_id = retweet.request.id profile.save() api = user_api(profile) try: tweet = retweet_random_favorite_tweet(api) except TweepError, e: raise retweet.retry(exc=e)
def settings_view(request): profile = request.user.get_profile() api = user_api(profile) twitter_user = api.me() form = SettingsForm(request.POST or None, instance=profile.settings) if form.is_valid(): form.save() success(request, 'Updated settings') return redirect(reverse('home')) elif request.POST: error(request, 'Couldn\'t update settings—the form has errors') return render(request, 'settings.html', { 'form': form, 'twitter_user': twitter_user, })