Пример #1
0
def user_tag_detail(request,
                    user_id,
                    tag_name,
                    template="web/user/tag_detail.html"):
    _hash = md5(tag_name.encode('utf-8')).hexdigest()
    _page = request.GET.get('page', 1)

    inner_qs = Content_Tags.objects.filter(
        tag__hash=_hash, creator_id=user_id,
        target_content_type_id=24).values_list('target_object_id', flat=True)

    _eid_list = Note.objects.filter(pk__in=inner_qs).values_list('entity_id',
                                                                 flat=True)
    _entity_list = Entity.objects.filter(pk__in=list(_eid_list))

    paginator = ExtentPaginator(_entity_list, 24)

    try:
        _entities = paginator.page(_page)
    except PageNotAnInteger:
        _entities = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(
        template,
        {
            'tag': tag_name,
            'entities': _entities,
        },
        context_instance=RequestContext(request),
    )
Пример #2
0
    def get(self, request, **kwargs):
        self._brand = self.kwargs.get('brand')
        self._brand_id = self.kwargs.get('brand_id')
        assert self._brand is not None
        _entity_list = self.get_queryset(brand_name=self.brand)
        page = request.GET.get('page', 1)

        paginator = ExtentPaginator(_entity_list, 30)

        try:
            _entities = paginator.page(page)
        except InvalidPage:
            _entities = paginator.page(1)
        except EmptyPage:
            raise Http404

        # for entity in _entities:
        #     try:
        #         entity_brand = Entity_Brand.objects.get(entity_id=entity.entity_id)
        #         if entity_brand.brand_id == int(self._brand_id):
        #             entity.is_belong = True
        #     except:
        #         pass

        context = {
            'brand': self.brand,
            'entities': _entities,
            'brand_id':self._brand_id,
        }
        return self.render_to_response(context)
Пример #3
0
def sub_category_list(request,
                      cid,
                      template="management/category/sub_category_list.html"):

    _page = request.GET.get('page', 1)
    try:
        category = Category.objects.get(pk=cid)
    except Category.DoesNotExist:
        raise Http404

    sub_categories = Sub_Category.objects.filter(group_id=cid).order_by('-id')

    paginator = ExtentPaginator(sub_categories, 30)

    try:
        category_list = paginator.page(_page)
    except PageNotAnInteger:
        category_list = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(template, {
        'category': category,
        'category_list': category_list,
    },
                              context_instance=RequestContext(request))
Пример #4
0
def entity_note(request, category_id):

    _offset = int(request.GET.get('offset', '0'))
    _count = int(request.GET.get('count', '30'))

    _offset = _offset / _count + 1

    res = []

    note_list = Note.objects.filter(entity__category_id=category_id)

    paginator = ExtentPaginator(note_list, _count)

    try:
        notes = paginator.page(_offset)
    except PageNotAnInteger:
        notes = paginator.page(1)
    except EmptyPage:
        return ErrorJsonResponse(status=404)

    for n in notes.object_list:
        # log.info(n)
        res.append({
            'note': n.v3_toDict(),
            'entity': n.entity.v3_toDict(),
        })

    return SuccessJsonResponse(res)
Пример #5
0
def pending(request, template="management/selection/list.html"):
    _page = request.GET.get('page', 1)
    s = Selection_Entity.objects.pending()
    # log.info(s.query)
    paginator = ExtentPaginator(s, 30)

    try:
        selections = paginator.page(_page)
    except PageNotAnInteger:
        selections = paginator.page(1)
    except EmptyPage:
        raise Http404

    # _entities = Entity.objects.filter(id__in=list(selections.object_list))

    return render_to_response(
        template,
        {
            'selections':
            selections,
            'pending_count':
            Selection_Entity.objects.pending().count(),
            'pending_and_removed_count':
            Selection_Entity.objects.pending_and_removed().count()
            # 'entities': _entities,
        },
        context_instance=RequestContext(request))
