PEP8 of most of the API app

This commit is contained in:
2010-10-26 09:02:05 +01:00
parent 8823217066
commit dee89dff68
6 changed files with 48 additions and 45 deletions

View File

@@ -1,13 +1,15 @@
from django.contrib import admin
from api.models import AuthAPIKey, AuthAPILog
class AuthAPIKeyAdmin(admin.ModelAdmin):
list_display = ('key', 'name', 'url', 'active')
search_fields = ['name']
admin.site.register(AuthAPIKey, AuthAPIKeyAdmin)
class AuthAPILogAdmin(admin.ModelAdmin):
list_display = ('key', 'url', 'access_datetime')
admin.site.register(AuthAPIKey, AuthAPIKeyAdmin)
admin.site.register(AuthAPILog, AuthAPILogAdmin)

View File

@@ -2,6 +2,7 @@ from django.http import HttpResponseForbidden
from django.contrib.auth.models import AnonymousUser
from api.models import AuthAPIKey
class APIKeyAuthentication(object):
def is_authenticated(self, request):
@@ -24,4 +25,3 @@ class APIKeyAuthentication(object):
def challenge(self):
return HttpResponseForbidden('Access Denied, use a API Key')

View File

@@ -98,6 +98,7 @@ class EveAPIHandler(BaseHandler):
return {'keys': s.values('id', 'user_id', 'api_status', 'api_last_updated')}
class EveAPIProxyHandler(BaseHandler):
allowed_methods = ('GET')
@@ -116,6 +117,7 @@ class EveAPIProxyHandler(BaseHandler):
return HttpResponse(cached_doc.body)
class OpTimerHandler(BaseHandler):
allowed_methods = ('GET')
@@ -140,8 +142,7 @@ class OpTimerHandler(BaseHandler):
'isImportant': 0,
'eventText': 'Fuck CCP tbqh imho srsly',
'endsIn':-1,
'forumLink': ''
}]}
'forumLink': ''}]}
events = []
events_node_children = dom.getElementsByTagName('rowset')[0].childNodes
@@ -178,8 +179,7 @@ class OpTimerHandler(BaseHandler):
'isImportant': node.getAttribute('importance'),
'eventText': node.getAttribute('eventText'),
'endsIn':endsIn,
'forumLink': forumlink
}
'forumLink': forumlink}
events.append(event)
if len(events) == 0:
return {'ops':[{
@@ -192,8 +192,6 @@ class OpTimerHandler(BaseHandler):
'isImportant': 0,
'eventText': 'Add ops using EVE-Gate or the in-game calendar',
'endsIn':-1,
'forumLink': ''
}]}
'forumLink': ''}]}
else:
return {'ops':events}

View File

@@ -1,8 +1,9 @@
import uuid
from django.db import models
class AuthAPIKey(models.Model):
""" Auth API Key storage model """
name = models.CharField("Service Name", max_length=200)
url = models.CharField("Service URL", max_length=200, blank=True)
@@ -25,7 +26,9 @@ class AuthAPIKey(models.Model):
verbose_name = 'API Key'
verbose_name_plural = "API Keys"
class AuthAPILog(models.Model):
""" Auth API Access Log """
access_datetime = models.DateTimeField("Date/Time Accessed")
key = models.ForeignKey(AuthAPIKey)

View File

@@ -28,4 +28,3 @@ urlpatterns += patterns('piston.authentication',
url(r'^oauth/authorize/$','oauth_user_auth'),
url(r'^oauth/access_token/$','oauth_access_token'),
)

View File

@@ -1,4 +1,5 @@
from django.http import HttpResponse
def oauth_callback(request, other):
return HttpResponse('Fake callback view.')