فهرست منبع

Rename People model to Person (#342)

Matt Westcott 2 سال پیش
والد
کامیت
172cdd9e5f

+ 20 - 20
bakerydemo/base/fixtures/bakerydemo.json

@@ -1,6 +1,6 @@
 [
 [
   {
   {
-    "model": "base.people",
+    "model": "base.person",
     "pk": 1,
     "pk": 1,
     "fields": {
     "fields": {
       "first_name": "Roberta",
       "first_name": "Roberta",
@@ -10,7 +10,7 @@
     }
     }
   },
   },
   {
   {
-    "model": "base.people",
+    "model": "base.person",
     "pk": 2,
     "pk": 2,
     "fields": {
     "fields": {
       "first_name": "Olivia",
       "first_name": "Olivia",
@@ -20,7 +20,7 @@
     }
     }
   },
   },
   {
   {
-    "model": "base.people",
+    "model": "base.person",
     "pk": 3,
     "pk": 3,
     "fields": {
     "fields": {
       "first_name": "Lightnin'",
       "first_name": "Lightnin'",
@@ -30,7 +30,7 @@
     }
     }
   },
   },
   {
   {
-    "model": "base.people",
+    "model": "base.person",
     "pk": 4,
     "pk": 4,
     "fields": {
     "fields": {
       "first_name": "Muddy",
       "first_name": "Muddy",
@@ -122,75 +122,75 @@
     }
     }
   },
   },
   {
   {
-    "model": "blog.blogpeoplerelationship",
+    "model": "blog.blogpersonrelationship",
     "pk": 2,
     "pk": 2,
     "fields": {
     "fields": {
       "sort_order": 0,
       "sort_order": 0,
       "page": 62,
       "page": 62,
-      "people": 1
+      "person": 1
     }
     }
   },
   },
   {
   {
-    "model": "blog.blogpeoplerelationship",
+    "model": "blog.blogpersonrelationship",
     "pk": 3,
     "pk": 3,
     "fields": {
     "fields": {
       "sort_order": 0,
       "sort_order": 0,
       "page": 68,
       "page": 68,
-      "people": 2
+      "person": 2
     }
     }
   },
   },
   {
   {
-    "model": "blog.blogpeoplerelationship",
+    "model": "blog.blogpersonrelationship",
     "pk": 4,
     "pk": 4,
     "fields": {
     "fields": {
       "sort_order": 0,
       "sort_order": 0,
       "page": 72,
       "page": 72,
-      "people": 3
+      "person": 3
     }
     }
   },
   },
   {
   {
-    "model": "blog.blogpeoplerelationship",
+    "model": "blog.blogpersonrelationship",
     "pk": 5,
     "pk": 5,
     "fields": {
     "fields": {
       "sort_order": 0,
       "sort_order": 0,
       "page": 73,
       "page": 73,
-      "people": 3
+      "person": 3
     }
     }
   },
   },
   {
   {
-    "model": "blog.blogpeoplerelationship",
+    "model": "blog.blogpersonrelationship",
     "pk": 6,
     "pk": 6,
     "fields": {
     "fields": {
       "sort_order": 0,
       "sort_order": 0,
       "page": 74,
       "page": 74,
-      "people": 1
+      "person": 1
     }
     }
   },
   },
   {
   {
-    "model": "blog.blogpeoplerelationship",
+    "model": "blog.blogpersonrelationship",
     "pk": 7,
     "pk": 7,
     "fields": {
     "fields": {
       "sort_order": 1,
       "sort_order": 1,
       "page": 74,
       "page": 74,
-      "people": 3
+      "person": 3
     }
     }
   },
   },
   {
   {
-    "model": "blog.blogpeoplerelationship",
+    "model": "blog.blogpersonrelationship",
     "pk": 8,
     "pk": 8,
     "fields": {
     "fields": {
       "sort_order": 1,
       "sort_order": 1,
       "page": 73,
       "page": 73,
-      "people": 1
+      "person": 1
     }
     }
   },
   },
   {
   {
-    "model": "blog.blogpeoplerelationship",
+    "model": "blog.blogpersonrelationship",
     "pk": 9,
     "pk": 9,
     "fields": {
     "fields": {
       "sort_order": 0,
       "sort_order": 0,
       "page": 77,
       "page": 77,
-      "people": 2
+      "person": 2
     }
     }
   },
   },
   {
   {

+ 2 - 2
bakerydemo/base/management/commands/create_random_data.py

@@ -9,7 +9,7 @@ from wagtail.core.rich_text import RichText
 from wagtail.images.models import Image
 from wagtail.images.models import Image
 from willow.image import Image as WillowImage
 from willow.image import Image as WillowImage
 
 
-from bakerydemo.base.models import FooterText, HomePage, People, StandardPage
+from bakerydemo.base.models import FooterText, HomePage, Person, StandardPage
 from bakerydemo.blog.models import BlogIndexPage, BlogPage
 from bakerydemo.blog.models import BlogIndexPage, BlogPage
 from bakerydemo.breads.models import (
 from bakerydemo.breads.models import (
     BreadIngredient,
     BreadIngredient,
@@ -140,7 +140,7 @@ class Command(BaseCommand):
 
 
         self.stdout.write("Creating people...")
         self.stdout.write("Creating people...")
         for _ in range(snippet_count):
         for _ in range(snippet_count):
-            People.objects.create(
+            Person.objects.create(
                 first_name=lorem_ipsum.words(1, common=False),
                 first_name=lorem_ipsum.words(1, common=False),
                 last_name=lorem_ipsum.words(1, common=False),
                 last_name=lorem_ipsum.words(1, common=False),
                 job_title=lorem_ipsum.words(1, common=False),
                 job_title=lorem_ipsum.words(1, common=False),

+ 19 - 0
bakerydemo/base/migrations/0010_rename_people_person.py

@@ -0,0 +1,19 @@
+# Generated by Django 3.2.15 on 2022-09-02 14:39
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("blog", "0005_use_json_field_for_body_streamfield"),
+        ("wagtailimages", "0024_index_image_file_hash"),
+        ("base", "0009_alter_homepage_promo_text"),
+    ]
+
+    operations = [
+        migrations.RenameModel(
+            old_name="People",
+            new_name="Person",
+        ),
+    ]

+ 4 - 4
bakerydemo/base/models.py

@@ -14,13 +14,13 @@ from .blocks import BaseStreamBlock
 
 
 
 
 @register_snippet
 @register_snippet
-class People(index.Indexed, ClusterableModel):
+class Person(index.Indexed, ClusterableModel):
     """
     """
-    A Django model to store People objects.
+    A Django model to store Person objects.
     It uses the `@register_snippet` decorator to allow it to be accessible
     It uses the `@register_snippet` decorator to allow it to be accessible
-    via the Snippets UI (e.g. /admin/snippets/base/people/)
+    via the Snippets UI (e.g. /admin/snippets/base/person/)
 
 
-    `People` uses the `ClusterableModel`, which allows the relationship with
+    `Person` uses the `ClusterableModel`, which allows the relationship with
     another model to be stored locally to the 'parent' model (e.g. a PageModel)
     another model to be stored locally to the 'parent' model (e.g. a PageModel)
     until the parent is explicitly saved. This allows the editor to use the
     until the parent is explicitly saved. This allows the editor to use the
     'Preview' button, to preview the content, without saving the relationships
     'Preview' button, to preview the content, without saving the relationships

+ 4 - 4
bakerydemo/base/wagtail_hooks.py

@@ -4,7 +4,7 @@ from wagtail.contrib.modeladmin.options import (
     modeladmin_register,
     modeladmin_register,
 )
 )
 
 
-from bakerydemo.base.models import FooterText, People
+from bakerydemo.base.models import FooterText, Person
 from bakerydemo.breads.models import BreadIngredient, BreadType, Country
 from bakerydemo.breads.models import BreadIngredient, BreadType, Country
 
 
 """
 """
@@ -48,8 +48,8 @@ class BreadModelAdminGroup(ModelAdminGroup):
     items = (BreadIngredientAdmin, BreadTypeAdmin, BreadCountryAdmin)
     items = (BreadIngredientAdmin, BreadTypeAdmin, BreadCountryAdmin)
 
 
 
 
-class PeopleModelAdmin(ModelAdmin):
-    model = People
+class PersonModelAdmin(ModelAdmin):
+    model = Person
     menu_label = "People"  # ditch this to use verbose_name_plural from model
     menu_label = "People"  # ditch this to use verbose_name_plural from model
     menu_icon = "fa-users"  # change as required
     menu_icon = "fa-users"  # change as required
     list_display = ("first_name", "last_name", "job_title", "thumb_image")
     list_display = ("first_name", "last_name", "job_title", "thumb_image")
@@ -67,7 +67,7 @@ class BakeryModelAdminGroup(ModelAdminGroup):
     menu_label = "Bakery Misc"
     menu_label = "Bakery Misc"
     menu_icon = "fa-cutlery"  # change as required
     menu_icon = "fa-cutlery"  # change as required
     menu_order = 300  # will put in 4th place (000 being 1st, 100 2nd)
     menu_order = 300  # will put in 4th place (000 being 1st, 100 2nd)
-    items = (PeopleModelAdmin, FooterTextAdmin)
+    items = (PersonModelAdmin, FooterTextAdmin)
 
 
 
 
 # When using a ModelAdminGroup class to group several ModelAdmin classes together,
 # When using a ModelAdminGroup class to group several ModelAdmin classes together,

+ 23 - 0
bakerydemo/blog/migrations/0006_rename_blogpeoplerelationship_person.py

@@ -0,0 +1,23 @@
+# Generated by Django 3.2.15 on 2022-09-02 14:39
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("base", "0010_rename_people_person"),
+        ("blog", "0005_use_json_field_for_body_streamfield"),
+    ]
+
+    operations = [
+        migrations.RenameModel(
+            old_name="BlogPeopleRelationship",
+            new_name="BlogPersonRelationship",
+        ),
+        migrations.RenameField(
+            model_name="blogpersonrelationship",
+            old_name="people",
+            new_name="person",
+        ),
+    ]

+ 14 - 14
bakerydemo/blog/models.py

@@ -15,22 +15,22 @@ from wagtail.search import index
 from bakerydemo.base.blocks import BaseStreamBlock
 from bakerydemo.base.blocks import BaseStreamBlock
 
 
 
 
-class BlogPeopleRelationship(Orderable, models.Model):
+class BlogPersonRelationship(Orderable, models.Model):
     """
     """
-    This defines the relationship between the `People` within the `base`
-    app and the BlogPage below. This allows People to be added to a BlogPage.
+    This defines the relationship between the `Person` within the `base`
+    app and the BlogPage below. This allows people to be added to a BlogPage.
 
 
-    We have created a two way relationship between BlogPage and People using
+    We have created a two way relationship between BlogPage and Person using
     the ParentalKey and ForeignKey
     the ParentalKey and ForeignKey
     """
     """
 
 
     page = ParentalKey(
     page = ParentalKey(
         "BlogPage", related_name="blog_person_relationship", on_delete=models.CASCADE
         "BlogPage", related_name="blog_person_relationship", on_delete=models.CASCADE
     )
     )
-    people = models.ForeignKey(
-        "base.People", related_name="person_blog_relationship", on_delete=models.CASCADE
+    person = models.ForeignKey(
+        "base.Person", related_name="person_blog_relationship", on_delete=models.CASCADE
     )
     )
-    panels = [FieldPanel("people")]
+    panels = [FieldPanel("person")]
 
 
 
 
 class BlogPageTag(TaggedItemBase):
 class BlogPageTag(TaggedItemBase):
@@ -49,8 +49,8 @@ class BlogPage(Page):
     """
     """
     A Blog Page
     A Blog Page
 
 
-    We access the People object with an inline panel that references the
-    ParentalKey's related_name in BlogPeopleRelationship. More docs:
+    We access the Person object with an inline panel that references the
+    ParentalKey's related_name in BlogPersonRelationship. More docs:
     https://docs.wagtail.org/en/stable/topics/pages.html#inline-models
     https://docs.wagtail.org/en/stable/topics/pages.html#inline-models
     """
     """
 
 
@@ -88,13 +88,13 @@ class BlogPage(Page):
 
 
     def authors(self):
     def authors(self):
         """
         """
-        Returns the BlogPage's related People. Again note that we are using
-        the ParentalKey's related_name from the BlogPeopleRelationship model
-        to access these objects. This allows us to access the People objects
+        Returns the BlogPage's related people. Again note that we are using
+        the ParentalKey's related_name from the BlogPersonRelationship model
+        to access these objects. This allows us to access the Person objects
         with a loop on the template. If we tried to access the blog_person_
         with a loop on the template. If we tried to access the blog_person_
-        relationship directly we'd print `blog.BlogPeopleRelationship.None`
+        relationship directly we'd print `blog.BlogPersonRelationship.None`
         """
         """
-        authors = [n.people for n in self.blog_person_relationship.all()]
+        authors = [n.person for n in self.blog_person_relationship.all()]
 
 
         return authors
         return authors
 
 

+ 1 - 1
bakerydemo/locations/models.py

@@ -50,7 +50,7 @@ class OperatingHours(models.Model):
 class LocationOperatingHours(Orderable, OperatingHours):
 class LocationOperatingHours(Orderable, OperatingHours):
     """
     """
     A model creating a relationship between the OperatingHours and Location
     A model creating a relationship between the OperatingHours and Location
-    Note that unlike BlogPeopleRelationship we don't include a ForeignKey to
+    Note that unlike BlogPersonRelationship we don't include a ForeignKey to
     OperatingHours as we don't need that relationship (e.g. any Location open
     OperatingHours as we don't need that relationship (e.g. any Location open
     a certain day of the week). The ParentalKey is the minimum required to
     a certain day of the week). The ParentalKey is the minimum required to
     relate the two objects to one another. We use the ParentalKey's related_
     relate the two objects to one another. We use the ParentalKey's related_