Пример #6
0
def entity(request, category_id):

    _offset = int(request.GET.get('offset', '0'))
    _offset = _offset / 30 + 1
    _count = int(request.GET.get('count', '30'))
    _key = request.GET.get('session')

    # entity_list = Entity.objects.filter(category_id=category_id, status__gte=0)
    entity_list = Entity.objects.new_or_selection(category_id=category_id)
    paginator = ExtentPaginator(entity_list, _count)

    try:
        entities = paginator.page(_offset)
    except PageNotAnInteger:
        entities = paginator.page(1)
    except EmptyPage:
        return ErrorJsonResponse(status=404)

    try:
        _session = Session_Key.objects.get(session_key=_key)

        el = Entity_Like.objects.user_like_list(
            user=_session.user,
            entity_list=list(entities.object_list.values_list('id',
                                                              flat=True)))
    except Session_Key.DoesNotExist:
        el = None

    res = []
    for row in entities.object_list:
        r = row.v3_toDict(user_like_list=el)
        r.pop('images', None)
        r.pop('id', None)
        res.append(r)
    return SuccessJsonResponse(res)
Пример #7
0
def sub_category_entity_list(
        request,
        scid,
        templates='management/category/entity/sub_category_entity_list.html'):
    page = request.GET.get('page', 1)
    status = request.GET.get('status', None)

    _sub_category = get_object_or_404(Sub_Category, pk=scid)

    if status is None:
        entities = Entity.objects.filter(category=_sub_category)
    else:
        entities = Entity.objects.filter(category=_sub_category,
                                         status=int(status))

    paginator = ExtentPaginator(entities, 30)
    try:
        _entity_list = paginator.page(page)
    except PageNotAnInteger:
        _entity_list = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(templates, {
        'entities': _entity_list,
        'category': _sub_category,
        'status': status,
    },
                              context_instance=RequestContext(request))
Пример #8
0
def list(request, template='management/notes/list.html'):

    status = request.GET.get('status', None)
    page = request.GET.get('page', 1)

    if status is None:
        note_list = Note.objects.all().order_by("-post_time")
    else:
        note_list = Note.objects.filter(
            status=int(status)).order_by("-post_time")

    paginator = ExtentPaginator(note_list, 30)

    try:
        notes = paginator.page(page)
    except InvalidPage:
        notes = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(template, {
        'notes': notes,
        'status': status,
    },
                              context_instance=RequestContext(request))
Пример #9
0
def notes(request, user_id, template='management/users/notes.html'):

    page = request.GET.get('page', 1)
    _status = request.GET.get('status', None)

    try:
        _user = GKUser.objects.get(pk=user_id)
    except GKUser.DoesNotExist:
        raise Http404

    if _status:
        _note_list = _user.note.filter(status=_status)
    else:
        _note_list = _user.note.all()

    paginator = ExtentPaginator(_note_list, 30)
    try:
        _notes = paginator.page(page)
    except InvalidPage:
        _notes = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(template, {
        'user': _user,
        'notes': _notes,
        'status': _status
    },
                              context_instance=RequestContext(request))
Пример #10
0
def user_like(request, category_id, user_id):

    _key = request.GET.get('session')
    _offset = int(request.GET.get('offset', '0'))
    _count = int(request.GET.get('count', '30'))

    _offset = _offset / _count + 1

    innqs = Entity_Like.objects.filter(user_id=user_id).values_list(
        'entity_id', flat=True)

    entity_list = Entity.objects.filter(category_id=category_id, id__in=innqs)

    paginator = ExtentPaginator(entity_list, _count)

    try:
        entities = paginator.page(_offset)
    except PageNotAnInteger:
        entities = paginator.page(1)
    except EmptyPage:
        return ErrorJsonResponse(status=404)

    res = []
    for entity in entities:
        res.append(entity.v3_toDict(user_like_list=[entity.id]))

    return SuccessJsonResponse(res)
Пример #11
0
def post(request, user_id, template='management/users/post.html'):

    status = request.GET.get('status', None)
    page = request.GET.get('page', 1)

    try:
        _user = GKUser.objects.get(pk=user_id)
    except GKUser.DoesNotExist:
        raise Http404

    _entity_list = _user.entities.all()

    paginator = ExtentPaginator(_entity_list, 30)

    try:
        _entities = paginator.page(page)
    except InvalidPage:
        _entities = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(template, {
        'user': _user,
        'entities': _entities,
        'status': status,
    },
                              context_instance=RequestContext(request))
