Skip to content

Commit

Permalink
Lint cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
agjohnson committed Apr 25, 2017
1 parent 841c4d5 commit 77fbfe6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 14 additions & 7 deletions readthedocs/integrations/admin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
"""Integration admin models"""

from datetime import datetime, timedelta

from django.contrib import admin
from django.contrib.contenttypes.models import ContentType
from django.core import urlresolvers
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from pygments.formatters import HtmlFormatter

from .models import Integration, HttpExchange
Expand All @@ -16,7 +12,7 @@ def pretty_json_field(field, description, include_styles=False):
# There is some styling here because this is easier than reworking how the
# admin is getting stylesheets. We only need minimal styles here, and there
# isn't much user impact to these styles as well.
def inner(self, obj):
def inner(_, obj):
styles = ''
if include_styles:
formatter = HtmlFormatter(style='colorful')
Expand All @@ -33,6 +29,11 @@ def inner(self, obj):

class HttpExchangeAdmin(admin.ModelAdmin):

"""Admin model for HttpExchange
This adds some read-only display to the admin model.
"""

readonly_fields = [
'date',
'status_code',
Expand Down Expand Up @@ -76,6 +77,12 @@ def failed_icon(self, obj):

class IntegrationAdmin(admin.ModelAdmin):

"""Admin model for Integration
Because of some problems using JSONField with admin model inlines, this
instead just links to the queryset.
"""

search_fields = ('project__slug', 'project__name')
readonly_fields = ['exchanges']

Expand All @@ -86,8 +93,8 @@ def exchanges(self, obj):
just to link to the exchanges.
"""
url = urlresolvers.reverse('admin:{0}_{1}_changelist'.format(
HttpExchange._meta.app_label,
HttpExchange._meta.model_name,
HttpExchange._meta.app_label, # pylint: disable=protected-access
HttpExchange._meta.model_name, # pylint: disable=protected-access
))
return mark_safe('<a href="{0}?{1}={2}">{3} HTTP transactions</a>'.format(
url,
Expand Down
4 changes: 2 additions & 2 deletions readthedocs/integrations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def delete_limit(self, related_object, limit=10):
else:
queryset = self.filter(
content_type=ContentType.objects.get(
app_label=related_object._meta.app_label,
model=related_object._meta.model_name,
app_label=related_object._meta.app_label, # pylint: disable=protected-access
model=related_object._meta.model_name, # pylint: disable=protected-access
),
object_id=related_object.pk
)
Expand Down

0 comments on commit 77fbfe6

Please sign in to comment.