mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Allows API keys added via Admin to be updated, fixes issue #64
This commit is contained in:
@@ -48,3 +48,6 @@ ADMINS = (
|
||||
)
|
||||
MANAGERS = ADMINS
|
||||
|
||||
CELERY_ALWAYS_EAGER = True
|
||||
CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
|
||||
|
||||
|
||||
@@ -24,9 +24,19 @@ char_api_update.short_description = "Update character information from the EVE A
|
||||
class EVEAccountAdmin(admin.ModelAdmin):
|
||||
list_display = ('api_user_id', 'user', 'api_keytype', 'api_status', 'api_last_updated')
|
||||
search_fields = ['api_user_id', 'user__username']
|
||||
readonly_fields = ('api_keytype', 'api_user_id', 'api_key', 'api_status', 'characters', 'api_last_updated', 'characters')
|
||||
readonly_fields = ('api_keytype', 'api_status', 'characters', 'api_last_updated', 'characters')
|
||||
actions = [account_api_update]
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
admin.ModelAdmin.save_model(self, request, obj, form, change)
|
||||
task = import_apikey.delay(api_key=obj.api_key, api_userid=obj.api_user_id)
|
||||
try:
|
||||
task.wait(10)
|
||||
except celery.exceptions.TimeoutError:
|
||||
self.message_user(request, "The API key is queued for update." % obj.api_user_id)
|
||||
except:
|
||||
self.message_user(request, "An error was encountered why updating the API Key")
|
||||
|
||||
admin.site.register(EVEAccount, EVEAccountAdmin)
|
||||
|
||||
class EVEPlayerCharacterAdmin(admin.ModelAdmin):
|
||||
|
||||
Reference in New Issue
Block a user