From 3a4558b84f76c1dbe54c8c38e90e4048c2bd3e9a Mon Sep 17 00:00:00 2001 From: Manan Date: Mon, 10 Dec 2018 19:58:49 +0530 Subject: [PATCH] Moved choices inside of test models per coding style. --- tests/admin_views/models.py | 21 +++++++++------------ tests/choices/models.py | 9 ++++----- tests/model_forms/models.py | 22 ++++++++++------------ tests/update_only_fields/models.py | 9 ++++----- 4 files changed, 27 insertions(+), 34 deletions(-) diff --git a/tests/admin_views/models.py b/tests/admin_views/models.py index 59228876c5..35ba543051 100644 --- a/tests/admin_views/models.py +++ b/tests/admin_views/models.py @@ -632,19 +632,16 @@ class Reservation(models.Model): price = models.IntegerField() -DRIVER_CHOICES = ( - ('bill', 'Bill G'), - ('steve', 'Steve J'), -) - -RESTAURANT_CHOICES = ( - ('indian', 'A Taste of India'), - ('thai', 'Thai Pography'), - ('pizza', 'Pizza Mama'), -) - - class FoodDelivery(models.Model): + DRIVER_CHOICES = ( + ('bill', 'Bill G'), + ('steve', 'Steve J'), + ) + RESTAURANT_CHOICES = ( + ('indian', 'A Taste of India'), + ('thai', 'Thai Pography'), + ('pizza', 'Pizza Mama'), + ) reference = models.CharField(max_length=100) driver = models.CharField(max_length=100, choices=DRIVER_CHOICES, blank=True) restaurant = models.CharField(max_length=100, choices=RESTAURANT_CHOICES, blank=True) diff --git a/tests/choices/models.py b/tests/choices/models.py index de68118386..b4ef8954ab 100644 --- a/tests/choices/models.py +++ b/tests/choices/models.py @@ -11,13 +11,12 @@ field. This method returns the "human-readable" value of the field. from django.db import models -GENDER_CHOICES = ( - ('M', 'Male'), - ('F', 'Female'), -) - class Person(models.Model): + GENDER_CHOICES = ( + ('M', 'Male'), + ('F', 'Female'), + ) name = models.CharField(max_length=20) gender = models.CharField(max_length=1, choices=GENDER_CHOICES) diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py index da4f5391c5..2c67c187cf 100644 --- a/tests/model_forms/models.py +++ b/tests/model_forms/models.py @@ -11,18 +11,6 @@ from django.db import models temp_storage_dir = tempfile.mkdtemp() temp_storage = FileSystemStorage(temp_storage_dir) -ARTICLE_STATUS = ( - (1, 'Draft'), - (2, 'Pending'), - (3, 'Live'), -) - -ARTICLE_STATUS_CHAR = ( - ('d', 'Draft'), - ('p', 'Pending'), - ('l', 'Live'), -) - class Person(models.Model): name = models.CharField(max_length=100) @@ -51,6 +39,11 @@ class Writer(models.Model): class Article(models.Model): + ARTICLE_STATUS = ( + (1, 'Draft'), + (2, 'Pending'), + (3, 'Live'), + ) headline = models.CharField(max_length=50) slug = models.SlugField() pub_date = models.DateField() @@ -239,6 +232,11 @@ class Triple(models.Model): class ArticleStatus(models.Model): + ARTICLE_STATUS_CHAR = ( + ('d', 'Draft'), + ('p', 'Pending'), + ('l', 'Live'), + ) status = models.CharField(max_length=2, choices=ARTICLE_STATUS_CHAR, blank=True, null=True) diff --git a/tests/update_only_fields/models.py b/tests/update_only_fields/models.py index 3d6a9ec8e6..7308c75ea3 100644 --- a/tests/update_only_fields/models.py +++ b/tests/update_only_fields/models.py @@ -1,17 +1,16 @@ from django.db import models -GENDER_CHOICES = ( - ('M', 'Male'), - ('F', 'Female'), -) - class Account(models.Model): num = models.IntegerField() class Person(models.Model): + GENDER_CHOICES = ( + ('M', 'Male'), + ('F', 'Female'), + ) name = models.CharField(max_length=20) gender = models.CharField(max_length=1, choices=GENDER_CHOICES) pid = models.IntegerField(null=True, default=None)