-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
287 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django.contrib import admin | ||
|
||
from .models import Pizza, Topping | ||
|
||
|
||
class ToppingInlineAdmin(admin.TabularInline): | ||
model = Topping | ||
extra = 1 | ||
|
||
|
||
class PizzaAdmin(admin.ModelAdmin): | ||
fieldsets = ( | ||
('', { | ||
'fields': ('description',), | ||
}), | ||
('Advanced', { | ||
# NOTE: Disabled because when PizzaAdmin uses a collapsed | ||
# class then the order of javascript libs is incorrect. | ||
# 'classes': ('collapse',), | ||
'fields': ('allergens',), | ||
}), | ||
) | ||
inlines = [ToppingInlineAdmin] | ||
|
||
|
||
admin.site.register(Pizza, PizzaAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from django.template import engines | ||
|
||
from cms.models import CMSPlugin | ||
from cms.plugin_base import CMSPluginBase | ||
from cms.plugin_pool import plugin_pool | ||
from cms.utils.plugins import get_plugin_model | ||
|
||
from djangocms_text.cms_plugins import TextPlugin | ||
from tests.test_app.models import DummyLink, DummySpacer | ||
|
||
|
||
@plugin_pool.register_plugin | ||
class PreviewDisabledPlugin(CMSPluginBase): | ||
text_editor_preview = False | ||
|
||
def get_render_template(self, context, instance, placeholder): | ||
template = '<span>Preview is disabled for this plugin</span>' | ||
return engines['django'].from_string(template) | ||
|
||
|
||
@plugin_pool.register_plugin | ||
class SekizaiPlugin(CMSPluginBase): | ||
name = 'Sekizai' | ||
render_template = 'test_app/plugin_with_sekizai.html' | ||
|
||
|
||
@plugin_pool.register_plugin | ||
class ExtendedTextPlugin(TextPlugin): | ||
name = 'Extended' | ||
|
||
|
||
@plugin_pool.register_plugin | ||
class DummyLinkPlugin(CMSPluginBase): | ||
render_plugin = False | ||
model = DummyLink | ||
|
||
|
||
@plugin_pool.register_plugin | ||
class DummySpacerPlugin(CMSPluginBase): | ||
render_plugin = False | ||
model = DummySpacer | ||
|
||
|
||
@plugin_pool.register_plugin | ||
class DummyParentPlugin(CMSPluginBase): | ||
render_template = 'test_app/dummy_parent_plugin.html' | ||
model = DummyLink | ||
allow_children = True | ||
|
||
_ckeditor_body_class = 'parent-plugin-css-class' | ||
_ckeditor_body_class_label_trigger = 'parent link label' | ||
|
||
@classmethod | ||
def get_child_ckeditor_body_css_class(cls, plugin: CMSPlugin) -> str: | ||
plugin_model = get_plugin_model(plugin.plugin_type) | ||
plugin_instance = plugin_model.objects.get(pk=plugin.pk) | ||
if plugin_instance.label == cls._ckeditor_body_class_label_trigger: | ||
return cls._ckeditor_body_class | ||
else: | ||
return '' | ||
|
||
|
||
@plugin_pool.register_plugin | ||
class DummyChildPlugin(CMSPluginBase): | ||
render_template = 'test_app/dummy_child_plugin.html' | ||
child_ckeditor_body_css_class = 'child-plugin-css-class' | ||
allow_children = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django import forms | ||
|
||
from djangocms_text.fields import HTMLFormField | ||
|
||
|
||
class SimpleTextForm(forms.Form): | ||
text = HTMLFormField() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from django.db import models | ||
|
||
from cms.models import CMSPlugin | ||
|
||
from djangocms_text.fields import HTMLField | ||
|
||
|
||
class SimpleText(models.Model): | ||
text = HTMLField(blank=True) | ||
|
||
|
||
class DummyLink(CMSPlugin): | ||
label = models.TextField() | ||
|
||
class Meta: | ||
abstract = False | ||
|
||
def __str__(self): | ||
return 'dummy link object' | ||
|
||
|
||
class DummySpacer(CMSPlugin): | ||
class Meta: | ||
abstract = False | ||
|
||
def __str__(self): | ||
return 'dummy spacer object' | ||
|
||
|
||
class Pizza(models.Model): | ||
description = HTMLField() | ||
allergens = HTMLField(blank=True) | ||
|
||
|
||
class Topping(models.Model): | ||
name = models.CharField(max_length=255) | ||
description = HTMLField() | ||
pizza = models.ForeignKey(Pizza, on_delete=models.CASCADE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% load cms_tags static menu_tags sekizai_tags %} | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>{% block title %}This is my new project home page{% endblock title %}</title> | ||
{% render_block "css" %} | ||
<style type="text/css"> | ||
.nav { | ||
padding-left: 0; | ||
} | ||
.nav li { | ||
display: inline; | ||
list-style-type: none; | ||
padding-right: 20px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
{% cms_toolbar %} | ||
<div style="width: 940px; margin:0 auto"> | ||
<ul class="nav"> | ||
{% show_menu 0 100 100 100 %} | ||
</ul> | ||
{% block content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% load cms_tags %} | ||
|
||
{% for plugin in instance.child_plugin_instances %} | ||
{% render_plugin plugin %} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% load cms_tags %} | ||
|
||
{% for plugin in instance.child_plugin_instances %} | ||
{% render_plugin plugin %} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{% extends "base.html" %} | ||
{% load cms_tags %} | ||
|
||
{% block title %}{% page_attribute 'title' %}{% endblock title %} | ||
|
||
{% block content %} | ||
{% placeholder "content" %} | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{% load sekizai_tags %} | ||
{% addtoblock "css" %}<link rel="stylesheet" href="/static/css/sekizai.css">{% endaddtoblock %} |