• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.register_snippet函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中wagtail.wagtailsnippets.models.register_snippet函数的典型用法代码示例。如果您正苦于以下问题:Python register_snippet函数的具体用法?Python register_snippet怎么用?Python register_snippet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了register_snippet函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setUp

 def setUp(self):
     register_snippet(ZuluSnippet)
     register_snippet(AlphaSnippet)
开发者ID:NickConnelly,项目名称:NewTort,代码行数:3,代码来源:tests.py


示例2: ParentalKey

    page = ParentalKey("wagtailcore.Page", related_name="advert_placements")
    advert = models.ForeignKey("swimtheme.Advert", related_name="+")


class Advert(models.Model):
    page = models.ForeignKey("wagtailcore.Page", related_name="adverts", null=True, blank=True)
    url = models.URLField(null=True, blank=True)
    text = models.CharField(max_length=255)

    panels = [PageChooserPanel("page"), FieldPanel("url"), FieldPanel("text")]

    def __unicode__(self):
        return self.text


register_snippet(Advert)


# Advert Snippet


class CalloutPlacement(models.Model):
    page = ParentalKey("wagtailcore.Page", related_name="callout_placements")
    callout = models.ForeignKey("swimtheme.Advert", related_name="+")


class Callout(models.Model):
    page = models.ForeignKey("wagtailcore.Page", related_name="callout", null=True, blank=True)
    url = models.URLField(null=True, blank=True)
    text = models.CharField(max_length=255)
开发者ID:cwallenpoole,项目名称:hlccswimteam,代码行数:30,代码来源:models.py


示例3: ImageChooserPanel

        return self.project.__unicode__() + u'\'s ' + self.image.__unicode__() + u' image'

    panels = [
        ImageChooserPanel('image'),
    ]

class PortfolioMetaFieldKey(models.Model):
    text = models.CharField(max_length=255)

    class Meta:
        verbose_name_plural = "MetaField Keys"

    def __unicode__(self):
        return self.text

register_snippet(PortfolioMetaFieldKey)

class ProjectCategoryMetaFieldDefaultKeys(Orderable):
    category = ParentalKey('portfolio.ProjectCategory',related_name='default_metafields')
    key = models.ForeignKey(PortfolioMetaFieldKey,related_name="default_to")

    class Meta:
        verbose_name_plural = "Portfolio Default MetaKeys"

    def __unicode__(self):
        return self.category.__unicode__() + u'\'s default key ' + self.key.__unicode__()

    panels=[
        SnippetChooserPanel('key', PortfolioMetaFieldKey),
    ]
开发者ID:ramanan12345,项目名称:wagtail-portfolio,代码行数:30,代码来源:models.py


示例4: FormPage

class FormPage(AbstractEmailForm):
    pass

FormPage.content_panels = [
    FieldPanel('title', classname="full title"),
    InlinePanel(FormPage, 'form_fields', label="Form fields"),
    MultiFieldPanel([
        FieldPanel('to_address', classname="full"),
        FieldPanel('from_address', classname="full"),
        FieldPanel('subject', classname="full"),
    ], "Email")
]


# Snippets

class Advert(models.Model):
  url = models.URLField(null=True, blank=True)
  text = models.CharField(max_length=255)

  panels = [
    FieldPanel('url'),
    FieldPanel('text'),
  ]

  def __unicode__(self):
    return self.text

register_snippet(Advert)
开发者ID:lili2311,项目名称:wagtail,代码行数:29,代码来源:models.py


示例5: ImageChooserPanel

    google = models.URLField(blank=True, null=True)

    panels = [
        ImageChooserPanel('logo'),
        FieldPanel('title'),
        FieldPanel('subtitle'),
        FieldPanel('facebook'),
        FieldPanel('twitter'),
        FieldPanel('linkedin'),
        FieldPanel('google'),
    ]

    def __unicode__(self):
        return self.title

register_snippet(Branding)


# about page

class Teaser(models.Model):
    page = ParentalKey('pages.AboutPage', related_name='teasers')
    image = models.ForeignKey(
        'wagtailimages.Image',
        null=True, blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )
    title = models.CharField(max_length=100)
    subtitle = models.CharField(max_length=100)
    link = models.ForeignKey(
开发者ID:onurmatik,项目名称:dome.do,代码行数:31,代码来源:models.py


示例6: PageChooserPanel

        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    panels = [
        PageChooserPanel('page', 'insoft.CustomerPage'),
        FieldPanel('title'),
        ImageChooserPanel('emblem')
    ]

    def __unicode__(self):
        return self.title

register_snippet(Customer)


# Products
class ProductsPage(Page):
    subpage_types = ['insoft.ProductCategoryPage']

    content = RichTextField(_('Content'), blank=True, null=True)

    class Meta:
        db_table = 'insoft_products_page'
        verbose_name = _('Products page')

ProductsPage.content_panels = [
    FieldPanel('title', classname='full title'),
    FieldPanel('content', classname='full'),
开发者ID:stikkas,项目名称:inss,代码行数:31,代码来源:models.py


示例7: FieldPanel

    FieldPanel('title', classname="full title"),
    StreamFieldPanel('body'),
    ]



class Social(models.Model):
    number = models.CharField('Телефон', blank=True, 
max_length=80
            )
    body = models.CharField("Тело", blank=True,

max_length=80
            )

    panels = [
        FieldPanel('body'),
        FieldPanel('number'),
    ]

    def __str__(self):
        return self.body

    class Meta:
        verbose_name = "Телефон"
        verbose_name_plural = "Телефоны"



register_snippet(Social)
开发者ID:iho,项目名称:lfk,代码行数:30,代码来源:models.py


示例8: RichTextField

        ('AC', 'Adaptive Courseware'),
        ('CT', 'Customized Tools'),
    )
    ally_category = models.CharField(max_length=2,
                        choices=ALLY_CATEGORY)
    logo = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
    heading = models.CharField(max_length=255)
    description = RichTextField()
    link_url = models.URLField(blank=True, help_text="Call to Action Link")
    link_text = models.CharField(max_length=255, help_text="Call to Action Text")

    api_fields = ('ally_category', 'logo', 'heading', 'description', )

    panels = [
        FieldPanel('ally_category'),
        ImageChooserPanel('logo'),
        FieldPanel('heading'),
        FieldPanel('description'),
    ]

    def __str__(self):
        return self.heading

register_snippet(Ally)
开发者ID:dhgrz,项目名称:openstax-cms,代码行数:30,代码来源:models.py


示例9: ImageChooserPanel

    panels = [
        ImageChooserPanel('image'),
        FieldPanel('embed_url'),
        FieldPanel('caption'),
        MultiFieldPanel(LinkFields.panels, "Link"),
    ]

    def __unicode__(self):
        return self.caption

    class Meta:
        verbose_name = u"头部滚动图"


register_snippet(CarouselItem)

# Head imgs
class HeadImage(models.Model):
    image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
    caption = models.CharField(max_length=255, blank=False)
    panels = [
        ImageChooserPanel('image'),
        FieldPanel('caption')
    ]
开发者ID:bencasper,项目名称:hongding,代码行数:30,代码来源:models.py


示例10: test_register_function

    def test_register_function(self):
        class RegisterFunction(models.Model):
            pass
        register_snippet(RegisterFunction)

        self.assertIn(RegisterFunction, SNIPPET_MODELS)
开发者ID:rense,项目名称:wagtail,代码行数:6,代码来源:tests.py


示例11: MultiFieldPanel

    panels = [
        MultiFieldPanel((FieldPanel('first_name'),
                         FieldPanel('middle_name'),
                         FieldPanel('last_name'),
                         FieldPanel('classification', classname='full'),
                         FieldPanel('about', classname='full'),
                        ), "Owner Information"),
        MultiFieldPanel((FieldPanel('block'),
                         FieldPanel('lot'),
                         FieldPanel('street'),
                         FieldPanel('purok'),
                         FieldPanel('sitio'),
                         FieldPanel('barangay'),
                         FieldPanel('municipality'),
                         FieldPanel('province'),
                         FieldPanel('region'),
                        ), "Address"),
    ]

    def __str__(self):
        full_name = []
        if self.first_name:
            full_name.append(self.first_name)
        if self.middle_name:
            full_name.append(self.middle_name[:1] + '.')
        if self.last_name:
            full_name.append(self.last_name)
        return ' '.join(full_name)

