Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bunch of debugs: views/tags.py, new slugify function, xmlrpc compatibility #531

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ django-apps-src
docs/build
demo/demo.db*
django_blog_zinnia.egg-info/
build
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
'pillow>=2.0.0',
'pyparsing>=2.0.3',
'pytz>=2014.10',
'regex>=2016.3.2']
'regex>=2016.3.2',
'python-slugify',] # compatible with non ASCII charaters
)
2 changes: 1 addition & 1 deletion zinnia/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.contrib.syndication.views import Feed
from django.core.exceptions import ObjectDoesNotExist
from django.shortcuts import get_object_or_404
from django.template.defaultfilters import slugify
from slugify import slugify
from django.urls import NoReverseMatch
from django.urls import reverse
from django.utils.encoding import smart_text
Expand Down
2 changes: 1 addition & 1 deletion zinnia/models_bases/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.contrib.sites.models import Site
from django.db import models
from django.db.models import Q
from django.template.defaultfilters import slugify
from slugify import slugify
from django.urls import reverse
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible
Expand Down
2 changes: 1 addition & 1 deletion zinnia/templating.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Templates module for Zinnia"""
import os

from django.template.defaultfilters import slugify
from slugify import slugify


def append_position(path, position, separator=''):
Expand Down
2 changes: 1 addition & 1 deletion zinnia/views/comments.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Views for Zinnia comments"""
from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpResponsePermanentRedirect
from django.template.defaultfilters import slugify
from slugify import slugify
from django.views.generic.base import TemplateResponseMixin
from django.views.generic.base import View

Expand Down
2 changes: 1 addition & 1 deletion zinnia/views/quick_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.contrib.auth.decorators import permission_required
from django.contrib.sites.models import Site
from django.shortcuts import redirect
from django.template.defaultfilters import slugify
from slugify import slugify
from django.urls import reverse
from django.utils import timezone
from django.utils.decorators import method_decorator
Expand Down
4 changes: 2 additions & 2 deletions zinnia/views/tags.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Views for Zinnia tags"""
from django.http import Http404
from django.template.defaultfilters import slugify
from slugify import slugify
from django.utils.translation import ugettext as _
from django.views.generic.list import BaseListView
from django.views.generic.list import ListView
Expand Down Expand Up @@ -80,4 +80,4 @@ def get_model_name(self):
"""
The model name is the tag slugified.
"""
return slugify(self.tag)
return slugify(self.tag.name)
6 changes: 5 additions & 1 deletion zinnia/xmlrpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
'wp.getAuthors'),
('zinnia.xmlrpc.metaweblog.get_tags',
'wp.getTags'),
('zinnia.xmlrpc.metaweblog.get_categories',
'wp.getCategories'),
('zinnia.xmlrpc.metaweblog.get_categories',
'metaWeblog.getCategories'),
('zinnia.xmlrpc.metaweblog.new_category',
'wp.newCategory'),
'wp.newCategory'),
('zinnia.xmlrpc.metaweblog.set_categories',
'mt.setPostCategories'),
('zinnia.xmlrpc.metaweblog.get_recent_posts',
'metaWeblog.getRecentPosts'),
('zinnia.xmlrpc.metaweblog.get_post',
Expand Down
28 changes: 23 additions & 5 deletions zinnia/xmlrpc/metaweblog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.contrib.sites.models import Site
from django.core.files.base import ContentFile
from django.core.files.storage import default_storage
from django.template.defaultfilters import slugify
from slugify import slugify # compatible with non-ASCII characters
from django.urls import reverse
from django.utils import six
from django.utils import timezone
Expand Down Expand Up @@ -204,7 +204,7 @@ def delete_post(apikey, post_id, username, password, publish):
entry.delete()
return True


@xmlrpc_func(returns='struct', args=['string', 'string', 'string'])
def get_post(post_id, username, password):
"""
Expand Down Expand Up @@ -261,16 +261,34 @@ def new_category(blog_id, username, password, category_struct):
=> category_id
"""
authenticate(username, password, 'zinnia.add_category')
category_dict = {'title': category_struct['name'],
'description': category_struct['description'],
'slug': category_struct['slug']}
category_dict = {
'title': category_struct['name'],
'slug': slugify(category_struct['name']),
}
if category_struct.has_key('description'):
if category_struct['description']:
category_dict['description'] = category_struct['description']
if category_struct.has_key('slug'):
if category_struct['slug']:
category_dict['slug'] = category_struct['slug']
if int(category_struct['parent_id']):
category_dict['parent'] = Category.objects.get(
pk=category_struct['parent_id'])
category = Category.objects.create(**category_dict)

return category.pk


@xmlrpc_func(returns='boolean', args=['string', 'string', 'string', 'struct'])
def set_categories(postid, username, password, categories):
"""
mt.setPostCategories(postid, username, password, categories)
=> boolean
"""
# This is useless 'cause category already set by new_post().
# Just for the compatability with open live writer
return True


@xmlrpc_func(returns='string', args=['string', 'string', 'string',
'struct', 'boolean'])
Expand Down