Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
),
migrations.CreateModel(
name="ExampleCMSBase",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
)
],
options={"abstract": False},
bases=(models.Model, feincms.extensions.base.ExtensionsMixin),
),
migrations.CreateModel(
name="ExampleCMSBase2",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
)
],
options={"abstract": False},
bases=(models.Model, feincms.extensions.base.ExtensionsMixin),
),
migrations.CreateModel(
name="MyModel",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
)
],
options={"abstract": False},
bases=(models.Model, feincms.extensions.base.ExtensionsMixin),
),
migrations.AddField(
model_name="customcontenttype",
name="parent",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="customcontenttype_set",
to="testapp.MyModel",
),
('last', models.NullBooleanField(verbose_name='Is last?')),
('visible', models.NullBooleanField(verbose_name='Is visible?')),
('include_contextual_pages', models.BooleanField(default=False, verbose_name='include contextual pages')),
('include_text_headers', models.BooleanField(default=False, verbose_name='include text headers')),
('region', models.CharField(max_length=255)),
('ordering', models.IntegerField(default=0, verbose_name='ordering')),
],
options={
'ordering': ['ordering'],
'abstract': False,
'verbose_name_plural': 'content navigations',
'db_table': 'web_page_contentnavigationwidget',
'verbose_name': 'content navigation',
'permissions': [],
},
bases=(models.Model, feincms.extensions.ExtensionsMixin),
),
migrations.CreateModel(
name='ContextNavigationWidget',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('options', django_extensions.db.fields.json.JSONField(verbose_name='widget options', editable=False, blank=True)),
('prerendered_content', models.TextField(verbose_name='prerendered content', editable=False, blank=True)),
('label', models.CharField(max_length=255, verbose_name='Title')),
('span', models.IntegerField(default=12, verbose_name='Span', choices=[(0, b' \xe2\x80\x94 '), (1, '1 col'), (2, '2 cols'), (3, '3 cols'), (4, '4 cols'), (5, '5 cols'), (6, '6 cols'), (7, '7 cols'), (8, '8 cols'), (9, '9 cols'), (10, '10 cols'), (11, '11 cols'), (12, '12 cols')])),
('vertical_span', models.IntegerField(default=12, verbose_name='V. Span', choices=[(0, b' \xe2\x80\x94 '), (1, '1 row'), (2, '2 rows'), (3, '3 rows'), (4, '4 rows'), (5, '5 rows'), (6, '6 rows'), (7, '7 rows'), (8, '8 rows'), (9, '9 rows'), (10, '10 rows'), (11, '11 rows'), (12, '12 rows'), (13, '13 rows'), (14, '14 rows'), (15, '15 rows'), (16, '16 rows'), (17, '17 rows'), (18, '18 rows'), (19, '19 rows'), (20, '20 rows'), (21, '21 rows'), (22, '22 rows'), (23, '23 rows'), (24, '24 rows')])),
('align', models.IntegerField(verbose_name='Alignment', choices=[(0, 'auto'), (1, 'left'), (2, 'center'), (3, 'right')])),
('vertical_align', models.IntegerField(default=0, verbose_name='V. Alignment', choices=[(0, 'auto'), (1, 'top'), (2, 'middle'), (3, 'bottom')])),
('prepend', models.IntegerField(default=12, verbose_name='Prepend', choices=[(0, b' \xe2\x80\x94 '), (1, '1 col'), (2, '2 cols'), (3, '3 cols'), (4, '4 cols'), (5, '5 cols'), (6, '6 cols'), (7, '7 cols'), (8, '8 cols'), (9, '9 cols'), (10, '10 cols'), (11, '11 cols'), (12, '12 cols')])),
('append', models.IntegerField(default=0, verbose_name='Append', choices=[(0, b' \xe2\x80\x94 '), (1, '1 col'), (2, '2 cols'), (3, '3 cols'), (4, '4 cols'), (5, '5 cols'), (6, '6 cols'), (7, '7 cols'), (8, '8 cols'), (9, '9 cols'), (10, '10 cols'), (11, '11 cols'), (12, '12 cols')])),
('push', models.IntegerField(default=0, verbose_name='Push', choices=[(0, b' \xe2\x80\x94 '), (1, '1 col'), (2, '2 cols'), (3, '3 cols'), (4, '4 cols'), (5, '5 cols'), (6, '6 cols'), (7, '7 cols'), (8, '8 cols'), (9, '9 cols'), (10, '10 cols'), (11, '11 cols'), (12, '12 cols')])),
('pull', models.IntegerField(default=12, verbose_name='Pull', choices=[(0, b' \xe2\x80\x94 '), (1, '1 col'), (2, '2 cols'), (3, '3 cols'), (4, '4 cols'), (5, '5 cols'), (6, '6 cols'), (7, '7 cols'), (8, '8 cols'), (9, '9 cols'), (10, '10 cols'), (11, '11 cols'), (12, '12 cols')])),
from django.db import models
from django.utils.translation import ugettext_lazy as _
from feincms import extensions
class Extension(extensions.Extension):
ident = 'author'
def handle_model(self):
self.model.add_to_class('author', models.ForeignKey('auth.User',
verbose_name=_('author'), blank=True, null=True))
def handle_modeladmin(self, modeladmin):
modeladmin.fieldsets[0][1]['fields'].append('author')
modeladmin.raw_id_fields.append('author')
raise forms.ValidationError(_('Percent must be 100 in total! '
'Now is %d %%' % total_percent))
if self.forms and num_primary != 1:
raise forms.ValidationError(_('You must define exactly one '
'primary receiver'))
class ReceiverInlineAdmin(admin.StackedInline):
model = Receiver
formset = ReceiverInlineFormset
extra = 0
feincms_inline = True
class Extension(extensions.Extension):
ident = 'paypal_receivers'
def handle_model(self):
pass
def handle_modeladmin(cls, modeladmin):
modeladmin.inlines.insert(1, ReceiverInlineAdmin)
def handle_modeladmin(self, modeladmin):
extensions.prefetch_modeladmin_get_queryset(
modeladmin, 'translation_of__translations', 'translations')
def available_translations_admin(self, page):
# Do not use available_translations() because we don't care
# whether pages are active or not here.
translations = [page]
translations.extend(page.translations.all())
if page.translation_of:
translations.append(page.translation_of)
translations.extend(page.translation_of.translations.all())
translations = {
p.language: p.id
for p in translations
}
links = []
def handle_modeladmin(self, modeladmin):
extensions.prefetch_modeladmin_get_queryset(
modeladmin, 'translation_of__translations', 'translations')
def available_translations_admin(self, page):
translations = dict(
(p.language, p.id) for p in page.available_translations())
links = []
for key, title in django_settings.LANGUAGES:
if key == page.language:
continue
if key in translations:
links.append('<a title="%s" href="%s/">%s</a>' % (
translations[key], _('Edit translation'), key.upper()))
else:
def datepublisher_response_processor(page, request, response):
"""
This response processor is automatically added when the datepublisher
extension is registered. It sets the response headers to match with
the publication end date of the page so that upstream caches and
the django caching middleware know when to expunge the copy.
"""
expires = page.publication_end_date
if expires is not None:
delta = expires - timezone.now()
delta = int(delta.days * 86400 + delta.seconds)
patch_response_headers(response, delta)
# ------------------------------------------------------------------------
class Extension(extensions.Extension):
def handle_model(self):
self.model.add_to_class(
"publication_date",
models.DateTimeField(_("publication date"), default=granular_now),
)
self.model.add_to_class(
"publication_end_date",
models.DateTimeField(
_("publication end date"),
blank=True,
null=True,
help_text=_("Leave empty if the entry should stay active forever."),
),
)
self.model.add_to_class("latest_children", latest_children)