Tidy up the views, remove unneeded checks

This commit is contained in:
2011-01-13 13:00:45 +00:00
parent 745642c31c
commit f83d369d4d

View File

@@ -55,23 +55,21 @@ def eveapi_del(request, userid, post_save_redirect='/'):
def eveapi_refresh(request, userid, post_save_redirect='/'): def eveapi_refresh(request, userid, post_save_redirect='/'):
""" Force refresh a EVE API key """ """ Force refresh a EVE API key """
if userid > 0: try:
try: acc = EVEAccount.objects.get(id=userid)
acc = EVEAccount.objects.get(id=userid) except EVEAccount.DoesNotExist:
except EVEAccount.DoesNotExist: pass
pass else:
else: if acc.user == request.user or request.user.is_superuser:
if acc.user == request.user or request.user.is_superuser: task = import_apikey_result.delay(api_key=acc.api_key, api_userid=acc.api_user_id, force_cache=True, user=request.user.id)
task = import_apikey_result.delay(api_key=acc.api_key, api_userid=acc.api_user_id, force_cache=True, user=request.user.id) if request.is_ajax():
try:
if request.is_ajax(): acc = task.wait(30)
try: except celery.exceptions.TimeoutError:
acc = task.wait(30) acc = EVEAccount.objects.get(id=userid)
except celery.exceptions.TimeoutError: return HttpResponse(serializers.serialize('json', [acc]), mimetype='application/javascript')
acc = EVEAccount.objects.get(id=userid) else:
return HttpResponse(serializers.serialize('json', [acc]), mimetype='application/javascript') messages.add_message(request, messages.INFO, "Key %s has been queued to be refreshed from the API" % acc.api_user_id)
else:
messages.add_message(request, messages.INFO, "Key %s has been queued to be refreshed from the API" % acc.api_user_id)
return redirect(post_save_redirect) return redirect(post_save_redirect)
@@ -79,6 +77,7 @@ def eveapi_refresh(request, userid, post_save_redirect='/'):
@login_required @login_required
def eveproxy_log(request, userid): def eveproxy_log(request, userid):
""" Provides a list of access logs for a specific EVE API key """ """ Provides a list of access logs for a specific EVE API key """
try: try:
acc = EVEAccount.objects.get(id=userid) acc = EVEAccount.objects.get(id=userid)
except EVEAccount.DoesNotExist: except EVEAccount.DoesNotExist: