Skip to content

Commit

Permalink
Merge pull request #18 from wharton/abstractitemmodel
Browse files Browse the repository at this point in the history
Changed model GridItem to be an abstract model, GridItemAbstract.
  • Loading branch information
FlipperPA authored Nov 7, 2023
2 parents ac5740e + aefea38 commit 8329bda
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions wagtailgridder/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ class Meta:
verbose_name_plural = "grid categories"


class GridItem(Page):
class GridItemAbstract(models.Model):
"""
The fields needed to properly display a grid item.
The template will omit any fields not included automagically.
"""

parent_page_types = get_grid_item_parent_page_types()

class Meta:
verbose_name = "Grid Item"

summary_image = models.ForeignKey(
"wagtailimages.Image",
null=True,
Expand Down Expand Up @@ -139,11 +136,23 @@ class Meta:
),
]

class Meta:
abstract = True

def save(self, *args, **kwargs):
self.modified = timezone.now()
super().save(*args, **kwargs)


class GridItem(GridItemAbstract, Page):
"""
Concrete implementation of GridItemAbstract.
"""

class Meta:
verbose_name = "Grid Item"


class GridIndexGridItemRelationship(Orderable, models.Model):
"""
Allows the content creator to associate Grid Items on a
Expand Down

0 comments on commit 8329bda

Please sign in to comment.