forked from mirrors/bookwyrm
allow group members to add items to group lists directly
NOTE: this will be the case regardless of privacy settings of the list
This commit is contained in:
parent
81e5ff5b76
commit
c87712c995
2 changed files with 10 additions and 4 deletions
|
@ -123,7 +123,7 @@
|
|||
</form>
|
||||
{% if request.user.is_authenticated and not list.curation == 'closed' or request.user == list.user %}
|
||||
<h2 class="title is-5 mt-6">
|
||||
{% if list.curation == 'open' or request.user == list.user %}
|
||||
{% if list.curation == 'open' or request.user == list.user or is_group_member %}
|
||||
{% trans "Add Books" %}
|
||||
{% else %}
|
||||
{% trans "Suggest Books" %}
|
||||
|
@ -176,7 +176,7 @@
|
|||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
<input type="hidden" name="list" value="{{ list.id }}">
|
||||
<button type="submit" class="button is-small is-link">{% if list.curation == 'open' or request.user == list.user %}{% trans "Add" %}{% else %}{% trans "Suggest" %}{% endif %}</button>
|
||||
<button type="submit" class="button is-small is-link">{% if list.curation == 'open' or request.user == list.user or is_group_member %}{% trans "Add" %}{% else %}{% trans "Suggest" %}{% endif %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -177,6 +177,7 @@ class List(View):
|
|||
][: 5 - len(suggestions)]
|
||||
|
||||
user_groups = models.Group.objects.filter(members=request.user).order_by("-updated_date")
|
||||
is_group_member = book_list.group in user_groups
|
||||
page = paginated.get_page(request.GET.get("page"))
|
||||
data = {
|
||||
"list": book_list,
|
||||
|
@ -191,7 +192,8 @@ class List(View):
|
|||
"sort_form": forms.SortListForm(
|
||||
{"direction": direction, "sort_by": sort_by}
|
||||
),
|
||||
"user_groups": user_groups
|
||||
"user_groups": user_groups,
|
||||
"is_group_member": is_group_member
|
||||
}
|
||||
return TemplateResponse(request, "lists/list.html", data)
|
||||
|
||||
|
@ -292,13 +294,17 @@ def delete_list(request, list_id):
|
|||
def add_book(request):
|
||||
"""put a book on a list"""
|
||||
book_list = get_object_or_404(models.List, id=request.POST.get("list"))
|
||||
is_group_member = False
|
||||
if book_list.curation == "group":
|
||||
user_groups = models.Group.objects.filter(members=request.user).order_by("-updated_date")
|
||||
is_group_member = book_list.group in user_groups
|
||||
if not book_list.visible_to_user(request.user):
|
||||
return HttpResponseNotFound()
|
||||
|
||||
book = get_object_or_404(models.Edition, id=request.POST.get("book"))
|
||||
# do you have permission to add to the list?
|
||||
try:
|
||||
if request.user == book_list.user or book_list.curation == "open":
|
||||
if request.user == book_list.user or is_group_member or book_list.curation == "open":
|
||||
# add the book at the latest order of approved books, before pending books
|
||||
order_max = (
|
||||
book_list.listitem_set.filter(approved=True).aggregate(Max("order"))[
|
||||
|
|
Loading…
Reference in a new issue