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_more = True if len(
|
||||||
review_list) > REVIEW_NUMBER else False
|
review_list) > REVIEW_NUMBER else False
|
||||||
review_list = review_list[:REVIEW_NUMBER]
|
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):
|
# def strip_html_tags(text):
|
||||||
# import re
|
# import re
|
||||||
|
|
|
@ -92,6 +92,9 @@
|
||||||
{{ collection.title }}
|
{{ collection.title }}
|
||||||
</a>
|
</a>
|
||||||
</h5>
|
</h5>
|
||||||
|
{% if follower_count %}
|
||||||
|
被 {{ follower_count }} 人关注
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -153,12 +153,8 @@ def retrieve(request, id):
|
||||||
raise PermissionDenied()
|
raise PermissionDenied()
|
||||||
form = CollectionForm(instance=collection)
|
form = CollectionForm(instance=collection)
|
||||||
|
|
||||||
if request.user.is_authenticated:
|
following = True if request.user.is_authenticated and CollectionMark.objects.filter(owner=request.user, collection=collection).first() is not None else False
|
||||||
following = True if CollectionMark.objects.filter(owner=request.user, collection=collection).first() is not None else False
|
follower_count = CollectionMark.objects.filter(collection=collection).count()
|
||||||
followers = []
|
|
||||||
else:
|
|
||||||
following = False
|
|
||||||
followers = []
|
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
|
@ -167,7 +163,7 @@ def retrieve(request, id):
|
||||||
'collection': collection,
|
'collection': collection,
|
||||||
'form': form,
|
'form': form,
|
||||||
'editable': request.user.is_authenticated and collection.is_editable_by(request.user),
|
'editable': request.user.is_authenticated and collection.is_editable_by(request.user),
|
||||||
'followers': followers,
|
'follower_count': follower_count,
|
||||||
'following': following,
|
'following': following,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -184,10 +180,6 @@ def retrieve_entity_list(request, id):
|
||||||
raise PermissionDenied()
|
raise PermissionDenied()
|
||||||
form = CollectionForm(instance=collection)
|
form = CollectionForm(instance=collection)
|
||||||
|
|
||||||
followers = []
|
|
||||||
if request.user.is_authenticated:
|
|
||||||
followers = []
|
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
'entity_list.html',
|
'entity_list.html',
|
||||||
|
@ -195,8 +187,6 @@ def retrieve_entity_list(request, id):
|
||||||
'collection': collection,
|
'collection': collection,
|
||||||
'form': form,
|
'form': form,
|
||||||
'editable': request.user.is_authenticated and collection.is_editable_by(request.user),
|
'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_more = True if len(
|
||||||
review_list) > REVIEW_NUMBER else False
|
review_list) > REVIEW_NUMBER else False
|
||||||
review_list = review_list[:REVIEW_NUMBER]
|
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):
|
# def strip_html_tags(text):
|
||||||
# import re
|
# import re
|
||||||
|
|
|
@ -211,7 +211,8 @@ def retrieve(request, id):
|
||||||
review_list_more = True if len(
|
review_list_more = True if len(
|
||||||
review_list) > REVIEW_NUMBER else False
|
review_list) > REVIEW_NUMBER else False
|
||||||
review_list = review_list[:REVIEW_NUMBER]
|
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):
|
# def strip_html_tags(text):
|
||||||
# import re
|
# import re
|
||||||
|
|
|
@ -218,7 +218,8 @@ def retrieve_song(request, id):
|
||||||
review_list_more = True if len(
|
review_list_more = True if len(
|
||||||
review_list) > REVIEW_NUMBER else False
|
review_list) > REVIEW_NUMBER else False
|
||||||
review_list = review_list[:REVIEW_NUMBER]
|
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):
|
# def strip_html_tags(text):
|
||||||
# import re
|
# import re
|
||||||
|
@ -780,7 +781,8 @@ def retrieve_album(request, id):
|
||||||
review_list_more = True if len(
|
review_list_more = True if len(
|
||||||
review_list) > REVIEW_NUMBER else False
|
review_list) > REVIEW_NUMBER else False
|
||||||
review_list = review_list[:REVIEW_NUMBER]
|
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):
|
# def strip_html_tags(text):
|
||||||
# import re
|
# import re
|
||||||
|
|
Loading…
Add table
Reference in a new issue