mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-15 12:31:00 +00:00
Merge pull request #330 from kaedroho/wagtailcore-cleanup
Wagtailcore cleanup
This commit is contained in:
commit
58ed918129
5 changed files with 33 additions and 26 deletions
|
|
@ -19,7 +19,7 @@ from django.utils.translation import ugettext as _
|
|||
from django.utils.translation import ugettext_lazy
|
||||
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail.wagtailcore.util import camelcase_to_underscore
|
||||
from wagtail.wagtailcore.utils import camelcase_to_underscore
|
||||
from wagtail.wagtailcore.fields import RichTextArea
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from wagtail.wagtailadmin import hooks
|
|||
from wagtail.wagtailadmin.menu import MenuItem
|
||||
|
||||
from wagtail.wagtailcore.models import get_navigation_menu_items, UserPagePermissionsProxy
|
||||
from wagtail.wagtailcore.util import camelcase_to_underscore
|
||||
from wagtail.wagtailcore.utils import camelcase_to_underscore
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||
|
||||
from treebeard.mp_tree import MP_Node
|
||||
|
||||
from wagtail.wagtailcore.util import camelcase_to_underscore
|
||||
from wagtail.wagtailcore.utils import camelcase_to_underscore
|
||||
from wagtail.wagtailcore.query import PageQuerySet
|
||||
|
||||
from wagtail.wagtailsearch import Indexed, get_search_backend
|
||||
|
|
@ -126,56 +126,56 @@ def get_navigable_page_content_type_ids():
|
|||
|
||||
|
||||
class PageManager(models.Manager):
|
||||
def get_query_set(self):
|
||||
def get_queryset(self):
|
||||
return PageQuerySet(self.model).order_by('path')
|
||||
|
||||
def live(self):
|
||||
return self.get_query_set().live()
|
||||
return self.get_queryset().live()
|
||||
|
||||
def not_live(self):
|
||||
return self.get_query_set().not_live()
|
||||
return self.get_queryset().not_live()
|
||||
|
||||
def page(self, other):
|
||||
return self.get_query_set().page(other)
|
||||
return self.get_queryset().page(other)
|
||||
|
||||
def not_page(self, other):
|
||||
return self.get_query_set().not_page(other)
|
||||
return self.get_queryset().not_page(other)
|
||||
|
||||
def descendant_of(self, other, inclusive=False):
|
||||
return self.get_query_set().descendant_of(other, inclusive)
|
||||
return self.get_queryset().descendant_of(other, inclusive)
|
||||
|
||||
def not_descendant_of(self, other, inclusive=False):
|
||||
return self.get_query_set().not_descendant_of(other, inclusive)
|
||||
return self.get_queryset().not_descendant_of(other, inclusive)
|
||||
|
||||
def child_of(self, other):
|
||||
return self.get_query_set().child_of(other)
|
||||
return self.get_queryset().child_of(other)
|
||||
|
||||
def not_child_of(self, other):
|
||||
return self.get_query_set().not_child_of(other)
|
||||
return self.get_queryset().not_child_of(other)
|
||||
|
||||
def ancestor_of(self, other, inclusive=False):
|
||||
return self.get_query_set().ancestor_of(other, inclusive)
|
||||
return self.get_queryset().ancestor_of(other, inclusive)
|
||||
|
||||
def not_ancestor_of(self, other, inclusive=False):
|
||||
return self.get_query_set().not_ancestor_of(other, inclusive)
|
||||
return self.get_queryset().not_ancestor_of(other, inclusive)
|
||||
|
||||
def parent_of(self, other):
|
||||
return self.get_query_set().parent_of(other)
|
||||
return self.get_queryset().parent_of(other)
|
||||
|
||||
def not_parent_of(self, other):
|
||||
return self.get_query_set().not_parent_of(other)
|
||||
return self.get_queryset().not_parent_of(other)
|
||||
|
||||
def sibling_of(self, other, inclusive=False):
|
||||
return self.get_query_set().sibling_of(other, inclusive)
|
||||
return self.get_queryset().sibling_of(other, inclusive)
|
||||
|
||||
def not_sibling_of(self, other, inclusive=False):
|
||||
return self.get_query_set().not_sibling_of(other, inclusive)
|
||||
return self.get_queryset().not_sibling_of(other, inclusive)
|
||||
|
||||
def type(self, model):
|
||||
return self.get_query_set().type(model)
|
||||
return self.get_queryset().type(model)
|
||||
|
||||
def not_type(self, model):
|
||||
return self.get_query_set().not_type(model)
|
||||
return self.get_queryset().not_type(model)
|
||||
|
||||
|
||||
class PageBase(models.base.ModelBase):
|
||||
|
|
@ -697,8 +697,8 @@ class Orderable(models.Model):
|
|||
|
||||
|
||||
class SubmittedRevisionsManager(models.Manager):
|
||||
def get_query_set(self):
|
||||
return super(SubmittedRevisionsManager, self).get_query_set().filter(submitted_for_moderation=True)
|
||||
def get_queryset(self):
|
||||
return super(SubmittedRevisionsManager, self).get_queryset().filter(submitted_for_moderation=True)
|
||||
|
||||
|
||||
class PageRevision(models.Model):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import re
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"The wagtail.wagtailcore.util module has been renamed. "
|
||||
"Use wagtail.wagtailcore.utils instead.", DeprecationWarning)
|
||||
|
||||
def camelcase_to_underscore(str):
|
||||
# http://djangosnippets.org/snippets/585/
|
||||
return re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', '_\\1', str).lower().strip('_')
|
||||
from .utils import *
|
||||
|
|
|
|||
6
wagtail/wagtailcore/utils.py
Normal file
6
wagtail/wagtailcore/utils.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import re
|
||||
|
||||
|
||||
def camelcase_to_underscore(str):
|
||||
# http://djangosnippets.org/snippets/585/
|
||||
return re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', '_\\1', str).lower().strip('_')
|
||||
Loading…
Reference in a new issue