Added retry for the Reddit flair, also some better error checking

This commit is contained in:
2011-08-10 13:51:15 +01:00
parent 9592f3b77d
commit 18da3b1c52
2 changed files with 34 additions and 19 deletions

View File

@@ -293,18 +293,22 @@ def primarychar_change(request):
@login_required
def toggle_reddit_tagging(request):
profile = request.user.get_profile()
profile.tag_reddit_accounts = not profile.tag_reddit_accounts
profile.save()
if profile.tag_reddit_accounts:
tag = 'Enabled'
else:
tag = 'Disabled'
messages.add_message(request, messages.INFO, "Reddit account tagging is now %s" % tag)
if profile.primary_character:
profile.tag_reddit_accounts = not profile.tag_reddit_accounts
profile.save()
if profile.tag_reddit_accounts:
tag = 'Enabled'
else:
tag = 'Disabled'
messages.add_message(request, messages.INFO, "Reddit account tagging is now %s" % tag)
if profile.tag_reddit_accounts:
name = profile.primary_character.name
if profile.tag_reddit_accounts:
name = profile.primary_character.name
else:
name = ''
for acc in request.user.redditaccount_set.all():
update_user_flair.delay(acc.username, name)
else:
name = ''
for acc in request.user.redditaccount_set.all():
update_user_flair.delay(acc.username, name)
messages.add_message(request, messages.ERROR, "You need to set a primary character before using this feature!")
return redirect('sso.views.profile')