Exemplo n.º 1
0
def comment_list(request, entry=0):
    
    if entry > 0:
        try:
            ent = models.Entry.objects.get(id=entry)
        except models.Entry.DoesNotExist:
            raise Http404
    else:
        ent = None
    
    try:
        clist = Comment.objects.filter(content_type__model='entry').filter(is_public=True).filter(is_removed=False)
    except Comment.DoesNotExist:
        clist = None
        
    pdate = None
    if clist != None:
        clist = clist.order_by('-submit_date')
        try:
            pdate = clist[0].submit_date
        except IndexError:
            pdate = None
    
    ctx = {
        'pubdate': pdate,
        'entry': ent,
        'host': request.get_host(),
        'secure': request.is_secure(),
    }
    
    return response.render(request, 'blog/feeds/rss_comments.html', ctx, mimetype="application/rss+xml")
Exemplo n.º 2
0
def comment_list(request, entry=0):

    if entry > 0:
        try:
            ent = models.Entry.objects.get(id=entry)
        except models.Entry.DoesNotExist:
            raise Http404
    else:
        ent = None

    try:
        clist = Comment.objects.filter(content_type__model='entry').filter(
            is_public=True).filter(is_removed=False)
    except Comment.DoesNotExist:
        clist = None

    pdate = None
    if clist != None:
        clist = clist.order_by('-submit_date')
        try:
            pdate = clist[0].submit_date
        except IndexError:
            pdate = None

    ctx = {
        'pubdate': pdate,
        'entry': ent,
        'host': request.get_host(),
        'secure': request.is_secure(),
    }

    return response.render(request,
                           'blog/feeds/rss_comments.html',
                           ctx,
                           mimetype="application/rss+xml")
Exemplo n.º 3
0
def feed_list(request, year=0, month=0, day=0, author='', tagslug=''):

    entries = get_entry_list(int(year), int(month), int(day), author, '',
                             tagslug)

    if entries.count() >= settings.ENTRIES_PER_FEED:
        entries = entries[:settings.ENTRIES_PER_FEED]

    if entries:
        pdate = entries[0].publish_date
    else:
        pdate = None

    # If month and day have not been set, assign 1 (so they don't block the date() function)
    if (year != 0 and month == 0 and day == 0):
        month = 1
        day = 1
        dtype = 'Y'
    elif (year != 0 and month != 0 and day == 0):
        day = 1
        dtype = 'F Y'
    else:
        dtype = None

    try:
        date = datetime(int(year), int(month), int(day))
    except ValueError:
        date = None

    try:
        tag = models.Tag.objects.get(slug__iexact=tagslug)
    except models.Tag.DoesNotExist:
        tag = None

    try:
        authorUser = User.objects.get(username__iexact=author)
    except User.DoesNotExist:
        authorUser = None

    ctx = {
        'entries': entries,
        'pubdate': pdate,
        'host': request.get_host(),
        'secure': request.is_secure(),
        'filter': {
            'author': authorUser,
            'date': {
                'type': dtype,
                'value': date
            },
            'tag': tag,
        }
    }

    return response.render(request,
                           'blog/feeds/rss_entries.html',
                           ctx,
                           mimetype="application/rss+xml")
Exemplo n.º 4
0
def entry_detail(request, year, month, day, slug):
    entry = get_entry_list(int(year), int(month), int(day), '', slug)
    if entry:
        ctx = {
            'entry': entry[0]
        }
        return response.render(request, 'blog/entry_detail.html', ctx)
    else:
        raise Http404
Exemplo n.º 5
0
def show(request, page_name):
    pg = get_page(page_name, request.LANGUAGE_CODE)
    if (pg):
        ctx = {
            'language': pg.language,
            'title': pg.title_html,
            'heading': pg.heading_html,
            'content': pg.content_html,
        }
        return response.render(request, 'page/show.html', ctx)
    else:
        raise Http404
Exemplo n.º 6
0
def show(request, page_name):
    pg = get_page(page_name, request.LANGUAGE_CODE)
    if (pg):
        ctx = {
            'language': pg.language,
            'title': pg.title_html,
            'heading': pg.heading_html,
            'content': pg.content_html,
        }
        return response.render(request, 'page/show.html', ctx)
    else:
        raise Http404
Exemplo n.º 7
0
def feed_list(request, year=0, month=0, day=0, author='', tagslug=''):
    
    entries = get_entry_list(int(year), int(month), int(day), author, '', tagslug)
    
    if entries.count() >= settings.ENTRIES_PER_FEED:
        entries = entries[:settings.ENTRIES_PER_FEED]
    
    if entries:
        pdate = entries[0].publish_date
    else:
        pdate = None
    
    # If month and day have not been set, assign 1 (so they don't block the date() function)
    if (year != 0 and month == 0 and day == 0):
        month = 1
        day = 1
        dtype = 'Y'
    elif (year != 0 and month != 0 and day == 0):
        day = 1
        dtype = 'F Y'
    else:
        dtype = None
    
    try:
        date = datetime(int(year), int(month), int(day))
    except ValueError:
        date = None
        
    try:
        tag = models.Tag.objects.get(slug__iexact=tagslug)
    except models.Tag.DoesNotExist:
        tag = None
        
    try:
        authorUser = User.objects.get(username__iexact=author)
    except User.DoesNotExist:
        authorUser = None
        
    ctx = {
        'entries': entries,
        'pubdate': pdate,
        'host': request.get_host(),
        'secure': request.is_secure(),
        'filter': {
            'author': authorUser,
            'date': {'type': dtype, 'value': date},
            'tag': tag,
        }
    }
    
    return response.render(request, 'blog/feeds/rss_entries.html', ctx, mimetype="application/rss+xml")
Exemplo n.º 8
0
def entry_list(request, year=0, month=0, day=0, author='', tagslug='', page=1):
    
    # Fetch and paginate the entry list
    entry_list = get_entry_list(int(year), int(month), int(day), author, '', tagslug)
    paginator = Paginator(entry_list, settings.ENTRIES_PER_PAGE)
    
    try:
        entries = paginator.page(page)
    except (EmptyPage, InvalidPage):
        entries = paginator.page(paginator.num_pages)
    
    # If month and day have not been set, assign 1 (so they don't block the date() function)
    if (year != 0 and month == 0 and day == 0):
        month = 1
        day = 1
        dtype = 'Y'
    elif (year != 0 and month != 0 and day == 0):
        day = 1
        dtype = 'F Y'
    else:
        dtype = None
    
    try:
        date = datetime(int(year), int(month), int(day))
    except ValueError:
        date = None
        
    try:
        tag = models.Tag.objects.get(slug__iexact=tagslug)
    except models.Tag.DoesNotExist:
        tag = None
        
    try:
        authorUser = User.objects.get(username__iexact=author)
    except User.DoesNotExist:
        authorUser = None
        
    ctx = {
        'entries': entries,
        'filter': {
            'author': authorUser,
            'date': {'type': dtype, 'value': date},
            'tag': tag,
        }
    }
    
    return response.render(request, 'blog/entry_list.html', ctx)