Skip to content

Commit

Permalink
Merge pull request #3803 from timgraham/whitespace
Browse files Browse the repository at this point in the history
Removed trailing whitespace and blank lines.
  • Loading branch information
ojii committed Jan 27, 2015
2 parents 0dbb961 + 3c4ad7c commit 379e120
Show file tree
Hide file tree
Showing 136 changed files with 547 additions and 588 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Open source enterprise content management system based on the django framework.
.. ATTENTION:: This is the **develop** branch. It's the branch for features that
will go into django CMS 3.1. The **master** branch is the current stable release,
the one released on PyPI.

**support/3.0.x** will be our *next stable release*, the most
appropriate branch for fixes and patches that will go into the next **master**.

Expand Down
2 changes: 1 addition & 1 deletion cms/admin/permissionadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def raw_id_fields(cls):
def get_queryset(self, request):
"""
Queryset change, so user with global change permissions can see
all permissions. Otherwise can user see only permissions for
all permissions. Otherwise can user see only permissions for
peoples which are under him (he can't see his permissions, because
this will lead to violation, when he can add more power to itself)
"""
Expand Down
8 changes: 4 additions & 4 deletions cms/admin/useradmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PageUserAdmin(admin_class, GenericCmsPermissionAdmin):
form = PageUserForm
add_form = PageUserForm
model = PageUser

def get_queryset(self, request):
qs = super(PageUserAdmin, self).get_queryset(request)
try:
Expand All @@ -30,15 +30,15 @@ def get_queryset(self, request):
except NoPermissionsException:
return self.model.objects.get_empty_query_set()


class PageUserGroupAdmin(admin.ModelAdmin, GenericCmsPermissionAdmin):
form = PageUserGroupForm
list_display = ('name', 'created_by')

fieldsets = [
(None, {'fields': ('name',)}),
]

def get_fieldsets(self, request, obj=None):
return self.update_permission_fieldsets(request, obj)

Expand Down
6 changes: 3 additions & 3 deletions cms/admin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def revert_plugins(request, version_id, obj):
for rev in revs:
obj = rev.object
if obj.__class__ == Placeholder:
placeholders[obj.pk] = obj
placeholders[obj.pk] = obj
if obj.__class__ == CMSPlugin:
cms_plugin_list.append(obj)
elif hasattr(obj, 'cmsplugin_ptr_id'):
Expand All @@ -27,14 +27,14 @@ def revert_plugins(request, version_id, obj):
pass
#page = obj #Page.objects.get(pk=obj.pk)
elif obj.__class__ == Title:
titles.append(obj)
titles.append(obj)
else:
others.append(rev)
if not page.has_change_permission(request):
raise Http404
current_plugins = list(CMSPlugin.objects.filter(placeholder__page=page))
for pk, placeholder in placeholders.items():
# admin has already created the placeholders/ get them instead
# admin has already created the placeholders/ get them instead
try:
placeholders[pk] = page.placeholders.get(slot=placeholder.slot)
except Placeholder.DoesNotExist:
Expand Down
18 changes: 9 additions & 9 deletions cms/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@


#===============================================================================
# Constants
# Constants
#===============================================================================

VISIBILITY_ALL = None
Expand Down Expand Up @@ -118,7 +118,7 @@ def _verify_plugin_type(plugin_type):


#===============================================================================
# Public API
# Public API
#===============================================================================