Пример #12
0
def messages(request, template='notifications/messages/message.html'):
    _user = request.user
    _page = request.GET.get('page', 1)
    _timestamp = request.GET.get('timestamp',None)
    if _timestamp != None:
        _timestamp = datetime.fromtimestamp(float(_timestamp))
    else:
        _timestamp = datetime.now()

    el = Entity_Like.objects.popular()
    cids = Entity.objects.filter(pk__in=list(el)).annotate(dcount=Count('category')).values_list('category_id', flat=True)

    _categories = Sub_Category.objects.filter(id__in=list(cids), status=True)
    # too expensive ???

    # remove_user_list = GKUser.objects.deactive_user_list()
    # remove_user_list.append(_user.id)
    # remove_user_list = list(remove_user_list)
    remove_user_list = []
    remove_user_list.append(_user.id)
    message_list = _user.notifications.filter(timestamp__lt=_timestamp).exclude(actor_object_id__in=remove_user_list)

    paginator = ExtentPaginator(message_list, 5)

    try:
        _messages = paginator.page(_page)
    except PageNotAnInteger:
        _messages = paginator.page(1)
    except EmptyPage:
        raise Http404

    _user.notifications.mark_all_as_read()
    if request.is_ajax():
        if not _messages.object_list:
            res = {
                'status': 0,
                'msg': 'no data'
            }
        else:
            _t = loader.get_template('notifications/messages/partial/ajax_notification.html')
            _c = RequestContext(request, {
                'messages': _messages,
            })
            _data = _t.render(_c)
            res = {
                'status': 1,
                'data': _data,
            }
        return JSONResponse(data=res, content_type='text/html; charset=utf-8',)

    return render_to_response(
        template,
        {
            'messages': _messages,
            'categories': random.sample(_categories, 6),
            # 'category': category,
        },
        context_instance = RequestContext(request),
    )
Пример #13
0
def get_paged_list(the_list, page_num=1, item_per_page=24):
    paginator = ExtentPaginator(the_list, item_per_page)
    try:
        _entities = paginator.page(page_num)
    except PageNotAnInteger:
        _entities = paginator.page(1)
    except EmptyPage:
        raise Http404
    return _entities
Пример #14
0
    def get_author_articles(self, author):
        if author.is_authorized_author:
            author_article_list = Article.objects.get_published_by_user(author)
            _page = int(self.request.GET.get('page', 1))
            paginator = ExtentPaginator(author_article_list, 24)
            try:
                _author_articles = paginator.page(_page)
            except PageNotAnInteger:
                _author_articles = paginator.page(1)
            except EmptyPage:
                raise Http404

            return _author_articles
Пример #15
0
def activity(request):

    log.info(request.GET)
    _timestamp = request.GET.get('timestamp', None)
    if _timestamp != None:
        _timestamp = datetime.fromtimestamp(float(_timestamp))
    _offset = int(request.GET.get('offset', '0'))
    _count = int(request.GET.get('count', '30'))
    _key = request.GET.get('session', None)

    _offset = _offset / _count + 1

    try:
        _session = Session_Key.objects.get(session_key = _key)
    except Session_Key.DoesNotExist:
        return ErrorJsonResponse(status=403)

    note_model = ContentType.objects.get_for_model(Note)
    # log.info(type(note_model))
    feed_list = Notification.objects.filter(actor_object_id__in=_session.user.following_list, action_object_content_type=note_model, timestamp__lt=_timestamp)

    paginator = ExtentPaginator(feed_list, _count)
    try:
        feeds = paginator.page(_offset)
    except PageNotAnInteger:
        feeds = paginator.page(1)
    except EmptyPage:
        return ErrorJsonResponse(status=404)

    # log.info(feeds)

    res = []
    for row in feeds.object_list:
        if row.action_object is None:
            continue
        res.append(
            {
                'type': 'entity',
                'content' : {
                    'entity' : row.target.v3_toDict(),
                    'note' : row.action_object.v3_toDict(),
                }
            }
        )

    return SuccessJsonResponse(res)
Пример #16
0
    def get(self, request):
        page = request.GET.get('page', 1)
        status = self.get_status(request)
        _buy_link_list = self.get_queryset(status=status)

        paginator = ExtentPaginator(_buy_link_list, 30)

        try:
            _buy_links = paginator.page(page)
        except InvalidPage:
            _buy_links = paginator.page(1)
        except EmptyPage:
            raise Http404

        context = {
            'buy_links': _buy_links,
            'status': status,
        }
        return self.render_to_response(context)
Пример #17
0
    def get(self, request):

        _brand_stat_list = self.get_queryset()
        page = request.GET.get('page', 1)

        paginator = ExtentPaginator(list(_brand_stat_list), 30)

        try:
            _brand_stat = paginator.page(page)
        except InvalidPage:
            _brand_stat = paginator.page(1)
        except EmptyPage:
            raise Http404

        context = {
            'brand_stat': _brand_stat,
        }

        return self.render_to_response(context)
