Skip to content

Commit

Permalink
add Action, PageAction
Browse files Browse the repository at this point in the history
  • Loading branch information
yomguy committed Aug 25, 2023
1 parent 3ca661b commit ee3cc19
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
11 changes: 10 additions & 1 deletion organization/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,4 +680,13 @@ class Featured(models.Model):
)

class Meta:
abstract = True
abstract = True


class Action(Named):
"""
Abstract model that provides an Action object.
"""

class Meta:
abstract = True
10 changes: 8 additions & 2 deletions organization/pages/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
TabularDynamicInlineAdmin
from mezzanine.pages.admin import PageAdmin, LinkAdmin
from mezzanine.pages.models import Link as MezzanineLink
from organization.pages.models import PageBlock, PageImage,\
from organization.pages.models import PageBlock, PageImage, PageAction, \
PagePlaylist, PageLink, LinkImage, LinkStyle, DynamicContentPage,\
PageRelatedTitle, DynamicMultimediaPage, ExtendedCustomPageDynamicContent,\
DynamicContentHomeMedia, HomeImage, CustomPage, ExtendedCustomPage
Expand Down Expand Up @@ -76,6 +76,11 @@ class LinkImageInline(StackedDynamicInlineAdmin):
model = LinkImage


class PageActionInline(StackedDynamicInlineAdmin):


model = PageAction

class LinkStyleInline(TabularDynamicInlineAdmin):

model = LinkStyle
Expand Down Expand Up @@ -142,7 +147,8 @@ class CustomPageAdmin(PageAdmin):
PersonListBlockAutocompleteInlineAdmin,
PageProductListInline,
PageRelatedTitleAdmin,
DynamicContentPageInline
DynamicContentPageInline,
PageActionInline,
]

change_form_template = "admin/pages/custompage/change_form.html"
Expand Down
19 changes: 18 additions & 1 deletion organization/pages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from mezzanine.core.fields import FileField
from mezzanine.pages.models import Page, Link as MezzanineLink
from organization.core.models import SubTitled, Block, Image, Link, RelatedTitle,\
DynamicContent, URL
DynamicContent, URL, Action
from organization.media.models import PlaylistRelated
from organization.core.managers import CustomSearchableManager

Expand Down Expand Up @@ -358,6 +358,23 @@ class Meta:
verbose_name = 'Media'


class PageAction(Action):

page = models.ForeignKey(
Page,
verbose_name=_('page'),
related_name='actions',
blank=True,
null=True,
on_delete=models.SET_NULL
)

class Meta:
verbose_name = _("action")
verbose_name_plural = _("action")
order_with_respect_to = "page"


class HomeImage(Image, URL):

home = models.ForeignKey(
Expand Down
8 changes: 7 additions & 1 deletion organization/pages/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DynamicContentHomeMedia, CustomPage, ExtendedCustomPage,\
ExtendedCustomPageDynamicContent, PageBlock, PageImage,\
PagePlaylist, PageLink, DynamicContentPage, LinkImage,\
PageRelatedTitle, HomeImage, DynamicMultimediaPage
PageRelatedTitle, HomeImage, DynamicMultimediaPage, PageAction


@register(LinkStyle)
Expand Down Expand Up @@ -118,6 +118,12 @@ class PageRelatedTitleTranslationOptions(TranslationOptions):
fields = ('title',)


@register(PageAction)
class PageActionTranslationOptions(TranslationOptions):

fields = ('name', 'description')


@register(HomeImage)
class HomeImageTranslationOptions(TranslationOptions):

Expand Down

0 comments on commit ee3cc19

Please sign in to comment.