Ejemplo n.º 1
0
def page_turning(list_obj, request, count=10):
    '''翻页函数'''

    page = int(request.GET.get("p",1))
    matchs = get_entry_page(list_obj, count, page)
    show_pages = range(max(page-4,1),min(page+4,matchs.paginator.num_pages)+1)
    return (matchs, show_pages)
Ejemplo n.º 2
0
def page_turning(list_obj, request, count=10):
    '''翻页函数'''

    page = int(request.GET.get("p", 1))
    matchs = get_entry_page(list_obj, count, page)
    show_pages = range(max(page - 4, 1),
                       min(page + 4, matchs.paginator.num_pages) + 1)
    return (matchs, show_pages)
Ejemplo n.º 3
0
def reply(request):
    '''关注回复,无匹配回复,关键字编辑'''
    appitem = get_appitem(request.user)
    tag = request.GET.get('tag')
    keyword = request.GET.get('keyword') #没有值时是:关注回复,无匹配回复
    mid = request.GET.get('mid') #没有值时是:关注回复,无匹配回复
    add = request.GET.get('add') #新增关键字符号
    news_show = None
    if tag in ['keyword_default_recontent', 'subscribe']:
        message = appitem.messages.filter(tag=tag).first()
    elif mid:
        message = appitem.messages.filter(tag=tag, id=mid).first()
    elif not mid and tag == 'keyword_recontent' and add =='add':
        message = appitem.messages.create(tag='keyword_recontent')

    if message.tag == 'keyword_recontent' and not message.keyword and keyword:
        message.keyword = keyword
        message.save()
    choid = request.GET.get('choid') # '2.3-1.5-articleid.order'
    listchoid = request.GET.get('listchoid') # '[articleid.order][12]' 点击选中素材后提交

    news_articles = None
    order_dic = None
    if listchoid:
        news_articles = appitem.articles.filter(id__in=parse_listchoid(listchoid))
        news_show = request.GET.get('news_show', 'show')
    elif message.retype == 'news':
        news = message.news_set.first()
        if news.order_dic:
            order_dic = json.loads(news.order_dic)   
        news_articles = news.articles.all()
    
    field_list = ['keyword', 'tag', 'listchoid', 'news_show', 'closeshow', 'mid', 'add']
    close_show_field = ['closeshow','listchoid']
    get_data_url = convert_get_data(request.GET, field_list)
    articles = appitem.articles.all()

    page = int(request.GET.get("p",1))
    return_articles = get_entry_page(articles,10,page)
    show_pages = range(max(page-4,1),min(page+4,return_articles.paginator.num_pages)+1)

    context = {
        'message': message,
        'tag': tag,
        'news_show': news_show,
        'get_data': request.GET,
        'news_articles': news_articles,
        'order_dic': order_dic,
        'articles': articles,
        'get_data_url': get_data_url,
        'close_show_field': close_show_field,
        'show_pages': show_pages,
        'return_articles': return_articles,
        'articles': articles,
    }
    return render_to_response('yimi_admin/default_recontent.html', context,
        context_instance=RequestContext(request))
Ejemplo n.º 4
0
def reply(request):
    '''关注回复,无匹配回复,关键字编辑'''
    appitem = get_appitem(request.user)
    tag = request.GET.get('tag')
    keyword = request.GET.get('keyword')  #没有值时是:关注回复,无匹配回复
    mid = request.GET.get('mid')  #没有值时是:关注回复,无匹配回复
    add = request.GET.get('add')  #新增关键字符号
    news_show = None
    if tag in ['keyword_default_recontent', 'subscribe']:
        message = appitem.messages.filter(tag=tag).first()
    elif mid:
        message = appitem.messages.filter(tag=tag, id=mid).first()
    elif not mid and tag == 'keyword_recontent' and add == 'add':
        message = appitem.messages.create(tag='keyword_recontent')

    if message.tag == 'keyword_recontent' and not message.keyword and keyword:
        message.keyword = keyword
        message.save()
    choid = request.GET.get('choid')  # '2.3-1.5-articleid.order'
    listchoid = request.GET.get(
        'listchoid')  # '[articleid.order][12]' 点击选中素材后提交

    news_articles = None
    order_dic = None
    if listchoid:
        news_articles = appitem.articles.filter(
            id__in=parse_listchoid(listchoid))
        news_show = request.GET.get('news_show', 'show')
    elif message.retype == 'news':
        news = message.news_set.first()
        if news.order_dic:
            order_dic = json.loads(news.order_dic)
        news_articles = news.articles.all()

    field_list = [
        'keyword', 'tag', 'listchoid', 'news_show', 'closeshow', 'mid', 'add'
    ]
    close_show_field = ['closeshow', 'listchoid']
    get_data_url = convert_get_data(request.GET, field_list)
    articles = appitem.articles.all()

    page = int(request.GET.get("p", 1))
    return_articles = get_entry_page(articles, 10, page)
    show_pages = range(max(page - 4, 1),
                       min(page + 4, return_articles.paginator.num_pages) + 1)

    context = {
        'message': message,
        'tag': tag,
        'news_show': news_show,
        'get_data': request.GET,
        'news_articles': news_articles,
        'order_dic': order_dic,
        'articles': articles,
        'get_data_url': get_data_url,
        'close_show_field': close_show_field,
        'show_pages': show_pages,
        'return_articles': return_articles,
        'articles': articles,
    }
    return render_to_response('yimi_admin/default_recontent.html',
                              context,
                              context_instance=RequestContext(request))