Added ungleich app to extend Page models.
Ungleich app has a model called UngleichPage, this model has an attribute called image_header which will be used to set the background image for the page header. Signed-off-by: rscnt <rascnt@gmail.com>
This commit is contained in:
parent
6c312a6e2e
commit
76bfb3c47b
10 changed files with 152 additions and 11 deletions
0
ungleich/__init__.py
Normal file
0
ungleich/__init__.py
Normal file
12
ungleich/admin.py
Normal file
12
ungleich/admin.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
from django.contrib import admin
|
||||
from cms.extensions import PageExtensionAdmin
|
||||
|
||||
# Register your models here.
|
||||
|
||||
from .models import UngleichPage
|
||||
|
||||
|
||||
class UngleichPageAdmin(PageExtensionAdmin):
|
||||
pass
|
||||
|
||||
admin.site.register(UngleichPage, UngleichPageAdmin)
|
||||
25
ungleich/cms_toolbar.py
Normal file
25
ungleich/cms_toolbar.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from cms.extensions.toolbar import ExtensionToolbar
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from cms.toolbar_pool import toolbar_pool
|
||||
from cms.toolbar_base import CMSToolbar
|
||||
|
||||
from .models import UngleichPage
|
||||
|
||||
|
||||
@toolbar_pool.register
|
||||
class UngleichPageToolbar(ExtensionToolbar):
|
||||
# defineds the model for the current toolbar
|
||||
model = UngleichPage
|
||||
|
||||
def populate(self):
|
||||
# setup the extension toolbar with permissions and sanity checks
|
||||
current_page_menu = self._setup_extension_toolbar()
|
||||
# if it's all ok
|
||||
if current_page_menu:
|
||||
# retrieves the instance of the current extension (if any) and the toolbar item url
|
||||
page_extension, url = self.get_page_extension_admin()
|
||||
if url:
|
||||
# adds a toolbar item
|
||||
current_page_menu.add_modal_item(_('Page Header'), url=url,
|
||||
disabled=not self.toolbar.edit_mode)
|
||||
27
ungleich/migrations/0001_initial.py
Normal file
27
ungleich/migrations/0001_initial.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cms', '0011_auto_20150419_1006'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='UngleichPage',
|
||||
fields=[
|
||||
('id', models.AutoField(serialize=False, primary_key=True, auto_created=True, verbose_name='ID')),
|
||||
('image_header', models.ImageField(upload_to='image_header')),
|
||||
('extended_object', models.OneToOneField(editable=False, to='cms.Page')),
|
||||
('public_extension', models.OneToOneField(editable=False, related_name='draft_extension', null=True, to='ungleich.UngleichPage')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
]
|
||||
0
ungleich/migrations/__init__.py
Normal file
0
ungleich/migrations/__init__.py
Normal file
12
ungleich/models.py
Normal file
12
ungleich/models.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
from django.db import models
|
||||
|
||||
from cms.extensions import PageExtension
|
||||
from cms.extensions.extension_pool import extension_pool
|
||||
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class UngleichPage(PageExtension):
|
||||
image_header = models.ImageField(upload_to='image_header')
|
||||
|
||||
extension_pool.register(UngleichPage)
|
||||
3
ungleich/tests.py
Normal file
3
ungleich/tests.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
ungleich/views.py
Normal file
3
ungleich/views.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Loading…
Add table
Add a link
Reference in a new issue