Skip to content
Snippets Groups Projects
Commit 03548a67 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '132-possibility-to-modify-contact-attempt-comments' into 'master'

adding contact attempts is possible from appointment edit page

Closes #132

See merge request !58
parents 7f69c07d 3e5b1c62
No related branches found
No related tags found
1 merge request!58adding contact attempts is possible from appointment edit page
Pipeline #
...@@ -105,6 +105,9 @@ ...@@ -105,6 +105,9 @@
</form> </form>
</div> </div>
{% include 'includes/mail_templates_box.html' with instance_id=appointment.id %} {% include 'includes/mail_templates_box.html' with instance_id=appointment.id %}
{% if appointment.visit %}
{% include 'includes/contact_attempts_box.html' with subject=appointment.visit.subject contact_attempts=contact_attempts appointment_id=appointment.id %}
{% endif %}
{% endblock %} {% endblock %}
......
<div class="row">
<div class="col-lg-12">
<div class="box box-success">
<div class="box-header with-border">
<h3>Contact attempts <a title="add a new contact attempt"
id="add-contact-attempt"
href="
{% url 'web.views.contact_add' subject.id %}{% if appointment_id %}?from_appointment={{ appointment_id }}{% endif %}"
class="text-primary"
><i class="fa fa-plus-circle text-success"></i></a></h3>
</div>
<div class="box-body">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="text-center">When</th>
<th class="text-center">Who</th>
<th class="text-center">Type</th>
<th class="text-center">Success</th>
<th class="text-center">Comment</th>
</tr>
</thead>
<tbody>
{% for contact_attempt in contact_attempts %}
<tr>
<td>{{ contact_attempt.datetime_when }}</td>
<td>{{ contact_attempt.worker }}</td>
<td class="text-center">{{ contact_attempt.get_type_display }}</td>
<td class="text-center">
<i class="fa {% if contact_attempt.success %}fa-check text-success{% else %}fa-times text-danger{% endif %}"></i>
</td>
<td>{{ contact_attempt.comment }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
...@@ -90,47 +90,7 @@ ...@@ -90,47 +90,7 @@
{% include 'includes/mail_templates_box.html' with instance_id=subject.id %} {% include 'includes/mail_templates_box.html' with instance_id=subject.id %}
<div class="row"> {% include 'includes/contact_attempts_box.html' with subject=subject contact_attempts=contact_attempts %}
<div class="col-lg-12">
<div class="box box-success">
<div class="box-header with-border">
<h3>Contact attempts <a title="add a new contact attempt"
id="add-contact-attempt"
href="{% url 'web.views.contact_add' subject.id %}" class="text-primary"
><i class="fa fa-plus-circle text-success"></i></a></h3>
</div>
<div class="box-body">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="text-center">When</th>
<th class="text-center">Who</th>
<th class="text-center">Type</th>
<th class="text-center">Success</th>
<th class="text-center">Comment</th>
</tr>
</thead>
<tbody>
{% for contact_attempt in contact_attempts %}
<tr>
<td>{{ contact_attempt.datetime_when }}</td>
<td>{{ contact_attempt.worker }}</td>
<td class="text-center">{{ contact_attempt.get_type_display }}</td>
<td class="text-center">
<i class="fa {% if contact_attempt.success %}fa-check text-success{% else %}fa-times text-danger{% endif %}"></i>
</td>
<td>{{ contact_attempt.comment }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="modal modal-danger fade" id="confirm-dead-resigned-mark-dialog" tabindex="-1" role="dialog"> <div class="modal modal-danger fade" id="confirm-dead-resigned-mark-dialog" tabindex="-1" role="dialog">
......
...@@ -54,6 +54,7 @@ def appointment_add(request, visit_id=None): ...@@ -54,6 +54,7 @@ def appointment_add(request, visit_id=None):
def appointment_edit(request, id): def appointment_edit(request, id):
the_appointment = get_object_or_404(Appointment, id=id) the_appointment = get_object_or_404(Appointment, id=id)
subject_form = None subject_form = None
contact_attempts = None
if request.method == 'POST': if request.method == 'POST':
appointment_form = AppointmentEditForm(request.POST, appointment_form = AppointmentEditForm(request.POST,
...@@ -94,6 +95,7 @@ def appointment_edit(request, id): ...@@ -94,6 +95,7 @@ def appointment_edit(request, id):
if the_appointment.visit is not None: if the_appointment.visit is not None:
subject_form = SubjectEditForm(instance=the_appointment.visit.subject, prefix="subject") subject_form = SubjectEditForm(instance=the_appointment.visit.subject, prefix="subject")
contact_attempts = the_appointment.visit.subject.contactattempt_set.order_by('-datetime_when').all()
languages = [] languages = []
if the_appointment.visit is not None: if the_appointment.visit is not None:
...@@ -106,5 +108,6 @@ def appointment_edit(request, id): ...@@ -106,5 +108,6 @@ def appointment_edit(request, id):
'subject_form': subject_form, 'subject_form': subject_form,
'id': id, 'id': id,
'appointment': the_appointment, 'appointment': the_appointment,
'contact_attempts': contact_attempts,
'mail_templates': MailTemplate.get_appointment_mail_templates(languages) 'mail_templates': MailTemplate.get_appointment_mail_templates(languages)
}) })
...@@ -12,7 +12,10 @@ def contact_add(request, subject_id): ...@@ -12,7 +12,10 @@ def contact_add(request, subject_id):
form.instance.subject_id = subject_id form.instance.subject_id = subject_id
if form.is_valid(): if form.is_valid():
form.save() form.save()
return redirect('web.views.subject_edit', id=subject_id) if 'from_appointment' in request.GET:
return redirect('web.views.appointment_edit', id=request.GET.get('from_appointment',''))
else:
return redirect('web.views.subject_edit', id=subject_id)
else: else:
form = ContactAttemptForm(user=request.user, subject=subject) form = ContactAttemptForm(user=request.user, subject=subject)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment