diff --git a/organization/core/models.py b/organization/core/models.py index d6b9b7b1..dad1ff1b 100644 --- a/organization/core/models.py +++ b/organization/core/models.py @@ -680,4 +680,13 @@ class Featured(models.Model): ) class Meta: - abstract = True \ No newline at end of file + abstract = True + + +class Action(Named): + """ + Abstract model that provides an Action object. + """ + + class Meta: + abstract = True diff --git a/organization/pages/admin.py b/organization/pages/admin.py index d468bf31..c65be4ba 100644 --- a/organization/pages/admin.py +++ b/organization/pages/admin.py @@ -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 @@ -76,6 +76,11 @@ class LinkImageInline(StackedDynamicInlineAdmin): model = LinkImage +class PageActionInline(StackedDynamicInlineAdmin): + + + model = PageAction + class LinkStyleInline(TabularDynamicInlineAdmin): model = LinkStyle @@ -142,7 +147,8 @@ class CustomPageAdmin(PageAdmin): PersonListBlockAutocompleteInlineAdmin, PageProductListInline, PageRelatedTitleAdmin, - DynamicContentPageInline + DynamicContentPageInline, + PageActionInline, ] change_form_template = "admin/pages/custompage/change_form.html" diff --git a/organization/pages/models.py b/organization/pages/models.py index 635acda9..cccef154 100644 --- a/organization/pages/models.py +++ b/organization/pages/models.py @@ -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 @@ -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( diff --git a/organization/pages/translation.py b/organization/pages/translation.py index 9bc5cece..9c8c5c64 100644 --- a/organization/pages/translation.py +++ b/organization/pages/translation.py @@ -25,7 +25,7 @@ DynamicContentHomeMedia, CustomPage, ExtendedCustomPage,\ ExtendedCustomPageDynamicContent, PageBlock, PageImage,\ PagePlaylist, PageLink, DynamicContentPage, LinkImage,\ - PageRelatedTitle, HomeImage, DynamicMultimediaPage + PageRelatedTitle, HomeImage, DynamicMultimediaPage, PageAction @register(LinkStyle) @@ -118,6 +118,12 @@ class PageRelatedTitleTranslationOptions(TranslationOptions): fields = ('title',) +@register(PageAction) +class PageActionTranslationOptions(TranslationOptions): + + fields = ('name', 'description') + + @register(HomeImage) class HomeImageTranslationOptions(TranslationOptions):