Пример #18
0
def list(request, active='1', template="management/users/list.html"):

    page = request.GET.get('page', 1)

    if active == '2':
        user_list = GKUser.objects.editor().using('slave')
    elif active == '1':
        user_list = GKUser.objects.active().using('slave').order_by(
            "-date_joined")
    elif active == '0':
        user_list = GKUser.objects.blocked().using('slave')
    # elif active == '999':
    elif active == '3':
        user_list = GKUser.objects.writer().using('slave')
    elif active == '999':
        user_list = GKUser.objects.deactive().using('slave')
    elif active == '888':
        user_list = GKUser.objects.authorized_author().using('slave')
    elif active == '777':
        user_list = GKUser.objects.admin().using('slave')
    else:
        pass

    # else:
    #     user_list = GKUser.objects.all().order_by("-date_joined")

    paginator = ExtentPaginator(user_list, 30)

    try:
        users = paginator.page(page)
    except InvalidPage:
        users = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(
        template,
        {
            'users': users,
            'active': active,
            # 'admin':admin,
        },
        context_instance=RequestContext(request))
Пример #19
0
def pending_and_removed(request, template="management/selection/list.html"):
    _page = request.GET.get('page', 1)
    s = Selection_Entity.objects.pending_and_removed()
    paginator = ExtentPaginator(s, 30)

    try:
        selections = paginator.page(_page)
    except PageNotAnInteger:
        selections = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(
        template, {
            'selections': selections,
            'pending_count': Selection_Entity.objects.pending().count(),
            'pending_and_removed_count': s.count()
        },
        context_instance=RequestContext(request))
Пример #20
0
def list(request, template='management/comment/list.html'):

    page = request.GET.get('page', 1)

    comment_list = Note_Comment.objects.all().order_by("-post_time")

    paginator = ExtentPaginator(comment_list, 30)

    try:
        comments = paginator.page(page)
    except InvalidPage:
        comments = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(template, {
        'comments': comments,
    },
                              context_instance=RequestContext(request))
Пример #21
0
def report_list(request, template="management/report/list.html"):

    _page = request.GET.get('page', 1)

    _report_list = Report.objects.all().order_by("-id")

    paginator = ExtentPaginator(_report_list, 20)

    try:
        _reports = paginator.page(_page)
    except PageNotAnInteger:
        _reports = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(
        template,
        {'reports': _reports},
        context_instance=RequestContext(request),
    )
Пример #22
0
def list(request, template="management/media/list.html"):

    _page = request.GET.get('page', 1)
    medium_list = Media.objects.all()

    paginator = ExtentPaginator(medium_list, 30)

    try:
        _media = paginator.page(_page)
    except PageNotAnInteger:
        _media = paginator.page(1)
    except EmptyPage:
        raise  Http404

    return render_to_response(
        template,
        {
            'media': _media
        },
        context_instance = RequestContext(request)
    )
Пример #23
0
def list(request, template='management/category/list.html'):
    #
    # c = request.GET.get('c', '1')
    if request.is_ajax():

        res = {}
        # res[''] = {}
        categories = Category.objects.all()

        for c in categories:
            res[c.id] = []
            for s in c.sub_categories.all().order_by('alias'):
                res[c.id].append({
                    'category_id': s.id,
                    'category_title': s.title,
                })
                # log.info(s)
        return JSONResponse(res)
        # return HttpResponse(json.dumps(res))

    page = request.GET.get('page', 1)

    categories = Category.objects.all().order_by('-status')

    paginator = ExtentPaginator(categories, 30)
    try:
        category_list = paginator.page(page)
    except PageNotAnInteger:
        category_list = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(
        template,
        {
            # 'current_category_id': int(category_id),
            'category_list': category_list,
            # 'sub_categories': sub_categories,
        },
        context_instance=RequestContext(request))
Пример #24
0
def user_goods(request, user_id, template="web/user/goods.html"):
    _page = request.GET.get('page', 1)
    _user = get_object_or_404(get_user_model(), pk=user_id, is_active__gte=0)
    _entity_list = Entity.objects.filter(user=_user).exclude(
        status=Entity.remove)
    paginator = ExtentPaginator(_entity_list, 24)

    try:
        _entities = paginator.page(_page)
    except PageNotAnInteger:
        _entities = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(
        template,
        {
            'user': _user,
            'entities': _entities,
        },
        context_instance=RequestContext(request),
    )