def create_page(title, template, language, menu_title=None, slug=None,
Expand All @@ -131,7 +131,7 @@ def create_page(title, template, language, menu_title=None, slug=None,
position="last-child", overwrite_url=None, xframe_options=Page.X_FRAME_OPTIONS_INHERIT):
"""
Create a CMS Page and it's title for the given language
See docs/extending_cms/api_reference.rst for more info
"""
# ugly permissions hack
Expand Down Expand Up @@ -249,9 +249,9 @@ def create_title(language, title, page, menu_title=None, slug=None,
parent=None, overwrite_url=None):
"""
Create a title.
Parent is only used if slug=None.
See docs/extending_cms/api_reference.rst for more info
"""
# validate page
Expand Down Expand Up @@ -286,7 +286,7 @@ def add_plugin(placeholder, plugin_type, language, position='last-child',
target=None, **data):
"""
Add a plugin to a placeholder
See docs/extending_cms/api_reference.rst for more info
"""
# validate placeholder
Expand Down Expand Up @@ -365,7 +365,7 @@ def create_page_user(created_by, user,
can_delete_pagepermission=True, grant_all=False):
"""
Creates a page user.
See docs/extending_cms/api_reference.rst for more info
"""
if grant_all:
Expand Down Expand Up @@ -408,7 +408,7 @@ def assign_user_to_page(page, user, grant_on=ACCESS_PAGE_AND_DESCENDANTS,
grant_all=False, global_permission=False):
"""
Assigns given user to page, and gives him requested permissions.
See docs/extending_cms/api_reference.rst for more info
"""
grant_all = grant_all and not global_permission
Expand Down Expand Up @@ -438,7 +438,7 @@ def publish_page(page, user, language):
"""
Publish a page. This sets `page.published` to `True` and calls publish()
which does the actual publishing.
See docs/extending_cms/api_reference.rst for more info
"""
page = page.reload()
Expand Down
4 changes: 2 additions & 2 deletions cms/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class AppAlreadyRegistered(Exception):
class ToolbarAlreadyRegistered(Exception):
pass


class ToolbarNotRegistered(Exception):
pass

Expand All @@ -47,7 +48,7 @@ class PermissionsException(Exception):


class NoPermissionsException(PermissionsException):
"""Can be fired when some violate action is performed on permission system.
"""Can be fired when some violate action is performed on permission system.
"""


Expand Down Expand Up @@ -81,4 +82,3 @@ class PluginConsistencyError(Exception): pass


class PlaceholderNotFound(Exception): pass

1 change: 0 additions & 1 deletion cms/extensions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,3 @@ def add_view(self, request, form_url='', extra_context=None):
except self.model.DoesNotExist:
pass
return super(ExtensionAdmin, self).add_view(request, form_url, extra_context)

1 change: 0 additions & 1 deletion cms/extensions/extension_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,3 @@ def _remove_orphaned_title_extensions(self):


extension_pool = ExtensionPool()

3 changes: 0 additions & 3 deletions cms/extensions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,3 @@ def delete(self, *args, **kwargs):
Title.objects.filter(pk=self.extended_object.pk).update(
publisher_state=PUBLISHER_STATE_DIRTY) # mark title dirty
return super(BaseExtension, self).delete(*args, **kwargs)



1 change: 0 additions & 1 deletion cms/forms/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

4 changes: 2 additions & 2 deletions cms/management/commands/subcommands/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand, CommandError
import sys

from django.core.management.base import BaseCommand, CommandError


class SubcommandsCommand(BaseCommand):
Expand Down Expand Up @@ -33,4 +33,4 @@ def handle(self, *args, **options):
stderr.write("Available subcommands are:\n")
for subcommand in sorted(self.subcommands.keys()):
stderr.write(" %r\n" % subcommand)
raise CommandError('No subcommand given for %r' % self.command_name)
raise CommandError('No subcommand given for %r' % self.command_name)
2 changes: 1 addition & 1 deletion cms/management/commands/subcommands/copy_lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def handle(self, *args, **kwargs):

from_lang = args[0]
to_lang = args[1]

assert from_lang != to_lang
except AssertionError:
raise CommandError("Error: bad arguments -- Usage: manage.py cms copy-lang <lang_from> <lang_to>")
Expand Down
24 changes: 12 additions & 12 deletions cms/management/commands/subcommands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from django.core.management.base import NoArgsCommand

class ListApphooksCommand(NoArgsCommand):

help = 'Lists all apphooks in pages'
def handle_noargs(self, **options):
urls = Page.objects.filter(application_urls__gt='').values_list("application_urls", flat=True)
for url in urls:
self.stdout.write(u'%s\n' % url)

def plugin_report():
# structure of report:
# [
Expand All @@ -28,44 +28,44 @@ def plugin_report():
plugin_types = list(set(all_plugins.values_list("plugin_type", flat=True)))
plugin_types.sort()

for plugin_type in plugin_types:
for plugin_type in plugin_types:
plugin = {}
plugin["type"] = plugin_type
try:
# get all plugins of this type
# get all plugins of this type
plugins = CMSPlugin.objects.filter(plugin_type=plugin_type)
plugin["instances"] = plugins
# does this plugin have a model? report unsaved instances
plugin["model"] = plugin_pool.get_plugin(name=plugin_type).model
unsaved_instances = [p for p in plugins if not p.get_plugin_instance()[0]]
plugin["unsaved_instances"] = unsaved_instances

# catch uninstalled plugins
except KeyError:
plugin["model"] = None
plugin["instances"] = plugins
plugin["unsaved_instances"] = []

plugin_report.append(plugin)

return plugin_report



class ListPluginsCommand(NoArgsCommand):

help = 'Lists all plugins in CMSPlugin'
def handle_noargs(self, **options):
self.stdout.write(u"==== Plugin report ==== \n\n")
self.stdout.write(u"There are %s plugin types in your database \n" % len(plugin_report()))
for plugin in plugin_report():
for plugin in plugin_report():
self.stdout.write(u"\n%s \n" % plugin["type"])

plugin_model = plugin["model"]
instances = len(plugin["instances"])
unsaved_instances = len(plugin["unsaved_instances"])

if not plugin_model:
if not plugin_model:
self.stdout.write(self.style.ERROR(" ERROR : not installed \n"))

elif plugin_model == CMSPlugin:
Expand All @@ -75,12 +75,12 @@ def handle_noargs(self, **options):
else:
self.stdout.write(u" model : %s.%s \n" %
(plugin_model.__module__, plugin_model.__name__))
if unsaved_instances:
if unsaved_instances:
self.stdout.write(self.style.ERROR(" ERROR : %s unsaved instance(s) \n" % unsaved_instances))

self.stdout.write(u" instance(s): %s \n" % instances)


class ListCommand(SubcommandsCommand):
help = 'List commands'
subcommands = {
Expand Down
28 changes: 14 additions & 14 deletions cms/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ def has_permission_membership(page):
is_setting_public_staff and request.user.is_staff)
):
# authenticated user, no restriction and public for all
# or
# or
# authenticated staff user, no restriction and public for staff
to_add = True
# check group and user memberships to restricted pages
elif is_restricted and has_permission_membership(page):
to_add = True
elif has_global_perm():
to_add = True
# anonymous user, no restriction
# anonymous user, no restriction
elif not is_restricted and is_setting_public_all:
to_add = True
# store it
Expand Down Expand Up @@ -176,7 +176,7 @@ def page_to_node(page, home, cut):
#if parent_id and not page.parent.get_calculated_status():
# parent_id = None # ????

if page.limit_visibility_in_menu == None:
if page.limit_visibility_in_menu is None:
attr['visible_for_authenticated'] = True
attr['visible_for_anonymous'] = True
else:
Expand Down Expand Up @@ -311,7 +311,7 @@ def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
if node.namespace == menu[0]:
removed.append(node)
if breadcrumb:
# if breadcrumb and home not in navigation add node
# if breadcrumb and home not in navigation add node
if breadcrumb and home and not home.visible:
home.visible = True
if request.path_info == home.get_absolute_url():
Expand All @@ -330,26 +330,26 @@ def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
class SoftRootCutter(Modifier):
"""
Ask evildmp/superdmp if you don't understand softroots!
Softroot description from the docs:
A soft root is a page that acts as the root for a menu navigation tree.
Typically, this will be a page that is the root of a significant new
section on your site.
When the soft root feature is enabled, the navigation menu for any page
will start at the nearest soft root, rather than at the real root of
the site’s page hierarchy.
This feature is useful when your site has deep page hierarchies (and
therefore multiple levels in its navigation trees). In such a case, you
usually don’t want to present site visitors with deep menus of nested
items.
For example, you’re on the page -Introduction to Bleeding-?, so the menu
might look like this:
School of Medicine
Medical Education
Departments
Expand All @@ -375,12 +375,12 @@ class SoftRootCutter(Modifier):
Administration
Contact us
Impressum
which is frankly overwhelming.
By making -Department of Mediaeval Surgery-? a soft root, the menu
becomes much more manageable:
Department of Mediaeval Surgery
Theory
Cures
Expand Down
2 changes: 1 addition & 1 deletion cms/menu_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class CMSAttachMenu(Menu):
cms_enabled = True
name = None

def __init__(self, *args, **kwargs):
super(CMSAttachMenu, self).__init__(*args, **kwargs)
if self.cms_enabled and not self.name:
Expand Down

0 comments on commit 379e120

Please sign in to comment.