This commit is contained in:
Nick Smith 2014-07-07 14:59:17 +01:00
parent e35f23e0f6
commit bc9ed8086d
2 changed files with 12 additions and 12 deletions

View file

@ -68,14 +68,14 @@ class Site(models.Model):
still be routed to a different hostname which is set as the default
"""
try:
hostname = request.META['HTTP_HOST'].split(':')[0] # KeyError here goes to the final except clause
hostname = request.META['HTTP_HOST'].split(':')[0] # KeyError here goes to the final except clause
try:
# find a Site matching this specific hostname
return Site.objects.get(hostname=hostname) # Site.DoesNotExist here goes to the final except clause
return Site.objects.get(hostname=hostname) # Site.DoesNotExist here goes to the final except clause
except Site.MultipleObjectsReturned:
# as there were more than one, try matching by port too
port = request.META['SERVER_PORT'] # KeyError here goes to the final except clause
return Site.objects.get(hostname=hostname, port=int(port)) # Site.DoesNotExist here goes to the final except clause
port = request.META['SERVER_PORT'] # KeyError here goes to the final except clause
return Site.objects.get(hostname=hostname, port=int(port)) # Site.DoesNotExist here goes to the final except clause
except (Site.DoesNotExist, KeyError):
# If no matching site exists, or request does not specify an HTTP_HOST (which
# will often be the case for the Django test client), look for a catch-all Site.
@ -105,9 +105,9 @@ class Site(models.Model):
raise ValidationError(
{'is_default_site': [
_("%(hostname)s is already configured as the default site. You must unset that before you can save this site as default.")
% { 'hostname': default.hostname }
]}
)
% {'hostname': default.hostname}
]}
)
# clear the wagtail_site_root_paths cache whenever Site records are updated
def save(self, *args, **kwargs):
@ -158,6 +158,7 @@ def get_leaf_page_content_type_ids():
if not getattr(content_type.model_class(), 'subpage_types', None)
]
def get_navigable_page_content_type_ids():
warnings.warn("""
get_navigable_page_content_type_ids is deprecated, as it treats pages without an explicit subpage_types
@ -371,8 +372,7 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, indexed.Index
SET url_path = %s || substring(url_path from %s)
WHERE path LIKE %s AND id <> %s
"""
cursor.execute(update_statement,
[new_url_path, len(old_url_path) + 1, self.path + '%', self.id])
cursor.execute(update_statement, [new_url_path, len(old_url_path) + 1, self.path + '%', self.id])
@cached_property
def specific(self):
@ -829,7 +829,7 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, indexed.Index
def get_navigation_menu_items():
# Get all pages that appear in the navigation menu: ones which have children,
# or are at the top-level (this rule required so that an empty site out-of-the-box has a working menu)
pages = Page.objects.filter(Q(depth=2)|Q(numchild__gt=0)).order_by('path')
pages = Page.objects.filter(Q(depth=2) | Q(numchild__gt=0)).order_by('path')
# Turn this into a tree structure:
# tree_node = (page, children)
@ -1049,7 +1049,7 @@ class PagePermissionTester(object):
self.user = user_perms.user
self.user_perms = user_perms
self.page = page
self.page_is_root = page.depth == 1 # Equivalent to page.is_root()
self.page_is_root = page.depth == 1 # Equivalent to page.is_root()
if self.user.is_active and not self.user.is_superuser:
self.permissions = set(

View file

@ -87,7 +87,7 @@ def create(request):
messages.success(request, _("Group '{0}' created.").format(group))
return redirect('wagtailusers_groups_index')
else:
messages.error(request, _("The group could not be created due to errors.") )
messages.error(request, _("The group could not be created due to errors."))
else:
form = GroupForm()