register_snippet(Owner)
开发者ID:rusbal,项目名称:dfr,代码行数:30,代码来源:models.py


示例12: PageChooserPanel

HomePage.content_panels = Page.content_panels + [
    PageChooserPanel("featured_item", "wagtailcore.Page"),
    FieldPanel("number_of_rows_of_articles"),
    FieldPanel("number_of_columns_of_articles"),
    FieldPanel("number_of_rows_of_external_articles"),
    FieldPanel("number_of_rows_of_visualizations"),
]


@python_2_unicode_compatible
class SiteDefaults(models.Model):
    site = models.OneToOneField('wagtailcore.Site',
                                related_name='default_settings', unique=True)
    default_external_article_source_logo = models.ForeignKey(
        'images.AttributedImage',
        related_name='+'
    )

    def __str__(self):
        return "{}".format(self.site)

    class Meta:
        verbose_name_plural = "Site Defaults"

    panels = [
        FieldPanel('site'),
        ImageChooserPanel('default_external_article_source_logo')
    ]
register_snippet(SiteDefaults)
开发者ID:albertoconnor,项目名称:website,代码行数:29,代码来源:models.py


示例13: EventCategory

]

EventIndexPage.promote_panels = Page.promote_panels


# EventPage
class EventCategory(models.Model):
    title = models.CharField(max_length=64, unique=True)

    def __unicode__(self):
        return self.title

    class Meta:
        verbose_name_plural = 'Event categories'

register_snippet(EventCategory)


class EventPageCategory(Orderable):
    page = ParentalKey('EventPage', related_name='categories')
    category = models.ForeignKey(EventCategory)

    panels = [
        SnippetChooserPanel('category')
    ]


class EventPageCarouselItem(Orderable, AbstractCarouselItem):
    page = ParentalKey('EventPage', related_name='carousel_items')

开发者ID:kingsdigitallab,项目名称:shakespeare400-django,代码行数:29,代码来源:pages.py


示例14: PageChooserPanel

        null=True,
        blank=True
    )
    url = models.URLField(null=True, blank=True)
    text = models.CharField(max_length=255)

    panels = [
        PageChooserPanel('page'),
        FieldPanel('url'),
        FieldPanel('text'),
    ]

    def __unicode__(self):
        return self.text

register_snippet(Advert)


# Custom image
class TorchboxImage(AbstractImage):
    credit = models.CharField(max_length=255, blank=True)

    admin_form_fields = Image.admin_form_fields + (
        'credit',
    )

    @property
    def credit_text(self):
        return self.credit

开发者ID:djangojack,项目名称:wagtail-torchbox,代码行数:29,代码来源:models.py


示例15: Organization

class Organization(models.Model):
    name = models.CharField(max_length=100)
    website = models.URLField(max_length=255)
    logo = models.ForeignKey(
        'images.AttributedImage',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    def __str__(self):
        return self.name


register_snippet(Organization)


Organization.panels = [
    FieldPanel('name'),
    FieldPanel('website'),
    ImageChooserPanel('logo'),
]


class EventListPage(Page):
    subpage_types = ['EventPage']

    events_per_page = models.IntegerField(default=20)

    @property
开发者ID:albertoconnor,项目名称:website,代码行数:31,代码来源:models.py


示例16: FieldPanel

        FieldPanel('title', classname="full title"),
        FieldPanel('slug', classname="col6"),
        ColorFieldPanel('color', classname="col6 colorpicker-field"),
    ]

    def get_children(self):
        return 

    class Meta:
        verbose_name = _('Category')
        verbose_name_plural = _('Categories')

    def __unicode__(self):
        return u"%s" % self.title

register_snippet(Category)

class ArticleMixin(models.Model):
    author = models.ForeignKey(User, null=True, blank=True, on_delete=models.SET_NULL)
    date = models.DateField(null=True, blank=True)
    category = models.ForeignKey('Category', null=True, blank=True, on_delete=models.SET_NULL)
    excerpt = RichTextField(blank=True, verbose_name=_('Excerpt'))
    subtitle = models.CharField(max_length=255, null=True, blank=True)
    styles_override = models.TextField(null=True, blank=True)

    class Meta:
        abstract = True

BASE_ARTICLE_CONTENT_PANELS = [
    FieldPanel('title'),
    FieldPanel('subtitle'),
开发者ID:overcastsoftware,项目名称:oc-wagtail-article,代码行数:31,代码来源:models.py


示例17: NavigationMenu


class NavigationMenu(ClusterableModel):

    menu_name = models.CharField(max_length=255, null=False, blank=False)

    def __str__(self):
        return self.menu_name


NavigationMenu.panels = [
    edit_handlers.FieldPanel('menu_name', classname='full title'),
    edit_handlers.InlinePanel('menu_items', label="Menu Items")
]

register_snippet(NavigationMenu)
register_snippet(RSSImport)


# Blocks
class RSSImportBlock(core_blocks.StructBlock):
    feed = snippet_blocks.SnippetChooserBlock(
        required=True, target_model=RSSImport)

    class Meta:
        template = 'home/blocks/rss_import_block.html'
        icon = 'snippet'
        label = 'RSS Import'


class InlineImageBlock(core_blocks.StructBlock):
开发者ID:liqd,项目名称:euth_wagtail,代码行数:29,代码来源:models.py


示例18: Advert

@python_2_unicode_compatible
class Advert(models.Model):
    url = models.URLField(null=True, blank=True)
    text = models.CharField(max_length=255)

    panels = [
        FieldPanel('url'),
        FieldPanel('text'),
    ]

    def __str__(self):
        return self.text


register_snippet(Advert)


# AlphaSnippet and ZuluSnippet are for testing ordering of
# snippets when registering.  They are named as such to ensure
# thier ordering is clear.  They are registered during testing
# to ensure specific [in]correct register ordering

# AlphaSnippet is registered during TestSnippetOrdering
@python_2_unicode_compatible
class AlphaSnippet(models.Model):
    text = models.CharField(max_length=255)

    def __str__(self):
        return self.text
开发者ID:jalourenco,项目名称:wagtail,代码行数:29,代码来源:models.py


示例19: __str__

        rgb_value = [str(int(x, 16)) for x in split]
        rgb_string = ', '.join(rgb_value)
        return rgb_string

    def __str__(self):
        return self.name

    def save(self, *args, **kwargs):
        if not self.hex_value.startswith("#"):
            self.hex_value = "#{}".format(self.hex_value)
        super(Colour, self).save(*args, **kwargs)

    class Meta:
        ordering = ['name', ]

register_snippet(Colour)


@python_2_unicode_compatible
class FontStyle(models.Model):
    name = models.CharField(max_length=1024)
    font_size = models.FloatField(default=1, help_text="The size of the fonts in ems.")
    line_size = models.FloatField(default=100, help_text="The line height as a percentage.")
    text_colour = models.ForeignKey(
        Colour,
        default=1,
        null=True,
        on_delete=models.SET_NULL
    )

    panels = [
开发者ID:albertoconnor,项目名称:website,代码行数:31,代码来源:models.py


示例20: ImageChooserPanel

    ImageChooserPanel('feed_image'),
]



class Navigation(models.Model):
    title = models.CharField(max_length=255)
    slug = models.SlugField(max_length=255)
    navigation = StreamField([
        ('menu_block', blocks.StructBlock([
            ('title', blocks.CharBlock()),
            ('menu_items', blocks.ListBlock(blocks.StreamBlock([
                ('link_external', blocks.StructBlock([
                        ('caption', blocks.CharBlock()),
                        ('url', blocks.CharBlock()),
                    ])),
                ('link_page', blocks.PageChooserBlock()),
            ])))])),
    ], blank=True)

    panels = [
        FieldPanel('title'),
        FieldPanel('slug'),
        StreamFieldPanel('navigation'),
    ]

    def __unicode__(self):
        return self.title

register_snippet(Navigation)
开发者ID:tobiase,项目名称:oc-wagtail-core,代码行数:30,代码来源:models.py



注:本文中的wagtail.wagtailsnippets.models.register_snippet函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.UserProfile类代码示例发布时间:2022-05-26
下一篇:
Python models.Query类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap