Exemplo n.º 1
0
class EntrySaveTest(TestCase):
    def setUp(self):
        self.user = User(username='******',password='******')
        self.user.save()
        self.blog = Blog(
            title = "Test Blog",
            slug = "test-blog",
            description = "Testing is cool",
        )
        self.blog.save()
        self.category = Category(
                title = "Test Category",
                slug = "test-category",
                blog = self.blog
        )
        self.category.save()
        self.entry = Entry(
                category = self.category,
                blog = self.blog,
                slug = "test-entry",
                title = "test entry",
                author = self.user,
                body = 'code goes like this:\n\n'
                    '    #!python \n'
                    '    from django import http \n'
                )
        self.target_body = u'<p>code goes like this:</p>\n<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="codehilite"><pre><span class="kn">from</span> <span class="nn">django</span> <span class="kn">import</span> <span class="n">http</span>\n</pre></div>\n</td></tr></table>'
        self.entry.save()

    def test_that_markdown_works(self):
        self.failUnlessEqual(self.entry.body_html, self.target_body)
Exemplo n.º 2
0
def show_entry(request, entry_slug, blog_slug=None):
    blog = Blog.get_blog(blog_slug)
    entry = get_object_or_404(Entry, slug=entry_slug)
    route = curry(route_template, extraname=entry.slug, blog_slug=blog.slug)
    context = RequestContext(request, {
        'blog': blog,
        'entry': entry,
        'multiblog': multiblog_enabled,
    })

    context['base_template'] = select_template( route('base') )
    return render_to_response( route('entry_details'), {}, context )
Exemplo n.º 3
0
def list_entries( request, blog_slug=None, page_num=1 ):
    ''' renders requested page, a list of date-ordred entries '''
    blog = Blog.get_blog(blog_slug)
    pages = LaidbackPaginator(blog.get_entries(), blog.page_length)

    # curry it up to save typing!
    route = curry(route_template, blog_slug=blog.slug)

    context = RequestContext(request, { 
        'blog': blog,
        'page': pages.page(page_num),
        'multiblog': multiblog_enabled,
    })

    context['base_template'] = select_template( route('base') )
    return render_to_response( route('entry_list'), {}, context )
Exemplo n.º 4
0
def show_category(request, blog_slug=None, category_slug=None, page_num=1):
    ''' lists entries under category specified by category_slug '''
    blog = Blog.get_blog(blog_slug)
    category = get_object_or_404(Category, blog=blog, slug=category_slug)
    entries = Entry.live.filter( category=category )
    pages = LaidbackPaginator(entries, blog.page_length)
    route = curry(route_template,extraname=category.slug,blog_slug=blog.slug)
    context = RequestContext(request, {
        'blog': blog,
        'category': category,
        'page': pages.page(page_num),
        'multiblog': multiblog_enabled,
    }) 

    context['base_template'] = select_template( route('base') )
    return render_to_response( route('category_details'), {}, context )
Exemplo n.º 5
0
 def get_object(self, request, blog_slug=None, category_slug=None):
     blog = Blog.get_blog(blog_slug)
     return get_object_or_404(Category, blog=blog, slug=category_slug)
Exemplo n.º 6
0
 def get_object(self, request, blog_slug=None):
     return Blog.get_blog(blog_slug)