Add basic proposal acceptance admin view
This commit is contained in:
parent
7248b40a60
commit
b22cdef2b8
5 changed files with 291 additions and 3 deletions
77
froide_govplan/templates/froide_govplan/admin/_proposal.html
Normal file
77
froide_govplan/templates/froide_govplan/admin/_proposal.html
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
{% load i18n %}
|
||||
{% load form_helper %}
|
||||
{% load permission_helper %}
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Field" %}</th>
|
||||
{% for key, proposal in proposals.items %}
|
||||
<th>
|
||||
<span title="{{ proposal.timestamp }}">
|
||||
{% if request.user.is_staff and request.user|has_perm:"account.view_user" %}
|
||||
{{ proposal.user.get_full_name }} ({{ proposal.user.email }})
|
||||
{% else %}
|
||||
{{ proposal.timestamp | date:"SHORT_DATETIME" }}
|
||||
{% endif %}
|
||||
</span>
|
||||
</th>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if proposals %}
|
||||
<tr>
|
||||
<td>
|
||||
{% trans "Proposal" %}
|
||||
</td>
|
||||
{% for key, proposal in proposals.items %}
|
||||
<td>
|
||||
<label>
|
||||
<input type="radio" name="proposal_id" class="proposal" value="{{ key }}" required>
|
||||
{% trans "Turn into update draft" %}
|
||||
</label>
|
||||
</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% for field in form %}
|
||||
<tr>
|
||||
<td>{{ field.label }}</td>
|
||||
{% for key, proposal in proposals.items %}
|
||||
{% with val=proposal.data|get_item_by_key:field.name %}
|
||||
<td>
|
||||
{% with label_name=field.name|add:"_label" %}
|
||||
{% if proposal.data|get_item_by_key:label_name %}
|
||||
{{ proposal.data|get_item_by_key:label_name }}
|
||||
{% else %}
|
||||
{{ val|urlize|linebreaksbr }}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{{ form.field }}
|
||||
{% endfor %}
|
||||
|
||||
{% if proposals %}
|
||||
<tr>
|
||||
<td>
|
||||
{% trans "Delete proposal" %}
|
||||
</td>
|
||||
{% for key, proposal in proposals.items %}
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="proposal_delete" value="{{ proposal.user.id }}">
|
||||
{% trans "Delete" %}
|
||||
</label>
|
||||
</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
{% extends "admin/change_form.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}{{ object.title }} - {{ block.super }}{% endblock %}
|
||||
|
||||
|
||||
{% block content %}<div id="content-main">
|
||||
<h3>{{ object.title }}</h3>
|
||||
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
<fieldset>
|
||||
{% include "froide_govplan/admin/_proposal.html" %}
|
||||
</fieldset>
|
||||
<div class="submit-row">
|
||||
<input type="submit" value="{% trans 'Create update draft' %}" style="float:left"/>
|
||||
</div>
|
||||
|
||||
<div class="card border-danger mt-3">
|
||||
<div class="card-body">
|
||||
<h3>{% trans "Delete proposal" %}</h3>
|
||||
<p><label for="delete_reason">
|
||||
{% trans "Please give a reason for not accepting this proposal. It will be send to the user who made the proposal." %}
|
||||
</label>
|
||||
<p>
|
||||
<p><textarea id="delete_reason" class="form-control" name="delete_reason" placeholder="{% trans 'We could not accept this update because...' %}"></textarea></p>
|
||||
<p><button class="mt-2 btn btn-danger float-right" type="submit" name="delete" value="1">
|
||||
{% trans "Delete proposed update" %}
|
||||
</button></p>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue