accept reconciliation

This commit is contained in:
Cayo Puigdefabregas 2025-03-11 11:03:47 +01:00
parent 64a95bf114
commit b73b96dba9
3 changed files with 45 additions and 12 deletions

View file

@ -1,4 +1,5 @@
{% load i18n %}
{% load django_bootstrap5 %}
<!DOCTYPE html>
<html lang="en">
@ -117,10 +118,28 @@
</table>
</div>
</div>
{% if not donor.reconciliation %}
<div class="row mt-4">
<div class="col">
<div class="form-actions-no-box">
<a class="btn btn-secondary" href="{% url 'lot:accept_donor' donor.lot.id donor.id %}">{% trans 'Accept' %}</a>
</div>
</div>
</div>
{% else %}
<div class="row mt-4">
<div class="col">
<div class="form-actions-no-box">
<a class="btn btn-secondary" href="{# url 'lot:impact_doc_donor' donor.lot.id donor.id #}">{% trans 'Impact Inform' %}</a>
</div>
</div>
</div>
{% endif %}
</div>
<footer>
<p>
&copy;{% now 'Y' %}eReuse. All rights reserved.
&copy;{% now 'Y' %} eReuse. All rights reserved.
</p>
</footer>

View file

@ -19,4 +19,5 @@ urlpatterns = [
path("<int:pk>/donor/add", views.AddDonorView.as_view(), name="add_donor"),
path("<int:pk>/donor/del", views.DelDonorView.as_view(), name="del_donor"),
path("<int:pk>/donor/<uuid:id>", views.DonorView.as_view(), name="web_donor"),
path("<int:pk>/donor/<uuid:id>/accept", views.AcceptDonorView.as_view(), name="accept_donor"),
]

View file

@ -423,12 +423,10 @@ class DelDonorView(DonorMixing):
return context
class DonorView(TemplateView, UpdateView):
class DonorView(TemplateView):
template_name = "donor_web.html"
model = Donor
fields = ("reconciliation",)
def get_form_kwargs(self):
def get_context_data(self, **kwargs):
pk = self.kwargs.get('pk')
id = self.kwargs.get('id')
@ -437,13 +435,6 @@ class DonorView(TemplateView, UpdateView):
id=id,
lot_id=pk
)
self.success_url = reverse_lazy('lot:web_donor', args=[pk, id])
kwargs = super().get_form_kwargs()
kwargs['instance'] = self.object
return kwargs
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["donor"] = self.object
context["devices"] = self.get_devices()
@ -465,3 +456,25 @@ class DonorView(TemplateView, UpdateView):
chids_ordered.append(Device(id=x.value))
return chids_ordered
class AcceptDonorView(TemplateView):
template_name = "donor_web.html"
def get(self, *args, **kwargs):
super().get(*args, **kwargs)
self.success_url = reverse_lazy('lot:web_donor', args=[pk, id])
pk = self.kwargs.get('pk')
id = self.kwargs.get('id')
self.object = get_object_or_404(
Donor,
id=id,
lot_id=pk
)
self.object.reconciliation = True
self.object.save()
# TODO
# self.send_email()
return redirect(self.success_url)