Merge pull request #1861 from milmazz/E251
Fixed flake8 E251 violations
This commit is contained in:
commit
91078f5669
|
@ -96,8 +96,8 @@ def result_headers(cl):
|
|||
ordering_field_columns = cl.get_ordering_field_columns()
|
||||
for i, field_name in enumerate(cl.list_display):
|
||||
text, attr = label_for_field(field_name, cl.model,
|
||||
model_admin = cl.model_admin,
|
||||
return_attr = True
|
||||
model_admin=cl.model_admin,
|
||||
return_attr=True
|
||||
)
|
||||
if attr:
|
||||
# Potentially not sortable
|
||||
|
|
|
@ -21,9 +21,9 @@ class LatestCommentFeed(Feed):
|
|||
|
||||
def items(self):
|
||||
qs = comments.get_model().objects.filter(
|
||||
site__pk = self.site.pk,
|
||||
is_public = True,
|
||||
is_removed = False,
|
||||
site__pk=self.site.pk,
|
||||
is_public=True,
|
||||
is_removed=False,
|
||||
)
|
||||
return qs.order_by('-submit_date')[:40]
|
||||
|
||||
|
|
|
@ -132,16 +132,16 @@ class CommentDetailsForm(CommentSecurityForm):
|
|||
method to add extra fields onto a custom comment model.
|
||||
"""
|
||||
return dict(
|
||||
content_type = ContentType.objects.get_for_model(self.target_object),
|
||||
object_pk = force_text(self.target_object._get_pk_val()),
|
||||
user_name = self.cleaned_data["name"],
|
||||
user_email = self.cleaned_data["email"],
|
||||
user_url = self.cleaned_data["url"],
|
||||
comment = self.cleaned_data["comment"],
|
||||
submit_date = timezone.now(),
|
||||
site_id = settings.SITE_ID,
|
||||
is_public = True,
|
||||
is_removed = False,
|
||||
content_type=ContentType.objects.get_for_model(self.target_object),
|
||||
object_pk=force_text(self.target_object._get_pk_val()),
|
||||
user_name=self.cleaned_data["name"],
|
||||
user_email=self.cleaned_data["email"],
|
||||
user_url=self.cleaned_data["url"],
|
||||
comment=self.cleaned_data["comment"],
|
||||
submit_date=timezone.now(),
|
||||
site_id=settings.SITE_ID,
|
||||
is_public=True,
|
||||
is_removed=False,
|
||||
)
|
||||
|
||||
def check_for_duplicate_comment(self, new):
|
||||
|
@ -152,11 +152,11 @@ class CommentDetailsForm(CommentSecurityForm):
|
|||
possible_duplicates = self.get_comment_model()._default_manager.using(
|
||||
self.target_object._state.db
|
||||
).filter(
|
||||
content_type = new.content_type,
|
||||
object_pk = new.object_pk,
|
||||
user_name = new.user_name,
|
||||
user_email = new.user_email,
|
||||
user_url = new.user_url,
|
||||
content_type=new.content_type,
|
||||
object_pk=new.object_pk,
|
||||
user_name=new.user_name,
|
||||
user_email=new.user_email,
|
||||
user_url=new.user_url,
|
||||
)
|
||||
for old in possible_duplicates:
|
||||
if old.submit_date.date() == new.submit_date.date() and old.comment == new.comment:
|
||||
|
|
|
@ -35,8 +35,8 @@ class BaseCommentNode(six.with_metaclass(RenameBaseCommentNodeMethods, template.
|
|||
if tokens[3] != 'as':
|
||||
raise template.TemplateSyntaxError("Third argument in %r must be 'as'" % tokens[0])
|
||||
return cls(
|
||||
object_expr = parser.compile_filter(tokens[2]),
|
||||
as_varname = tokens[4],
|
||||
object_expr=parser.compile_filter(tokens[2]),
|
||||
as_varname=tokens[4],
|
||||
)
|
||||
|
||||
# {% get_whatever for app.model pk as varname %}
|
||||
|
@ -44,9 +44,9 @@ class BaseCommentNode(six.with_metaclass(RenameBaseCommentNodeMethods, template.
|
|||
if tokens[4] != 'as':
|
||||
raise template.TemplateSyntaxError("Fourth argument in %r must be 'as'" % tokens[0])
|
||||
return cls(
|
||||
ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
|
||||
object_pk_expr = parser.compile_filter(tokens[3]),
|
||||
as_varname = tokens[5]
|
||||
ctype=BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
|
||||
object_pk_expr=parser.compile_filter(tokens[3]),
|
||||
as_varname=tokens[5]
|
||||
)
|
||||
|
||||
else:
|
||||
|
@ -83,9 +83,9 @@ class BaseCommentNode(six.with_metaclass(RenameBaseCommentNodeMethods, template.
|
|||
return self.comment_model.objects.none()
|
||||
|
||||
qs = self.comment_model.objects.filter(
|
||||
content_type = ctype,
|
||||
object_pk = smart_text(object_pk),
|
||||
site__pk = settings.SITE_ID,
|
||||
content_type=ctype,
|
||||
object_pk=smart_text(object_pk),
|
||||
site__pk=settings.SITE_ID,
|
||||
)
|
||||
|
||||
# The is_public and is_removed fields are implementation details of the
|
||||
|
@ -166,8 +166,8 @@ class RenderCommentFormNode(CommentFormNode):
|
|||
# {% render_comment_form for app.models pk %}
|
||||
elif len(tokens) == 4:
|
||||
return cls(
|
||||
ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
|
||||
object_pk_expr = parser.compile_filter(tokens[3])
|
||||
ctype=BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
|
||||
object_pk_expr=parser.compile_filter(tokens[3])
|
||||
)
|
||||
|
||||
def render(self, context):
|
||||
|
@ -202,8 +202,8 @@ class RenderCommentListNode(CommentListNode):
|
|||
# {% render_comment_list for app.models pk %}
|
||||
elif len(tokens) == 4:
|
||||
return cls(
|
||||
ctype = BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
|
||||
object_pk_expr = parser.compile_filter(tokens[3])
|
||||
ctype=BaseCommentNode.lookup_content_type(tokens[2], tokens[0]),
|
||||
object_pk_expr=parser.compile_filter(tokens[3])
|
||||
)
|
||||
|
||||
def render(self, context):
|
||||
|
|
|
@ -99,40 +99,40 @@ def perform_flag(request, comment):
|
|||
Actually perform the flagging of a comment from a request.
|
||||
"""
|
||||
flag, created = comments.models.CommentFlag.objects.get_or_create(
|
||||
comment = comment,
|
||||
user = request.user,
|
||||
flag = comments.models.CommentFlag.SUGGEST_REMOVAL
|
||||
comment=comment,
|
||||
user=request.user,
|
||||
flag=comments.models.CommentFlag.SUGGEST_REMOVAL
|
||||
)
|
||||
signals.comment_was_flagged.send(
|
||||
sender = comment.__class__,
|
||||
comment = comment,
|
||||
flag = flag,
|
||||
created = created,
|
||||
request = request,
|
||||
sender=comment.__class__,
|
||||
comment=comment,
|
||||
flag=flag,
|
||||
created=created,
|
||||
request=request,
|
||||
)
|
||||
|
||||
def perform_delete(request, comment):
|
||||
flag, created = comments.models.CommentFlag.objects.get_or_create(
|
||||
comment = comment,
|
||||
user = request.user,
|
||||
flag = comments.models.CommentFlag.MODERATOR_DELETION
|
||||
comment=comment,
|
||||
user=request.user,
|
||||
flag=comments.models.CommentFlag.MODERATOR_DELETION
|
||||
)
|
||||
comment.is_removed = True
|
||||
comment.save()
|
||||
signals.comment_was_flagged.send(
|
||||
sender = comment.__class__,
|
||||
comment = comment,
|
||||
flag = flag,
|
||||
created = created,
|
||||
request = request,
|
||||
sender=comment.__class__,
|
||||
comment=comment,
|
||||
flag=flag,
|
||||
created=created,
|
||||
request=request,
|
||||
)
|
||||
|
||||
|
||||
def perform_approve(request, comment):
|
||||
flag, created = comments.models.CommentFlag.objects.get_or_create(
|
||||
comment = comment,
|
||||
user = request.user,
|
||||
flag = comments.models.CommentFlag.MODERATOR_APPROVAL,
|
||||
comment=comment,
|
||||
user=request.user,
|
||||
flag=comments.models.CommentFlag.MODERATOR_APPROVAL,
|
||||
)
|
||||
|
||||
comment.is_removed = False
|
||||
|
@ -140,24 +140,24 @@ def perform_approve(request, comment):
|
|||
comment.save()
|
||||
|
||||
signals.comment_was_flagged.send(
|
||||
sender = comment.__class__,
|
||||
comment = comment,
|
||||
flag = flag,
|
||||
created = created,
|
||||
request = request,
|
||||
sender=comment.__class__,
|
||||
comment=comment,
|
||||
flag=flag,
|
||||
created=created,
|
||||
request=request,
|
||||
)
|
||||
|
||||
# Confirmation views.
|
||||
|
||||
flag_done = confirmation_view(
|
||||
template = "comments/flagged.html",
|
||||
doc = 'Displays a "comment was flagged" success page.'
|
||||
template="comments/flagged.html",
|
||||
doc='Displays a "comment was flagged" success page.'
|
||||
)
|
||||
delete_done = confirmation_view(
|
||||
template = "comments/deleted.html",
|
||||
doc = 'Displays a "comment was deleted" success page.'
|
||||
template="comments/deleted.html",
|
||||
doc='Displays a "comment was deleted" success page.'
|
||||
)
|
||||
approve_done = confirmation_view(
|
||||
template = "comments/approved.html",
|
||||
doc = 'Displays a "comment was approved" success page.'
|
||||
template="comments/approved.html",
|
||||
doc='Displays a "comment was approved" success page.'
|
||||
)
|
||||
|
|
|
@ -276,14 +276,14 @@ class ReverseGenericRelatedObjectsDescriptor(object):
|
|||
|
||||
join_cols = self.field.get_joining_columns(reverse_join=True)[0]
|
||||
manager = RelatedManager(
|
||||
model = rel_model,
|
||||
instance = instance,
|
||||
source_col_name = qn(join_cols[0]),
|
||||
target_col_name = qn(join_cols[1]),
|
||||
content_type = content_type,
|
||||
content_type_field_name = self.field.content_type_field_name,
|
||||
object_id_field_name = self.field.object_id_field_name,
|
||||
prefetch_cache_name = self.field.attname,
|
||||
model=rel_model,
|
||||
instance=instance,
|
||||
source_col_name=qn(join_cols[0]),
|
||||
target_col_name=qn(join_cols[1]),
|
||||
content_type=content_type,
|
||||
content_type_field_name=self.field.content_type_field_name,
|
||||
object_id_field_name=self.field.object_id_field_name,
|
||||
prefetch_cache_name=self.field.attname,
|
||||
)
|
||||
|
||||
return manager
|
||||
|
@ -329,15 +329,15 @@ def create_generic_related_manager(superclass):
|
|||
manager = getattr(self.model, kwargs.pop('manager'))
|
||||
manager_class = create_generic_related_manager(manager.__class__)
|
||||
return manager_class(
|
||||
model = self.model,
|
||||
instance = self.instance,
|
||||
symmetrical = self.symmetrical,
|
||||
source_col_name = self.source_col_name,
|
||||
target_col_name = self.target_col_name,
|
||||
content_type = self.content_type,
|
||||
content_type_field_name = self.content_type_field_name,
|
||||
object_id_field_name = self.object_id_field_name,
|
||||
prefetch_cache_name = self.prefetch_cache_name,
|
||||
model=self.model,
|
||||
instance=self.instance,
|
||||
symmetrical=self.symmetrical,
|
||||
source_col_name=self.source_col_name,
|
||||
target_col_name=self.target_col_name,
|
||||
content_type=self.content_type,
|
||||
content_type_field_name=self.content_type_field_name,
|
||||
object_id_field_name=self.object_id_field_name,
|
||||
prefetch_cache_name=self.prefetch_cache_name,
|
||||
)
|
||||
do_not_call_in_templates = True
|
||||
|
||||
|
|
|
@ -43,9 +43,9 @@ class ContentTypeManager(models.Manager):
|
|||
# needed around opts.verbose_name_raw because name_raw might be a
|
||||
# django.utils.functional.__proxy__ object.
|
||||
ct, created = self.get_or_create(
|
||||
app_label = opts.app_label,
|
||||
model = opts.model_name,
|
||||
defaults = {'name': smart_text(opts.verbose_name_raw)},
|
||||
app_label=opts.app_label,
|
||||
model=opts.model_name,
|
||||
defaults={'name': smart_text(opts.verbose_name_raw)},
|
||||
)
|
||||
self._add_to_cache(self.db, ct)
|
||||
|
||||
|
|
|
@ -271,9 +271,9 @@ class ContentTypesTests(TestCase):
|
|||
is defined anymore.
|
||||
"""
|
||||
ct = ContentType.objects.create(
|
||||
name = 'Old model',
|
||||
app_label = 'contenttypes',
|
||||
model = 'OldModel',
|
||||
name='Old model',
|
||||
app_label='contenttypes',
|
||||
model='OldModel',
|
||||
)
|
||||
self.assertEqual(six.text_type(ct), 'Old model')
|
||||
self.assertIsNone(ct.model_class())
|
||||
|
|
|
@ -6,10 +6,10 @@ from django.utils.translation import ugettext, ugettext_lazy as _
|
|||
|
||||
class FlatpageForm(forms.ModelForm):
|
||||
url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/\.~]+$',
|
||||
help_text = _("Example: '/about/contact/'. Make sure to have leading"
|
||||
" and trailing slashes."),
|
||||
error_message = _("This value must contain only letters, numbers,"
|
||||
" dots, underscores, dashes, slashes or tildes."))
|
||||
help_text=_("Example: '/about/contact/'. Make sure to have leading"
|
||||
" and trailing slashes."),
|
||||
error_message=_("This value must contain only letters, numbers,"
|
||||
" dots, underscores, dashes, slashes or tildes."))
|
||||
|
||||
class Meta:
|
||||
model = FlatPage
|
||||
|
|
|
@ -87,7 +87,7 @@ class FlatpageMiddlewareTests(TestCase):
|
|||
|
||||
|
||||
@override_settings(
|
||||
APPEND_SLASH = True,
|
||||
APPEND_SLASH=True,
|
||||
LOGIN_URL='/accounts/login/',
|
||||
MIDDLEWARE_CLASSES=(
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
|
|
|
@ -75,7 +75,7 @@ class FlatpageViewTests(TestCase):
|
|||
|
||||
|
||||
@override_settings(
|
||||
APPEND_SLASH = True,
|
||||
APPEND_SLASH=True,
|
||||
LOGIN_URL='/accounts/login/',
|
||||
MIDDLEWARE_CLASSES=(
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
|
|
|
@ -58,12 +58,12 @@ class BaseTests(object):
|
|||
|
||||
def setUp(self):
|
||||
self.settings_override = override_settings_tags(
|
||||
TEMPLATE_DIRS = (),
|
||||
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS,
|
||||
MESSAGE_TAGS = '',
|
||||
MESSAGE_STORAGE = '%s.%s' % (self.storage_class.__module__,
|
||||
TEMPLATE_DIRS=(),
|
||||
TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS,
|
||||
MESSAGE_TAGS='',
|
||||
MESSAGE_STORAGE='%s.%s' % (self.storage_class.__module__,
|
||||
self.storage_class.__name__),
|
||||
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer',
|
||||
SESSION_SERIALIZER='django.contrib.sessions.serializers.JSONSerializer',
|
||||
)
|
||||
self.settings_override.enable()
|
||||
|
||||
|
|
|
@ -121,23 +121,23 @@ class Feed(object):
|
|||
link = add_domain(current_site.domain, link, request.is_secure())
|
||||
|
||||
feed = self.feed_type(
|
||||
title = self.__get_dynamic_attr('title', obj),
|
||||
subtitle = self.__get_dynamic_attr('subtitle', obj),
|
||||
link = link,
|
||||
description = self.__get_dynamic_attr('description', obj),
|
||||
language = settings.LANGUAGE_CODE,
|
||||
feed_url = add_domain(
|
||||
title=self.__get_dynamic_attr('title', obj),
|
||||
subtitle=self.__get_dynamic_attr('subtitle', obj),
|
||||
link=link,
|
||||
description=self.__get_dynamic_attr('description', obj),
|
||||
language=settings.LANGUAGE_CODE,
|
||||
feed_url=add_domain(
|
||||
current_site.domain,
|
||||
self.__get_dynamic_attr('feed_url', obj) or request.path,
|
||||
request.is_secure(),
|
||||
),
|
||||
author_name = self.__get_dynamic_attr('author_name', obj),
|
||||
author_link = self.__get_dynamic_attr('author_link', obj),
|
||||
author_email = self.__get_dynamic_attr('author_email', obj),
|
||||
categories = self.__get_dynamic_attr('categories', obj),
|
||||
feed_copyright = self.__get_dynamic_attr('feed_copyright', obj),
|
||||
feed_guid = self.__get_dynamic_attr('feed_guid', obj),
|
||||
ttl = self.__get_dynamic_attr('ttl', obj),
|
||||
author_name=self.__get_dynamic_attr('author_name', obj),
|
||||
author_link=self.__get_dynamic_attr('author_link', obj),
|
||||
author_email=self.__get_dynamic_attr('author_email', obj),
|
||||
categories=self.__get_dynamic_attr('categories', obj),
|
||||
feed_copyright=self.__get_dynamic_attr('feed_copyright', obj),
|
||||
feed_guid=self.__get_dynamic_attr('feed_guid', obj),
|
||||
ttl=self.__get_dynamic_attr('ttl', obj),
|
||||
**self.feed_extra_kwargs(obj)
|
||||
)
|
||||
|
||||
|
@ -175,9 +175,9 @@ class Feed(object):
|
|||
enc_url = self.__get_dynamic_attr('item_enclosure_url', item)
|
||||
if enc_url:
|
||||
enc = feedgenerator.Enclosure(
|
||||
url = smart_text(enc_url),
|
||||
length = smart_text(self.__get_dynamic_attr('item_enclosure_length', item)),
|
||||
mime_type = smart_text(self.__get_dynamic_attr('item_enclosure_mime_type', item))
|
||||
url=smart_text(enc_url),
|
||||
length=smart_text(self.__get_dynamic_attr('item_enclosure_length', item)),
|
||||
mime_type=smart_text(self.__get_dynamic_attr('item_enclosure_mime_type', item))
|
||||
)
|
||||
author_name = self.__get_dynamic_attr('item_author_name', item)
|
||||
if author_name is not None:
|
||||
|
@ -197,20 +197,20 @@ class Feed(object):
|
|||
updateddate = make_aware(updateddate, tz)
|
||||
|
||||
feed.add_item(
|
||||
title = title,
|
||||
link = link,
|
||||
description = description,
|
||||
unique_id = self.__get_dynamic_attr('item_guid', item, link),
|
||||
unique_id_is_permalink = self.__get_dynamic_attr(
|
||||
title=title,
|
||||
link=link,
|
||||
description=description,
|
||||
unique_id=self.__get_dynamic_attr('item_guid', item, link),
|
||||
unique_id_is_permalink=self.__get_dynamic_attr(
|
||||
'item_guid_is_permalink', item),
|
||||
enclosure = enc,
|
||||
pubdate = pubdate,
|
||||
updateddate = updateddate,
|
||||
author_name = author_name,
|
||||
author_email = author_email,
|
||||
author_link = author_link,
|
||||
categories = self.__get_dynamic_attr('item_categories', item),
|
||||
item_copyright = self.__get_dynamic_attr('item_copyright', item),
|
||||
enclosure=enc,
|
||||
pubdate=pubdate,
|
||||
updateddate=updateddate,
|
||||
author_name=author_name,
|
||||
author_email=author_email,
|
||||
author_link=author_link,
|
||||
categories=self.__get_dynamic_attr('item_categories', item),
|
||||
item_copyright=self.__get_dynamic_attr('item_copyright', item),
|
||||
**self.item_extra_kwargs(item)
|
||||
)
|
||||
return feed
|
||||
|
|
|
@ -38,7 +38,7 @@ def _samefile(src, dst):
|
|||
os.path.normcase(os.path.abspath(dst)))
|
||||
|
||||
|
||||
def file_move_safe(old_file_name, new_file_name, chunk_size = 1024*64, allow_overwrite=False):
|
||||
def file_move_safe(old_file_name, new_file_name, chunk_size=1024*64, allow_overwrite=False):
|
||||
"""
|
||||
Moves a file from one location to another in the safest way possible.
|
||||
|
||||
|
|
|
@ -193,13 +193,13 @@ class MemoryFileUploadHandler(FileUploadHandler):
|
|||
|
||||
self.file.seek(0)
|
||||
return InMemoryUploadedFile(
|
||||
file = self.file,
|
||||
field_name = self.field_name,
|
||||
name = self.file_name,
|
||||
content_type = self.content_type,
|
||||
size = file_size,
|
||||
charset = self.charset,
|
||||
content_type_extra = self.content_type_extra
|
||||
file=self.file,
|
||||
field_name=self.field_name,
|
||||
name=self.file_name,
|
||||
content_type=self.content_type,
|
||||
size=file_size,
|
||||
charset=self.charset,
|
||||
content_type_extra=self.content_type_extra
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ class Command(NoArgsCommand):
|
|||
if settings.configured:
|
||||
settings.USE_I18N = True
|
||||
else:
|
||||
settings.configure(USE_I18N = True)
|
||||
settings.configure(USE_I18N=True)
|
||||
|
||||
self.invoked_for_django = False
|
||||
if os.path.isdir(os.path.join('conf', 'locale')):
|
||||
|
|
|
@ -81,10 +81,10 @@ class MigrationAutodetector(object):
|
|||
self.add_to_migration(
|
||||
app_label,
|
||||
operations.CreateModel(
|
||||
name = model_state.name,
|
||||
fields = model_state.fields,
|
||||
options = model_state.options,
|
||||
bases = model_state.bases,
|
||||
name=model_state.name,
|
||||
fields=model_state.fields,
|
||||
options=model_state.options,
|
||||
bases=model_state.bases,
|
||||
)
|
||||
)
|
||||
# Phase 2 is progressively adding pending models, splitting up into two
|
||||
|
@ -99,10 +99,10 @@ class MigrationAutodetector(object):
|
|||
self.add_to_migration(
|
||||
app_label,
|
||||
operations.CreateModel(
|
||||
name = model_state.name,
|
||||
fields = model_state.fields,
|
||||
options = model_state.options,
|
||||
bases = model_state.bases,
|
||||
name=model_state.name,
|
||||
fields=model_state.fields,
|
||||
options=model_state.options,
|
||||
bases=model_state.bases,
|
||||
)
|
||||
)
|
||||
for field_name, other_app_label, other_model_name in related_fields:
|
||||
|
@ -119,10 +119,10 @@ class MigrationAutodetector(object):
|
|||
self.add_to_migration(
|
||||
app_label,
|
||||
operations.CreateModel(
|
||||
name = model_state.name,
|
||||
fields = [(n, f) for n, f in model_state.fields if n not in bad_fields],
|
||||
options = model_state.options,
|
||||
bases = model_state.bases,
|
||||
name=model_state.name,
|
||||
fields=[(n, f) for n, f in model_state.fields if n not in bad_fields],
|
||||
options=model_state.options,
|
||||
bases=model_state.bases,
|
||||
)
|
||||
)
|
||||
# Add the bad fields to be made in a phase 3
|
||||
|
@ -135,11 +135,11 @@ class MigrationAutodetector(object):
|
|||
self.add_to_migration(
|
||||
app_label,
|
||||
operations.AddField(
|
||||
model_name = model_name,
|
||||
name = field_name,
|
||||
field = model_state.get_field_by_name(field_name),
|
||||
model_name=model_name,
|
||||
name=field_name,
|
||||
field=model_state.get_field_by_name(field_name),
|
||||
),
|
||||
new = True,
|
||||
new=True,
|
||||
)
|
||||
if app_label != other_app_label:
|
||||
self.add_dependency(app_label, other_app_label)
|
||||
|
@ -172,9 +172,9 @@ class MigrationAutodetector(object):
|
|||
self.add_to_migration(
|
||||
app_label,
|
||||
operations.RenameField(
|
||||
model_name = model_name,
|
||||
old_name = removed_field_name,
|
||||
new_name = field_name,
|
||||
model_name=model_name,
|
||||
old_name=removed_field_name,
|
||||
new_name=field_name,
|
||||
)
|
||||
)
|
||||
old_field_names.remove(removed_field_name)
|
||||
|
@ -189,9 +189,9 @@ class MigrationAutodetector(object):
|
|||
self.add_to_migration(
|
||||
app_label,
|
||||
operations.AddField(
|
||||
model_name = model_name,
|
||||
name = field_name,
|
||||
field = field,
|
||||
model_name=model_name,
|
||||
name=field_name,
|
||||
field=field,
|
||||
)
|
||||
)
|
||||
# Old fields
|
||||
|
@ -199,8 +199,8 @@ class MigrationAutodetector(object):
|
|||
self.add_to_migration(
|
||||
app_label,
|
||||
operations.RemoveField(
|
||||
model_name = model_name,
|
||||
name = field_name,
|
||||
model_name=model_name,
|
||||
name=field_name,
|
||||
)
|
||||
)
|
||||
# The same fields
|
||||
|
@ -212,9 +212,9 @@ class MigrationAutodetector(object):
|
|||
self.add_to_migration(
|
||||
app_label,
|
||||
operations.AlterField(
|
||||
model_name = model_name,
|
||||
name = field_name,
|
||||
field = new_model_state.get_field_by_name(field_name),
|
||||
model_name=model_name,
|
||||
name=field_name,
|
||||
field=new_model_state.get_field_by_name(field_name),
|
||||
)
|
||||
)
|
||||
# unique_together changes
|
||||
|
@ -222,8 +222,8 @@ class MigrationAutodetector(object):
|
|||
self.add_to_migration(
|
||||
app_label,
|
||||
operations.AlterUniqueTogether(
|
||||
name = model_name,
|
||||
unique_together = new_model_state.options.get("unique_together", set()),
|
||||
name=model_name,
|
||||
unique_together=new_model_state.options.get("unique_together", set()),
|
||||
)
|
||||
)
|
||||
# Alright, now add internal dependencies
|
||||
|
|
|
@ -26,7 +26,7 @@ class ProjectState(object):
|
|||
def clone(self):
|
||||
"Returns an exact copy of this ProjectState"
|
||||
return ProjectState(
|
||||
models = dict((k, v.clone()) for k, v in self.models.items())
|
||||
models=dict((k, v.clone()) for k, v in self.models.items())
|
||||
)
|
||||
|
||||
def render(self):
|
||||
|
@ -137,11 +137,11 @@ class ModelState(object):
|
|||
fields.append((name, field_class(*args, **kwargs)))
|
||||
# Now make a copy
|
||||
return self.__class__(
|
||||
app_label = self.app_label,
|
||||
name = self.name,
|
||||
fields = fields,
|
||||
options = dict(self.options),
|
||||
bases = self.bases,
|
||||
app_label=self.app_label,
|
||||
name=self.name,
|
||||
fields=fields,
|
||||
options=dict(self.options),
|
||||
bases=self.bases,
|
||||
)
|
||||
|
||||
def render(self, app_cache):
|
||||
|
|
|
@ -43,20 +43,20 @@ def _initialize():
|
|||
app_store=ModelDict(),
|
||||
|
||||
# Mapping of installed app_labels to model modules for that app.
|
||||
app_labels = {},
|
||||
app_labels={},
|
||||
|
||||
# Mapping of app_labels to a dictionary of model names to model code.
|
||||
# May contain apps that are not installed.
|
||||
app_models=ModelDict(),
|
||||
|
||||
# Mapping of app_labels to errors raised when trying to import the app.
|
||||
app_errors = {},
|
||||
app_errors={},
|
||||
|
||||
# Pending lookups for lazy relations
|
||||
pending_lookups = {},
|
||||
pending_lookups={},
|
||||
|
||||
# -- Everything below here is only used when populating the cache --
|
||||
loads_installed = True,
|
||||
loads_installed=True,
|
||||
loaded=False,
|
||||
handled=set(),
|
||||
postponed=[],
|
||||
|
|
|
@ -9,7 +9,7 @@ import traceback
|
|||
import weakref
|
||||
|
||||
|
||||
def safeRef(target, onDelete = None):
|
||||
def safeRef(target, onDelete=None):
|
||||
"""Return a *safe* weak reference to a callable target
|
||||
|
||||
target -- the object to be weakly referenced, if it's a
|
||||
|
|
|
@ -249,29 +249,29 @@ class BaseForm(object):
|
|||
def as_table(self):
|
||||
"Returns this form rendered as HTML <tr>s -- excluding the <table></table>."
|
||||
return self._html_output(
|
||||
normal_row = '<tr%(html_class_attr)s><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>',
|
||||
error_row = '<tr><td colspan="2">%s</td></tr>',
|
||||
row_ender = '</td></tr>',
|
||||
help_text_html = '<br /><span class="helptext">%s</span>',
|
||||
errors_on_separate_row = False)
|
||||
normal_row='<tr%(html_class_attr)s><th>%(label)s</th><td>%(errors)s%(field)s%(help_text)s</td></tr>',
|
||||
error_row='<tr><td colspan="2">%s</td></tr>',
|
||||
row_ender='</td></tr>',
|
||||
help_text_html='<br /><span class="helptext">%s</span>',
|
||||
errors_on_separate_row=False)
|
||||
|
||||
def as_ul(self):
|
||||
"Returns this form rendered as HTML <li>s -- excluding the <ul></ul>."
|
||||
return self._html_output(
|
||||
normal_row = '<li%(html_class_attr)s>%(errors)s%(label)s %(field)s%(help_text)s</li>',
|
||||
error_row = '<li>%s</li>',
|
||||
row_ender = '</li>',
|
||||
help_text_html = ' <span class="helptext">%s</span>',
|
||||
errors_on_separate_row = False)
|
||||
normal_row='<li%(html_class_attr)s>%(errors)s%(label)s %(field)s%(help_text)s</li>',
|
||||
error_row='<li>%s</li>',
|
||||
row_ender='</li>',
|
||||
help_text_html=' <span class="helptext">%s</span>',
|
||||
errors_on_separate_row=False)
|
||||
|
||||
def as_p(self):
|
||||
"Returns this form rendered as HTML <p>s."
|
||||
return self._html_output(
|
||||
normal_row = '<p%(html_class_attr)s>%(label)s %(field)s%(help_text)s</p>',
|
||||
error_row = '%s',
|
||||
row_ender = '</p>',
|
||||
help_text_html = ' <span class="helptext">%s</span>',
|
||||
errors_on_separate_row = True)
|
||||
normal_row='<p%(html_class_attr)s>%(label)s %(field)s%(help_text)s</p>',
|
||||
error_row='%s',
|
||||
row_ender='</p>',
|
||||
help_text_html=' <span class="helptext">%s</span>',
|
||||
errors_on_separate_row=True)
|
||||
|
||||
def non_field_errors(self):
|
||||
"""
|
||||
|
|
|
@ -495,7 +495,7 @@ class BoundaryIter(six.Iterator):
|
|||
stream.unget(chunk[-rollback:])
|
||||
return chunk[:-rollback]
|
||||
|
||||
def _find_boundary(self, data, eof = False):
|
||||
def _find_boundary(self, data, eof=False):
|
||||
"""
|
||||
Finds a multipart boundary in data.
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ class CsrfViewMiddleware(object):
|
|||
# the expiry timer.
|
||||
response.set_cookie(settings.CSRF_COOKIE_NAME,
|
||||
request.META["CSRF_COOKIE"],
|
||||
max_age = 60 * 60 * 24 * 7 * 52,
|
||||
max_age=60 * 60 * 24 * 7 * 52,
|
||||
domain=settings.CSRF_COOKIE_DOMAIN,
|
||||
path=settings.CSRF_COOKIE_PATH,
|
||||
secure=settings.CSRF_COOKIE_SECURE,
|
||||
|
|
|
@ -126,9 +126,9 @@ class TemplateResponseMixin(object):
|
|||
"""
|
||||
response_kwargs.setdefault('content_type', self.content_type)
|
||||
return self.response_class(
|
||||
request = self.request,
|
||||
template = self.get_template_names(),
|
||||
context = context,
|
||||
request=self.request,
|
||||
template=self.get_template_names(),
|
||||
context=context,
|
||||
**response_kwargs
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue