cms.contrib.keywords package

Submodules

cms.contrib.keywords.admin module

class cms.contrib.keywords.admin.KeywordAdmin(model, admin_site)

Bases: cms.contrib.admin.admin.CMSAdmin, cms.core.translations.admin.TranslationAdmin

fieldsets = ((<django.utils.functional.__proxy__ object at 0x557ef10>, {'fields': ['title', 'slug']}),)
get_created_date(obj)
get_title(obj)
list_display = ('get_created_date', 'get_title')
list_exclude = ('get_changelist_meta',)
media
prepopulated_fields = {'slug': ('title',)}
class cms.contrib.keywords.admin.KeywordableAdmin(model, admin_site)

Bases: django.contrib.admin.options.ModelAdmin

Admin class for models that subclass the abstract Keyword model.

formfield_for_dbfield(db_field, **kwargs)

Set content_type for KeywordsWidget.

media

cms.contrib.keywords.cms_initialize module

class cms.contrib.keywords.cms_initialize.CMSInitialize

Bases: cms.core.models.CMSInitializeBase

models = (<class 'cms.contrib.keywords.models.Keyword'>,)
now_fields = ('created_date', 'modified_date')

cms.contrib.keywords.cms_plugin module

class cms.contrib.keywords.cms_plugin.CMSPlugin

Bases: cms.core.plugins.CMSPluginBase

admin_icon_class = 'icon-tags'
description = <django.utils.functional.__proxy__ object at 0x31ffd10>
status = 'stable'
verbose_name = <django.utils.functional.__proxy__ object at 0x31ffd50>
version = '0.3'

cms.contrib.keywords.fields module

class cms.contrib.keywords.fields.KeywordsField(*args, **kwargs)

Bases: cms.core.fields.BaseGenericRelation

Stores the keywords as a single string into the KEYWORDS_FIELD_NAME_string field for convenient access when searching.

fields = {'%s_string': <django.db.models.fields.CharField>}
formfield(**kwargs)

Provide the custom form widget for the admin, since there isn’t a form field mapped to GenericRelation model fields.

save_form_data(instance, data)

The KeywordsWidget field will return data as a string of comma separated IDs for the Keyword model - convert these into actual AssignedKeyword instances. Also delete Keyword instances if their last related AssignedKeyword instance is being removed.

cms.contrib.keywords.management module

cms.contrib.keywords.management.create_group(sender, **kwargs)

cms.contrib.keywords.managers module

class cms.contrib.keywords.managers.KeywordManager

Bases: django.db.models.manager.Manager

delete_unused(keyword_ids=None)

Removes all instances that are not assigned to any object. Limits processing to keyword_ids if given.

get_by_natural_key(value)

Provides natural key method.

get_or_create_iexact(**kwargs)

Case insensitive title version of get_or_create. Also allows for multiple existing results.

cms.contrib.keywords.models module

class cms.contrib.keywords.models.AssignedKeyword(*args, **kwargs)

Bases: cms.core.models.Orderable

A Keyword assigned to a model instance.

class ApiPrivate
fields = ('keyword', 'content_type', 'object_pk')
exception AssignedKeyword.DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception AssignedKeyword.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

AssignedKeyword.content_object

Provides a generic relation to any object through content-type/object-id fields.

AssignedKeyword.content_type
AssignedKeyword.keyword
AssignedKeyword.objects = <django.db.models.manager.Manager object at 0x4104c10>
AssignedKeyword.order_with_respect_to = 'content_object'
class cms.contrib.keywords.models.Keyword(*args, **kwargs)

Bases: cms.core.models.BaseData, cms.core.models.Slugged

Keywords/tags which are managed via a custom Javascript based widget in the admin.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Keyword.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class Keyword.Settings
Keyword.assignments
Keyword.clean_fields(exclude=None)
Keyword.created_by
Keyword.get_next_by_created_date(*moreargs, **morekwargs)
Keyword.get_next_by_modified_date(*moreargs, **morekwargs)
Keyword.get_previous_by_created_date(*moreargs, **morekwargs)
Keyword.get_previous_by_modified_date(*moreargs, **morekwargs)
Keyword.modified_by
Keyword.objects = <cms.core.translations.translator.NewMultilingualManager object at 0x4101fd0>
Keyword.slug

A descriptor used for the original translated field.

Keyword.title

A descriptor used for the original translated field.

cms.contrib.keywords.urls module

cms.contrib.keywords.views module

class cms.contrib.keywords.views.KeywordsAdminSubmitView(**kwargs)

Bases: django.views.generic.base.View

post(*args, **kwargs)

Adds any new given keywords from the custom keywords field in the admin, and returns their IDs for use when saving a model with a keywords field.

cms.contrib.keywords.widgets module

class cms.contrib.keywords.widgets.KeywordsWidget(attrs=None, xxx=None)

Bases: django.forms.widgets.MultiWidget

Form field for the KeywordsField generic relation field. Since the admin with model forms has no form field for generic relations, this form field provides a single field for managing the keywords. It contains two actual widgets, a text input for entering keywords, and a hidden input that stores the ID of each Keyword instance.

The attached JavaScript adds behaviour so that when the form is submitted, an AJAX post is made that passes the list of keywords in the text input, and returns a list of keyword IDs which are then entered into the hidden input before the form submits. The list of IDs in the hidden input is what is used when retrieving an actual value from the field for the form.

class Media
css = {'all': ['//127.0.0.1:8080/static/cms/css/admin/contrib.keywords.keyword.css']}
css_all = ('contrib.keywords.keyword.css',)
extra = ''
js = ['//127.0.0.1:8080/static/cms/js/admin/contrib.keywords.keyword.js']
url = 'contrib.keywords.keyword.js'
KeywordsWidget.decompress(value)

Takes the sequence of AssignedKeyword instances and splits them into lists of keyword IDs and titles each mapping to one of the form field widgets.

KeywordsWidget.format_output(rendered_widgets)

Wraps the output HTML with a list of all available Keyword instances that can be clicked on to toggle a keyword.

Apply only to the querset, because in admin we want only the title.

KeywordsWidget.media
KeywordsWidget.value_from_datadict(data, files, name)

Return the comma separated list of keyword IDs for use in KeywordsField.save_form_data().

Module contents