Пример #25
0
def articles(request,
             user_id,
             template="web/user/user_published_articles.html"):
    _page = request.GET.get('page', 1)
    _user = get_object_or_404(get_user_model(), pk=user_id, is_active__gte=0)
    _articles = Article.objects.get_published_by_user(_user)
    paginator = ExtentPaginator(_articles, 12)
    try:
        _articles = paginator.page(_page)
    except PageNotAnInteger:
        _articles = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(
        template,
        {
            'articles': _articles,
            'user': _user
        },
        context_instance=RequestContext(request),
    )
Пример #26
0
def tag(request, user_id, template="web/user/tag.html"):
    _page = request.GET.get('page', 1)
    _user = get_object_or_404(get_user_model(), pk=user_id, is_active__gte=0)

    tag_list = Content_Tags.objects.user_tags(user_id)

    paginator = ExtentPaginator(tag_list, 12)

    try:
        _tags = paginator.page(_page)
    except PageNotAnInteger:
        _tags = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(
        template,
        {
            'tags': _tags,
            'user': _user,
        },
        context_instance=RequestContext(request),
    )
Пример #27
0
def following(request, user_id, templates="web/user/following.html"):
    page = request.GET.get('page', 1)

    _user = get_object_or_404(get_user_model(), pk=user_id, is_active__gte=0)

    followings_list = _user.followings.all()

    paginator = ExtentPaginator(followings_list, 12)

    try:
        _followings = paginator.page(page)
    except PageNotAnInteger:
        _followings = paginator.page(1)
    except EmptyPage:
        raise Http404

    return render_to_response(
        templates,
        {
            'user': _user,
            'followings': _followings,
        },
        context_instance=RequestContext(request),
    )
Пример #28
0
    def get_data(self, context):
        note_model = ContentType.objects.get_for_model(Note)
        entity_list_models = ContentType.objects.get_for_model(Entity_Like)
        user_follow = ContentType.objects.get_for_model(User_Follow)
        article_dig = ContentType.objects.get_for_model(Article_Dig)
        article_remark = ContentType.objects.get_for_model(Article_Remark)

        da = Article_Dig.objects.filter(user=self.user).values_list(
            'article_id', flat=True)
        ra = Article_Remark.objects.filter(user=self.user).values_list(
            'article_id', flat=True)

        feed_list = Notification.objects.filter(
            actor_object_id__in=self.user.following_list,
            action_object_content_type__in=[
                note_model, entity_list_models, user_follow, article_dig,
                article_remark
            ],
            timestamp__lt=self.timestamp)

        paginator = ExtentPaginator(feed_list, self.count)
        try:
            feeds = paginator.page(self.offset)
        except PageNotAnInteger:
            feeds = paginator.page(1)
        except EmptyPage:
            return ErrorJsonResponse(status=404)

        res = []
        for row in feeds.object_list:
            if row.action_object is None:
                continue

            # log.info(row.action_object_content_type)
            if isinstance(row.action_object, Note):
                res.append({
                    'type':
                    'entity',
                    'created_time':
                    time.mktime(row.timestamp.timetuple()),
                    'content': {
                        'entity': row.target.v3_toDict(),
                        'note': row.action_object.v3_toDict(),
                    }
                })
            elif isinstance(row.action_object, User_Follow):
                _context = {
                    'type': 'user_follow',
                    'created_time': time.mktime(row.timestamp.timetuple()),
                    'content': {
                        'user': row.actor.v3_toDict(),
                        'target': row.target.v3_toDict(),
                    }
                }
                res.append(_context)
            elif isinstance(row.action_object, Entity_Like):
                _context = {
                    'type': 'user_like',
                    'created_time': time.mktime(row.timestamp.timetuple()),
                    'content': {
                        'liker': row.actor.v3_toDict(),
                        'entity': row.target.v3_toDict(),
                    }
                }
                res.append(_context)
            elif isinstance(row.action_object, Article_Dig):
                _context = {
                    'type': 'article_dig',
                    'created_time': time.mktime(row.timestamp.timetuple()),
                    'content': {
                        'digger': row.actor.v3_toDict(),
                        'article': row.target.v4_toDict(articles_list=da),
                    }
                }
                res.append(_context)

            elif isinstance(row.action_object, Article_Remark):
                _context = {
                    'type': 'article_remark',
                    'created_time': time.mktime(row.timestamp.timetuple()),
                    'content': {
                        'remark_user': row.actor.v3_toDict(),
                        'article': row.target.v4_toDict(articles_list=ra),
                    }
                }
                res.append(_context)

        return res
