collection: show follows; order by follows
This commit is contained in:
parent
f48252c19e
commit
6acd109eca
6 changed files with 16 additions and 18 deletions
|
@ -210,7 +210,8 @@ def retrieve(request, id):
|
|||
review_list_more = True if len(
|
||||
review_list) > REVIEW_NUMBER else False
|
||||
review_list = review_list[:REVIEW_NUMBER]
|
||||
collection_list = filter(lambda c: c.is_visible_to(request.user), map(lambda i: i.collection, CollectionItem.objects.filter(book=book)))
|
||||
all_collections = CollectionItem.objects.filter(book=book).annotate(num_marks=Count('collection__collection_marks')).order_by('-num_marks')[:20]
|
||||
collection_list = filter(lambda c: c.is_visible_to(request.user), map(lambda i: i.collection, all_collections))
|
||||
|
||||
# def strip_html_tags(text):
|
||||
# import re
|
||||
|
|
|
@ -92,6 +92,9 @@
|
|||
{{ collection.title }}
|
||||
</a>
|
||||
</h5>
|
||||
{% if follower_count %}
|
||||
被 {{ follower_count }} 人关注
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -153,12 +153,8 @@ def retrieve(request, id):
|
|||
raise PermissionDenied()
|
||||
form = CollectionForm(instance=collection)
|
||||
|
||||
if request.user.is_authenticated:
|
||||
following = True if CollectionMark.objects.filter(owner=request.user, collection=collection).first() is not None else False
|
||||
followers = []
|
||||
else:
|
||||
following = False
|
||||
followers = []
|
||||
following = True if request.user.is_authenticated and CollectionMark.objects.filter(owner=request.user, collection=collection).first() is not None else False
|
||||
follower_count = CollectionMark.objects.filter(collection=collection).count()
|
||||
|
||||
return render(
|
||||
request,
|
||||
|
@ -167,7 +163,7 @@ def retrieve(request, id):
|
|||
'collection': collection,
|
||||
'form': form,
|
||||
'editable': request.user.is_authenticated and collection.is_editable_by(request.user),
|
||||
'followers': followers,
|
||||
'follower_count': follower_count,
|
||||
'following': following,
|
||||
}
|
||||
)
|
||||
|
@ -184,10 +180,6 @@ def retrieve_entity_list(request, id):
|
|||
raise PermissionDenied()
|
||||
form = CollectionForm(instance=collection)
|
||||
|
||||
followers = []
|
||||
if request.user.is_authenticated:
|
||||
followers = []
|
||||
|
||||
return render(
|
||||
request,
|
||||
'entity_list.html',
|
||||
|
@ -195,8 +187,6 @@ def retrieve_entity_list(request, id):
|
|||
'collection': collection,
|
||||
'form': form,
|
||||
'editable': request.user.is_authenticated and collection.is_editable_by(request.user),
|
||||
'followers': followers,
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -212,7 +212,8 @@ def retrieve(request, id):
|
|||
review_list_more = True if len(
|
||||
review_list) > REVIEW_NUMBER else False
|
||||
review_list = review_list[:REVIEW_NUMBER]
|
||||
collection_list = filter(lambda c: c.is_visible_to(request.user), map(lambda i: i.collection, CollectionItem.objects.filter(game=game)))
|
||||
all_collections = CollectionItem.objects.filter(game=game).annotate(num_marks=Count('collection__collection_marks')).order_by('-num_marks')[:20]
|
||||
collection_list = filter(lambda c: c.is_visible_to(request.user), map(lambda i: i.collection, all_collections))
|
||||
|
||||
# def strip_html_tags(text):
|
||||
# import re
|
||||
|
|
|
@ -211,7 +211,8 @@ def retrieve(request, id):
|
|||
review_list_more = True if len(
|
||||
review_list) > REVIEW_NUMBER else False
|
||||
review_list = review_list[:REVIEW_NUMBER]
|
||||
collection_list = filter(lambda c: c.is_visible_to(request.user), map(lambda i: i.collection, CollectionItem.objects.filter(movie=movie)))
|
||||
all_collections = CollectionItem.objects.filter(movie=movie).annotate(num_marks=Count('collection__collection_marks')).order_by('-num_marks')[:20]
|
||||
collection_list = filter(lambda c: c.is_visible_to(request.user), map(lambda i: i.collection, all_collections))
|
||||
|
||||
# def strip_html_tags(text):
|
||||
# import re
|
||||
|
|
|
@ -218,7 +218,8 @@ def retrieve_song(request, id):
|
|||
review_list_more = True if len(
|
||||
review_list) > REVIEW_NUMBER else False
|
||||
review_list = review_list[:REVIEW_NUMBER]
|
||||
collection_list = filter(lambda c: c.is_visible_to(request.user), map(lambda i: i.collection, CollectionItem.objects.filter(song=song)))
|
||||
all_collections = CollectionItem.objects.filter(song=song).annotate(num_marks=Count('collection__collection_marks')).order_by('-num_marks')[:20]
|
||||
collection_list = filter(lambda c: c.is_visible_to(request.user), map(lambda i: i.collection, all_collections))
|
||||
|
||||
# def strip_html_tags(text):
|
||||
# import re
|
||||
|
@ -780,7 +781,8 @@ def retrieve_album(request, id):
|
|||
review_list_more = True if len(
|
||||
review_list) > REVIEW_NUMBER else False
|
||||
review_list = review_list[:REVIEW_NUMBER]
|
||||
collection_list = filter(lambda c: c.is_visible_to(request.user), map(lambda i: i.collection, CollectionItem.objects.filter(album=album)))
|
||||
all_collections = CollectionItem.objects.filter(album=album).annotate(num_marks=Count('collection__collection_marks')).order_by('-num_marks')[:20]
|
||||
collection_list = filter(lambda c: c.is_visible_to(request.user), map(lambda i: i.collection, all_collections))
|
||||
|
||||
# def strip_html_tags(text):
|
||||
# import re
|
||||
|
|
Loading…
Add table
Reference in a new issue