mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-11 10:46:37 +00:00
remove list from group when changing curation
Allows 'group' to be blank when saving a list. Removes the 'group' field when saving a list with curation other than 'group' - this stops the list "sticking" to a group after it is changed from group curation to something else.
This commit is contained in:
parent
8bfc71db6e
commit
5fccb991a7
3 changed files with 7 additions and 11 deletions
|
@ -37,7 +37,8 @@ class List(OrderedCollectionMixin, BookWyrmModel):
|
|||
group = models.ForeignKey(
|
||||
"Group",
|
||||
on_delete=models.CASCADE,
|
||||
null=True
|
||||
default=None,
|
||||
blank=True
|
||||
)
|
||||
books = models.ManyToManyField(
|
||||
"Edition",
|
||||
|
|
|
@ -37,20 +37,16 @@
|
|||
<input type="radio" name="curation" value="group"{% if list.curation == 'group' %} checked{% endif %}> {% trans "Group" %}
|
||||
<p class="help mb-2">{% trans "Group members can add to and remove from this list" %}</p>
|
||||
</label>
|
||||
|
||||
<!-- TODO: add a list picker on-select for group lists -->
|
||||
|
||||
<!-- TODO: change the submission url -->
|
||||
<!-- <form name="list-add" method="post" action="{% url 'list-add-book' %}"> -->
|
||||
{% if user_groups %}
|
||||
{% csrf_token %}
|
||||
<label class="label" for="id_group">{% trans "Select Group" %}</label>
|
||||
<div class="field has-addons">
|
||||
<div class="select control">
|
||||
<select name="group" id="id_group">
|
||||
<option value="{{ group.id }}" disabled selected></option>
|
||||
<option value="">Select a list</option>
|
||||
{% for group in user_groups %}
|
||||
<option value="{{ group.id }}">{{ group.name }}</option>
|
||||
<option value="{{ group.id }}" {% if list.group.id == group.id %} selected{% endif %}>{{ group.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
@ -62,10 +62,6 @@ class Lists(View):
|
|||
def post(self, request):
|
||||
"""create a book_list"""
|
||||
form = forms.ListForm(request.POST)
|
||||
# TODO: here we need to take the value of the group (the group.id)
|
||||
# and fetch the actual group to add to the DB
|
||||
# but only if curation type is 'group' other wise the value of
|
||||
# group is None
|
||||
if not form.is_valid():
|
||||
return redirect("lists")
|
||||
book_list = form.save()
|
||||
|
@ -208,6 +204,9 @@ class List(View):
|
|||
if not form.is_valid():
|
||||
return redirect("list", book_list.id)
|
||||
book_list = form.save()
|
||||
if not book_list.curation == "group":
|
||||
book_list.group = None
|
||||
book_list.save()
|
||||
return redirect(book_list.local_path)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue