add "Create list" form to group template

This commit is contained in:
Hugh Rundle 2021-12-19 14:19:35 +11:00
parent f7c6cb3598
commit 1603df0817
No known key found for this signature in database
GPG key ID: CD23D6039184286B
4 changed files with 20 additions and 10 deletions

View file

@ -11,13 +11,22 @@
{% include 'groups/created_text.html' with group=group %} {% include 'groups/created_text.html' with group=group %}
</p> </p>
</div> </div>
<div class="column is-narrow is-flex">
{% if request.user == group.user %} {% if request.user == group.user %}
<div class="column is-narrow is-flex">
{% trans "Create List" as button_text %}
{% include 'snippets/toggle/open_button.html' with controls_text="create_list" icon_with_text="plus" text=button_text focus="create_list_header" %}
</div>
<div class="column is-narrow is-flex">
{% trans "Edit group" as button_text %} {% trans "Edit group" as button_text %}
{% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_group" focus="edit_group_header" %} {% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_group" focus="edit_group_header" %}
{% endif %}
</div> </div>
{% endif %}
</header> </header>
{% if request.user.is_authenticated %}
<div class="block">
{% include 'lists/create_form.html' with controls_text="create_list" curation_group=group %}
</div>
{% endif %}
<div class="block content"> <div class="block content">
{% include 'snippets/trimmed_text.html' with full=group.description %} {% include 'snippets/trimmed_text.html' with full=group.description %}

View file

@ -7,6 +7,6 @@
{% block form %} {% block form %}
<form name="create-list" method="post" action="{% url 'lists' %}"> <form name="create-list" method="post" action="{% url 'lists' %}">
{% include 'lists/form.html' %} {% include 'lists/form.html' with curation_group=group %}
</form> </form>
{% endblock %} {% endblock %}

View file

@ -19,7 +19,7 @@
<legend class="label">{% trans "List curation:" %}</legend> <legend class="label">{% trans "List curation:" %}</legend>
<label class="field" data-hides="list_group_selector"> <label class="field" data-hides="list_group_selector">
<input type="radio" name="curation" value="closed"{% if not list or list.curation == 'closed' %} checked{% endif %}> {% trans "Closed" %} <input type="radio" name="curation" value="closed"{% if not curation_group.exists or not list or list.curation == 'closed' %} checked{% endif %}> {% trans "Closed" %}
<p class="help mb-2">{% trans "Only you can add and remove books to this list" %}</p> <p class="help mb-2">{% trans "Only you can add and remove books to this list" %}</p>
</label> </label>
@ -34,17 +34,17 @@
</label> </label>
<label class="field hidden-form"> <label class="field hidden-form">
<input type="radio" name="curation" value="group"{% if list.curation == 'group' %} checked{% endif %} > {% trans "Group" %} <input type="radio" name="curation" value="group"{% if curation_group.id or list.curation == 'group' %} checked{% endif %} > {% trans "Group" %}
<p class="help mb-2">{% trans "Group members can add to and remove from this list" %}</p> <p class="help mb-2">{% trans "Group members can add to and remove from this list" %}</p>
<fieldset class="{% if list.curation != 'group' %}is-hidden{% endif %}" id="list_group_selector"> <fieldset class="{% if list.curation != 'group' and not curation_group %}is-hidden{% endif %}" id="list_group_selector">
{% if user.memberships.exists %} {% if user.memberships.exists %}
<label class="label" for="id_group" id="group">{% trans "Select Group" %}</label> <label class="label" for="id_group" id="group">{% trans "Select Group" %}</label>
<div class="field has-addons"> <div class="field has-addons">
<div class="select control"> <div class="select control">
<select name="group" id="id_group"> <select name="group" id="id_group">
<option value="" disabled {% if not list.group %} selected{% endif %}>{% trans "Select a group" %}</option> <option value="" disabled {% if not list.group and not curation_group %} selected{% endif %}>{% trans "Select a group" %}</option>
{% for membership in user.memberships.all %} {% for membership in user.memberships.all %}
<option value="{{ membership.group.id }}" {% if list.group.id == membership.group.id %} selected{% endif %}>{{ membership.group.name }}</option> <option value="{{ membership.group.id }}" {% if list.group.id == membership.group.id or curation_group.id == membership.group.id %} selected{% endif %}>{{ membership.group.name }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>

View file

@ -35,6 +35,7 @@ class Group(View):
"group": group, "group": group,
"lists": lists, "lists": lists,
"group_form": forms.GroupForm(instance=group), "group_form": forms.GroupForm(instance=group),
"list_form": forms.ListForm(),
"path": "/group", "path": "/group",
} }
return TemplateResponse(request, "groups/group.html", data) return TemplateResponse(request, "groups/group.html", data)