Пример #29
0
def event(request, slug, template='web/events/home'):
    _page_num = request.GET.get('p', 1)
    _slug = slug
    try:
        event = Event.objects.get(slug=_slug)
        template = template + '_%s.html' % _slug
    except Event.DoesNotExist:
        raise Http404

    try:
        loader.get_template(template)
    except TemplateDoesNotExist:
        template = "web/events/home.html"

    hash_str = md5(event.tag.encode('utf-8')).hexdigest()
    tag = Tags.objects.get(hash=hash_str)
    inner_qs = Content_Tags.objects.filter(tag=tag, target_content_type=24) \
        .values_list('target_object_id', flat=True).using('slave')
    log.info(inner_qs.query)
    _eid_list = Note.objects.filter(pk__in=list(inner_qs)).values_list(
        'entity_id', flat=True).using('slave')

    _entity_list = Entity.objects.filter(id__in=list(set(_eid_list)), status=Entity.selection) \
        .filter(selection_entity__is_published=True, selection_entity__pub_time__lte=datetime.now()) \
        .using('slave')

    # here is some dirty code for 1111 event
    top_entities_list = None
    top_entities_list_like = list()
    if event.toptag:
        top_tag_name = event.toptag
        # TODO: 此部分逻辑太复杂,查询太多,影响性能
        try:
            top_tag = Tags.objects.get(name=top_tag_name)

            note_id_list = Content_Tags.objects \
                .filter(tag=top_tag, target_content_type_id=24) \
                .values_list("target_object_id", flat=True) \
                .using('slave')

            top_entities_id_list = Note.objects \
                .filter(pk__in=list(note_id_list)) \
                .values_list('entity_id', flat=True) \
                .using('slave')

            top_entities_filter = Q(pk__in=list(top_entities_id_list))
            top_entities_filter &= Q(selection_entity__is_published=True)
            top_entities_filter &= Q(
                selection_entity__pub_time__lte=datetime.now())
            top_entities_list = Entity.objects.filter(
                top_entities_filter).using('slave')

            if request.user.is_authenticated():
                top_entities_list_like = Entity_Like.objects \
                    .filter(entity_id__in=top_entities_list, user=request.user) \
                    .values_list('entity_id', flat=True).using('slave')

        except Tags.DoesNotExist as e:
            pass

    _paginator = ExtentPaginator(_entity_list, 12)

    try:
        _entities = _paginator.page(_page_num)
    except PageNotAnInteger:
        _entities = _paginator.page(1)
    except EmptyPage:
        raise Http404

    el = list()
    if request.user.is_authenticated():
        e = _entities.object_list
        el = Entity_Like.objects.filter(entity_id__in=list(e),
                                        user=request.user).values_list(
                                            'entity_id', flat=True)
        el = list(el) + list(top_entities_list_like)

    _show_event_banners = Show_Event_Banner.objects.filter(event=event,
                                                           position__gt=0)
    _show_editor_recommendations = Show_Editor_Recommendation.objects.filter(
        event=event, position__gt=0)

    _show_editor_recommendations_entity = Show_Editor_Recommendation.objects \
        .filter(event=event, section='entity', position__gt=0).order_by('position')

    _show_editor_recommendations_fair = Show_Editor_Recommendation.objects \
        .filter(event=event, section='fair', position__gt=0).order_by('position')

    _show_editor_recommendations_shop = Show_Editor_Recommendation.objects \
        .filter(event=event, section='shop', position__gt=0).order_by('position')

    if request.is_ajax():
        _ret = {'status': 0, 'msg': '没有更多数据'}

        if _entity_list:
            log.info(_entities)
            _t = loader.get_template(
                'web/events/partial/event_entity_list.html')
            try:
                _c = RequestContext(request, {
                    'user_entity_likes': el,
                    'entities': _entities,
                })

                _data = _t.render(_c)
            except Exception, e:
                log.error('render error', e.message)
                _data = list()

            _ret = {'status': '1', 'data': _data}
        return JSONResponse(
            data=_ret,
            content_type='text/html; charset=utf-8',
        )