Skip to content

Commit

Permalink
Add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Feb 12, 2016
1 parent 0945253 commit 34039be
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
21 changes: 18 additions & 3 deletions djangocms_blog/admin.py
Expand Up @@ -77,6 +77,9 @@ class PostAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin,
}

def get_urls(self):
"""
Customize the modeladmin urls
"""
urls = [
url(r'^publish/([0-9]+)/$', self.admin_site.admin_view(self.publish_post),
name='djangocms_blog_publish_article'),
Expand All @@ -85,6 +88,12 @@ def get_urls(self):
return urls

def publish_post(self, request, pk):
"""
Admin view to publish a single post
:param request: request
:param pk: primary key of the post to publish
:return: Redirect to the post itself (if found) or fallback urls
"""
language = get_language_from_request(request, check_path=True)
try:
post = Post.objects.get(pk=int(pk))
Expand All @@ -97,9 +106,6 @@ def publish_post(self, request, pk):
except KeyError:
return HttpResponseRedirect(reverse('djangocms_blog:posts-latest'))

def languages(self, obj):
return ','.join(obj.get_available_languages())

def formfield_for_dbfield(self, db_field, **kwargs):
field = super(PostAdmin, self).formfield_for_dbfield(db_field, **kwargs)
if db_field.name == 'meta_description':
Expand All @@ -111,6 +117,12 @@ def formfield_for_dbfield(self, db_field, **kwargs):
return field

def get_fieldsets(self, request, obj=None):
"""
Customize the fieldsets according to the app settings
:param request: request
:param obj: post
:return: fieldsets configuration
"""
app_config_default = self._app_config_select(request, obj)
if app_config_default is None and request.method == 'GET':
return super(PostAdmin, self).get_fieldsets(request, obj)
Expand Down Expand Up @@ -156,6 +168,9 @@ class BlogConfigAdmin(BaseAppHookConfig, TranslatableAdmin):

@property
def declared_fieldsets(self):
"""
Fieldsets configuration
"""
return [
(None, {
'fields': ('type', 'namespace', 'app_title', 'object_name')
Expand Down
3 changes: 3 additions & 0 deletions djangocms_blog/cms_toolbar.py
Expand Up @@ -35,6 +35,9 @@ def populate(self):
active=True)

def add_publish_button(self):
"""
Adds the publish button to the toolbar if the current post is unpublished
"""
current_post = getattr(self.request, get_setting('CURRENT_POST_IDENTIFIER'), None)
if (self.toolbar.edit_mode and current_post and
not current_post.publish and
Expand Down

0 comments on commit 34039be

Please sign in to comment.