Do things in a more python way
This commit is contained in:
@@ -17,22 +17,11 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Dynastie. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
import os
|
||||
from xml.dom.minidom import parse, parseString
|
||||
from dynastie.generators.generator import DynastieGenerator
|
||||
from dynastie.generators.index import Index
|
||||
from django.db import models
|
||||
|
||||
class Category(Index):
|
||||
|
||||
cur_page = 0
|
||||
nb_pages = 0
|
||||
cur_post = 0
|
||||
posts_per_page = 0
|
||||
filename = 'index'
|
||||
dirname = ''
|
||||
cur_category = None
|
||||
|
||||
def createCategory(self, posts, dom, root, node):
|
||||
if node.hasAttribute('name'):
|
||||
self.replaceByText(dom, root, node, self.cur_category.name)
|
||||
@@ -43,6 +32,8 @@ class Category(Index):
|
||||
def generate(self, blog, src, output):
|
||||
from dynastie.models import Post, Blog, Category
|
||||
|
||||
self.cur_category = None
|
||||
|
||||
self.hooks['category'] = self.createCategory
|
||||
|
||||
dom = self.parseTemplate(blog, src, output, 'category', 'category')
|
||||
@@ -54,9 +45,7 @@ class Category(Index):
|
||||
self.cur_category = category
|
||||
posts = Post.objects.filter(category__exact=category, published=True).order_by('-creation_date')
|
||||
|
||||
self.nb_pages = 0
|
||||
self.cur_page = 0
|
||||
self.cur_post = 0
|
||||
self.resetCounters()
|
||||
|
||||
self.dirname = '/category/' + category.name_slug
|
||||
|
||||
|
||||
Reference in New Issue
Block a user