зеркало из https://github.com/mozilla/bedrock.git
Enable flake8-django and fix errors found
This commit is contained in:
Родитель
b19f3e0399
Коммит
a61755bcff
|
@ -34,13 +34,13 @@ class Position(models.Model):
|
|||
def __str__(self):
|
||||
return f"{self.job_id}@{self.source}"
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("careers.position", kwargs={"source": self.source, "job_id": self.job_id})
|
||||
|
||||
@property
|
||||
def location_list(self):
|
||||
return sorted(self.location.split(","))
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("careers.position", kwargs={"source": self.source, "job_id": self.job_id})
|
||||
|
||||
@classmethod
|
||||
def position_types(cls):
|
||||
return sorted(set(cls.objects.values_list("position_type", flat=True)))
|
||||
|
|
|
@ -12,3 +12,6 @@ class ExternalFile(models.Model):
|
|||
|
||||
class Meta:
|
||||
app_label = "externalfiles"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name}"
|
||||
|
|
|
@ -87,7 +87,7 @@ class PocketArticle(models.Model):
|
|||
url = models.URLField()
|
||||
domain = models.CharField(max_length=255)
|
||||
title = models.CharField(max_length=255)
|
||||
image_src = models.URLField(null=True) # points to Pocket's image CDN
|
||||
image_src = models.URLField(null=True) # points to Pocket's image CDN # noqa: DJ001
|
||||
time_shared = models.DateTimeField()
|
||||
created_date = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
|
|
|
@ -244,6 +244,17 @@ class ProductRelease(models.Model):
|
|||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
def get_absolute_url(self):
|
||||
if self.product == "Firefox for Android":
|
||||
urlname = "firefox.android.releasenotes"
|
||||
elif self.product == "Firefox for iOS":
|
||||
urlname = "firefox.ios.releasenotes"
|
||||
else:
|
||||
urlname = "firefox.desktop.releasenotes"
|
||||
|
||||
prefix = "aurora" if self.channel == "Aurora" else "release"
|
||||
return reverse(urlname, args=[self.version, prefix])
|
||||
|
||||
@cached_property
|
||||
def major_version(self):
|
||||
return str(self.version_obj.major)
|
||||
|
@ -260,17 +271,6 @@ class ProductRelease(models.Model):
|
|||
def is_latest(self):
|
||||
return self == get_latest_release(self.product, self.channel)
|
||||
|
||||
def get_absolute_url(self):
|
||||
if self.product == "Firefox for Android":
|
||||
urlname = "firefox.android.releasenotes"
|
||||
elif self.product == "Firefox for iOS":
|
||||
urlname = "firefox.ios.releasenotes"
|
||||
else:
|
||||
urlname = "firefox.desktop.releasenotes"
|
||||
|
||||
prefix = "aurora" if self.channel == "Aurora" else "release"
|
||||
return reverse(urlname, args=[self.version, prefix])
|
||||
|
||||
def get_sysreq_url(self):
|
||||
if self.product == "Firefox for Android":
|
||||
urlname = "firefox.android.system_requirements"
|
||||
|
|
|
@ -26,6 +26,18 @@ class Product(models.Model):
|
|||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
|
||||
# do not use self.name_tuple because don't want ".0" on versions.
|
||||
product, vers = self.name_and_version
|
||||
self.product = product
|
||||
self.product_slug = slugify(product)
|
||||
self.slug = f"{self.product_slug}-{vers}"
|
||||
super().save(force_insert, force_update, using, update_fields)
|
||||
|
||||
def get_absolute_url(self):
|
||||
product, vers = self.name_and_version
|
||||
return reverse("security.product-version-advisories", kwargs={"product": product, "version": vers})
|
||||
|
||||
@property
|
||||
def name_and_version(self):
|
||||
return self.name.rsplit(None, 1)
|
||||
|
@ -49,18 +61,6 @@ class Product(models.Model):
|
|||
def __lt__(self, other):
|
||||
return self.name_tuple < other.name_tuple
|
||||
|
||||
def get_absolute_url(self):
|
||||
product, vers = self.name_and_version
|
||||
return reverse("security.product-version-advisories", kwargs={"product": product, "version": vers})
|
||||
|
||||
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
|
||||
# do not use self.name_tuple because don't want ".0" on versions.
|
||||
product, vers = self.name_and_version
|
||||
self.product = product
|
||||
self.product_slug = slugify(product)
|
||||
self.slug = f"{self.product_slug}-{vers}"
|
||||
super().save(force_insert, force_update, using, update_fields)
|
||||
|
||||
|
||||
class SecurityAdvisory(models.Model):
|
||||
id = models.CharField(max_length=8, primary_key=True, db_index=True)
|
||||
|
@ -117,6 +117,9 @@ class HallOfFamer(models.Model):
|
|||
class Meta:
|
||||
ordering = ("-date", "id")
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.program}/{self.name}"
|
||||
|
||||
@property
|
||||
def year_quarter(self):
|
||||
"""Return the year and quarter based on the date field.
|
||||
|
|
|
@ -69,9 +69,9 @@ class SitemapURL(models.Model):
|
|||
else:
|
||||
return self.path
|
||||
|
||||
def get_absolute_url(self):
|
||||
return f"{settings.CANONICAL_URL}{self}"
|
||||
|
||||
@property
|
||||
def has_locale(self):
|
||||
return self.locale != NO_LOCALE
|
||||
|
||||
def get_absolute_url(self):
|
||||
return f"{settings.CANONICAL_URL}{self}"
|
||||
|
|
|
@ -6,8 +6,7 @@ select = [
|
|||
# "A", # flake8-builtin errors.
|
||||
# TODO: Enable bugbear and fix errors.
|
||||
# "B", # bugbear errors
|
||||
# TODO: Enable flake8-django and fix errors.
|
||||
# "DJ", # flake8-django errors.
|
||||
"DJ", # flake8-django errors.
|
||||
"E", # pycodestyle errors
|
||||
"F", # pyflakes errors
|
||||
# TODO: Currently ruff doesn't have the ability to sort Django imports together.
|
||||
|
|
Загрузка…
Ссылка в новой задаче