1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

PEP8 cleanup

Signed-off-by: Jason Myers <jason@jasonamyers.com>
This commit is contained in:
Jason Myers
2013-11-02 23:36:09 -05:00
parent 0fdb692c6c
commit 7a61c68c50
128 changed files with 739 additions and 206 deletions

View File

@@ -5,6 +5,7 @@ from django.db.models.fields.related import ReverseSingleRelatedObjectDescriptor
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import get_language
@python_2_unicode_compatible
class Country(models.Model):
# Table Column Fields
@@ -13,6 +14,7 @@ class Country(models.Model):
def __str__(self):
return self.name
@python_2_unicode_compatible
class Person(models.Model):
# Table Column Fields
@@ -30,6 +32,7 @@ class Person(models.Model):
def __str__(self):
return self.name
@python_2_unicode_compatible
class Group(models.Model):
# Table Column Fields
@@ -96,6 +99,7 @@ class Friendship(models.Model):
to_fields=['person_country_id', 'id'],
related_name='to_friend')
class ArticleTranslationDescriptor(ReverseSingleRelatedObjectDescriptor):
"""
The set of articletranslation should not set any local fields.
@@ -107,6 +111,7 @@ class ArticleTranslationDescriptor(ReverseSingleRelatedObjectDescriptor):
if value is not None and not self.field.rel.multiple:
setattr(value, self.field.related.get_cache_name(), instance)
class ColConstraint(object):
# Antyhing with as_sql() method works in get_extra_restriction().
def __init__(self, alias, col, value):
@@ -115,6 +120,7 @@ class ColConstraint(object):
def as_sql(self, qn, connection):
return '%s.%s = %%s' % (qn(self.alias), qn(self.col)), [self.value]
class ActiveTranslationField(models.ForeignObject):
"""
This field will allow querying and fetching the currently active translation
@@ -132,6 +138,7 @@ class ActiveTranslationField(models.ForeignObject):
super(ActiveTranslationField, self).contribute_to_class(cls, name)
setattr(cls, self.name, ArticleTranslationDescriptor(self))
@python_2_unicode_compatible
class Article(models.Model):
active_translation = ActiveTranslationField(
@@ -148,9 +155,11 @@ class Article(models.Model):
except ArticleTranslation.DoesNotExist:
return '[No translation found]'
class NewsArticle(Article):
pass
class ArticleTranslation(models.Model):
article = models.ForeignKey(Article)
lang = models.CharField(max_length='2')
@@ -162,10 +171,12 @@ class ArticleTranslation(models.Model):
unique_together = ('article', 'lang')
ordering = ('active_translation__title',)
class ArticleTag(models.Model):
article = models.ForeignKey(Article, related_name="tags", related_query_name="tag")
name = models.CharField(max_length=255)
class ArticleIdea(models.Model):
articles = models.ManyToManyField(Article, related_name="ideas",
related_query_name="idea_things")