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

Merge branch '20-mail-templates' into 'master'

Resolve "Automatic post mail creation"

Closes #20

See merge request !45
parents 704051a5 be760fa3
No related branches found
No related tags found
1 merge request!45Resolve "Automatic post mail creation"
Pipeline #
Showing
with 582 additions and 14 deletions
<div class="box box-success">
<div class="box-header with-border">
<h3>Generate Mail</h3>
</div>
<div class="box-body">
<h4>Available templates:</h4>
<p>
{% for mail_template in mail_templates.0 %}
<a href="{% url "web.views.mail_template_generate" mail_template.id instance_id %}"
class="btn btn-app">
<i class="fa"> {% autoescape off %}{{ mail_template.language.image_img }}{% endautoescape %}</i>
{{ mail_template.name }}
</a>
{% endfor %}
</p>
<h4>Unavailable templates:</h4>
<p>
{% for mail_template in mail_templates.1 %}
<span
class="btn btn-app disabled">
<i class="fa"> {% autoescape off %}{{ mail_template.language.image_img }}{% endautoescape %}</i>
{{ mail_template.name }}
</span>
{% endfor %}
<p></p>
</div>
</div>
\ No newline at end of file
{% extends "languages/add_edit.html" %}
{% block page_header %}New language{% endblock page_header %}
{% block title %}{{ block.super }} - Add new language{% endblock %}
{% block form-title %}Enter language §details{% endblock %}
{% block save-button %}Add{% endblock %}
{% extends "_base.html" %}
{% load static %}
{% load filters %}
{% block styles %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/awesomplete/awesomplete.css' %}"/>
{% endblock styles %}
{% block ui_active_tab %}'configuration'{% endblock ui_active_tab %}
{% block page_description %}{% endblock page_description %}
{% block breadcrumb %}
{% include "languages/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">{% block form-title %}Enter language details{% endblock %}</h3>
</div>
<form method="post" action="" class="form-horizontal" enctype="multipart/form-data">
{% csrf_token %}
<div class="box-body">
{% for field in form %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
<label class="col-sm-4 col-lg-offset-1 col-lg-2 control-label">
{{ field.label }}
</label>
<div class="col-sm-8 col-lg-4">
{{ field|add_class:'form-control' }}
{% if field.errors %}
<span class="help-block">{{ field.errors }}</span>
{% endif %}
</div>
</div>
{% endfor %}
</div><!-- /.box-body -->
<div class="box-footer">
<div class="col-sm-6">
<button type="submit" class="btn btn-block btn-success">{% block save-button %}
Add{% endblock %}
</button>
</div>
<div class="col-sm-6">
<a href="{% url 'web.views.languages' %}"
class="btn btn-block btn-default">Cancel</a>
</div>
</div><!-- /.box-footer -->
</form>
</div>
</div>
</div>
{% endblock %}
{% endblock maincontent %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'AdminLTE/plugins/awesomplete/awesomplete.min.js' %}"></script>
{% endblock scripts %}
\ No newline at end of file
<li><a href="{% url 'web.views.appointments' %}"><i class="fa fa-dashboard"></i> Dashboard</a></li>
<li class="active"><a href="{% url 'web.views.languages' %}">Languages</a></li>
\ No newline at end of file
{% extends "_base.html" %}
{% load static %}
{% load filters %}
{% block styles %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/awesomplete/awesomplete.css' %}"/>
{% endblock styles %}
{% block ui_active_tab %}'configuration'{% endblock ui_active_tab %}
{% block page_header %}Delete language{% endblock page_header %}
{% block page_description %}{% endblock page_description %}
{% block title %}{{ block.super }} - Delete language{% endblock %}
{% block breadcrumb %}
{% include "languages/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Confirm deletion</h3>
</div>
<form action="" method="post" class="form-horizontal">{% csrf_token %}
<div class="box-body">
<p>Are you sure you want to delete language "{{ object.name }}"?</p>
</div><!-- /.box-body -->
<div class="box-footer">
<div class="col-sm-6">
<button type="submit" class="btn btn-block btn-danger">Delete</button>
</div>
<div class="col-sm-6">
<a href="{% url 'web.views.languages' %}"
class="btn btn-block btn-default">Cancel</a>
</div>
</div><!-- /.box-footer -->
</form>
</div>
</div>
</div>
{% endblock %}
{% endblock maincontent %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'AdminLTE/plugins/awesomplete/awesomplete.min.js' %}"></script>
{% endblock scripts %}
{% extends "mail_templates/add_edit.html" %}
{% block page_header %}Edit language "{{ language.name }}"{% endblock page_header %}
{% block title %}{{ block.super }} - Edit language "{{ language.name }}"{% endblock %}
{% block form-title %}Enter language details{% endblock %}
{% block save-button %}Save{% endblock %}
{% extends "_base.html" %}
{% load static %}
{% block styles %}
{{ block.super }}
<!-- DataTables -->
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}">
{% endblock styles %}
{% block ui_active_tab %}'configuration'{% endblock ui_active_tab %}
{% block page_header %}Languages{% endblock page_header %}
{% block page_description %}{% endblock page_description %}
{% block breadcrumb %}
{% include "languages/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
<div>
<a class="btn btn-app" href="{% url 'web.views.language_add' %}">
<i class="fa fa-plus"></i> Add new language
</a>
</div>
<div class="box-body">
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Flag</th>
<th>Order</th>
<th>Locale</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
{% for language in languages %}
<tr>
<td>{{ language.id }}</td>
<td>{{ language.name }}</td>
<td>{% autoescape off %}{{ language.image_img }}{% endautoescape %}</td>
<td>{{ language.order }}</td>
<td>{{ language.locale }}</td>
<td><a href="{% url 'web.views.language_edit' language.id %}"><i
class="fa fa-edit"></i></a></td>
<td><a href="{% url 'web.views.language_delete' language.id %}"><i
class="fa fa-trash text-danger"></i></a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock maincontent %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'AdminLTE/plugins/datatables/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.min.js' %}"></script>
<script>
$(function () {
$('#table').DataTable({
"paging": true,
"lengthChange": false,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": false
});
});
</script>
{% endblock scripts %}
{% extends "mail_templates/add_edit.html" %}
{% block page_header %}New mail template{% endblock page_header %}
{% block title %}{{ block.super }} - Add new mail template{% endblock %}
{% block form-title %}Enter mail template details{% endblock %}
{% block save-button %}Add{% endblock %}
\ No newline at end of file
{% extends "_base.html" %}
{% load static %}
{% load filters %}
{% block styles %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/awesomplete/awesomplete.css' %}"/>
{% endblock styles %}
{% block ui_active_tab %}'subjects'{% endblock ui_active_tab %}
{% block page_description %}{% endblock page_description %}
{% block breadcrumb %}
{% include "mail_templates/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">{% block form-title %}Enter mail template details{% endblock %}</h3>
</div>
<form method="post" action="" class="form-horizontal" enctype="multipart/form-data">
{% csrf_token %}
<div class="box-body">
{% for field in form %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
<label class="col-sm-4 col-lg-offset-1 col-lg-2 control-label">
{{ field.label }}
</label>
<div class="col-sm-8 col-lg-4">
{{ field|add_class:'form-control' }}
{% if field.errors %}
<span class="help-block">{{ field.errors }}</span>
{% endif %}
</div>
</div>
{% endfor %}
</div><!-- /.box-body -->
<div class="box-footer">
<div class="col-sm-6">
<button type="submit" class="btn btn-block btn-success">{% block save-button %}
Add{% endblock %}</button>
</div>
<div class="col-sm-6">
<a href="{% url 'web.views.mail_templates' %}"
class="btn btn-block btn-default">Cancel</a>
</div>
</div><!-- /.box-footer -->
</form>
</div>
</div>
</div>
{% endblock %}
{% endblock maincontent %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'AdminLTE/plugins/awesomplete/awesomplete.min.js' %}"></script>
{% endblock scripts %}
\ No newline at end of file
{% extends "_base.html" %}
{% load static %}
{% load filters %}
{% block styles %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/awesomplete/awesomplete.css' %}"/>
{% endblock styles %}
{% block ui_active_tab %}'subjects'{% endblock ui_active_tab %}
{% block page_header %}Delete mail template{% endblock page_header %}
{% block page_description %}{% endblock page_description %}
{% block title %}{{ block.super }} - Delete mail template{% endblock %}
{% block breadcrumb %}
{% include "mail_templates/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Confirm deletion</h3>
</div>
<form action="" method="post" class="form-horizontal">{% csrf_token %}
<div class="box-body">
<p>Are you sure you want to delete mail template "{{ object.name }}"?</p>
</div><!-- /.box-body -->
<div class="box-footer">
<div class="col-sm-6">
<button type="submit" class="btn btn-block btn-danger">Delete</button>
</div>
<div class="col-sm-6">
<a href="{% url 'web.views.mail_templates' %}"
class="btn btn-block btn-default">Cancel</a>
</div>
</div><!-- /.box-footer -->
</form>
</div>
</div>
</div>
{% endblock %}
{% endblock maincontent %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'AdminLTE/plugins/awesomplete/awesomplete.min.js' %}"></script>
{% endblock scripts %}
{% extends "mail_templates/add_edit.html" %}
{% block page_header %}Edit mail template "{{ mail_template.name }}"{% endblock page_header %}
{% block title %}{{ block.super }} - Edit mail template "{{ mail_template.name }}"{% endblock %}
{% block form-title %}Enter mail template details{% endblock %}
{% block save-button %}Save{% endblock %}
{% extends "_base.html" %}
{% load static %}
{% block styles %}
{{ block.super }}
<!-- DataTables -->
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}">
{% endblock styles %}
{% block ui_active_tab %}'mail_templates'{% endblock ui_active_tab %}
{% block page_header %}Mail templates{% endblock page_header %}
{% block page_description %}{% endblock page_description %}
{% block breadcrumb %}
{% include "mail_templates/breadcrumb.html" %}
{% endblock breadcrumb %}
{% block maincontent %}
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Templates</h3>
</div>
<div class="box-body">
<div>
<a class="btn btn-app" href="{% url 'web.views.mail_template_add' %}">
<i class="fa fa-plus"></i> Add new template
</a>
</div>
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<th>No.</th>
<th>Context</th>
<th>Language</th>
<th>Name</th>
<th>Download</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
{% for mail_template in mail_templates %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ mail_template.get_context_display }}</td>
<td>{% autoescape off %}{{ mail_template.language.image_img }}{% endautoescape %}</td>
<td>{{ mail_template.name }}</td>
<td><a href="{{ mail_template.template_file.url }}"><i class="fa fa-download"></i></a></td>
<td><a href="{% url 'web.views.mail_template_edit' mail_template.id %}"><i
class="fa fa-edit"></i></a></td>
<td><a href="{% url 'web.views.mail_template_delete' mail_template.id %}"><i
class="fa fa-trash text-danger"></i></a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Tags <i class="fa fa-question-circle"></i></h3>
</div>
<div class="box-body">
<p>The following tags can be used within the Word documents and will be replaced by actual values during the
mail generation.</p>
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<th>Placeholder</th>
<th>Description</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
{% for name, tags in explanations.items %}
<tr>
<td class="table-separator" colspan="3">{{ name | title }}</td>
</tr>
{% for tag in tags %}
<tr>
<td>{{ tag.0 }}</td>
<td>{{ tag.1 }}</td>
<td>{{ tag.2 }}</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock maincontent %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'AdminLTE/plugins/datatables/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.min.js' %}"></script>
<script>
$(function () {
$('#table').DataTable({
"paging": true,
"lengthChange": false,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": false
});
});
</script>
{% endblock scripts %}
...@@ -57,12 +57,19 @@ ...@@ -57,12 +57,19 @@
<span>Export</span> <span>Export</span>
</a> </a>
</li> </li>
<li data-desc="configuration" class="treeview">
<li data-desc="configuration"> <a href="#">
<a href="{% url 'web.views.configuration' %}"> <i class="fa fa-wrench"></i> <span>Configuration</span>
<i class="fa fa-wrench"></i> <span class="pull-right-container">
<span>Configuration</span> <i class="fa fa-angle-left pull-right"></i>
</span>
</a> </a>
<ul class="treeview-menu">
<li><a href="{% url 'web.views.configuration' %}">General</a></li>
<li>
<a href="{% url 'web.views.languages' %}">Languages</a>
</li>
</ul>
</li> </li>
</ul> </ul>
\ No newline at end of file
...@@ -70,10 +70,15 @@ ...@@ -70,10 +70,15 @@
<div class="box-footer"> <div class="box-footer">
<div class="col-sm-6"> <div class="col-sm-4">
<button type="submit" class="btn btn-block btn-success">Save</button> <button type="submit" class="btn btn-block btn-success">Save</button>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-4">
<button id="save-and-continue" type="button" class="btn btn-block btn-success">Save and
Continue
</button>
</div>
<div class="col-sm-4">
<a href="{% url 'web.views.subjects' %}" class="btn btn-block btn-default" <a href="{% url 'web.views.subjects' %}" class="btn btn-block btn-default"
onclick="history.back()">Cancel</a> onclick="history.back()">Cancel</a>
</div> </div>
...@@ -82,6 +87,9 @@ ...@@ -82,6 +87,9 @@
</div><!-- /.box --> </div><!-- /.box -->
</div><!-- /.col-md-12 --> </div><!-- /.col-md-12 -->
</div><!-- /.row --> </div><!-- /.row -->
{% include 'includes/mail_templates_box.html' with instance_id=subject.id %}
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<div class="box box-success"> <div class="box box-success">
...@@ -123,6 +131,8 @@ ...@@ -123,6 +131,8 @@
</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">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
</div><!-- /.box-body --> </div><!-- /.box-body -->
<div class="box-footer"> <div class="box-footer">
<div class="col-sm-12"> <div class="col-sm-12">
<button type="submit" class="btn btn-block btn-success">Save</button> <button type="submit" class="btn btn-block btn-success">Save and continue</button>
</div> </div>
</div><!-- /.box-footer --> </div><!-- /.box-footer -->
</form> </form>
...@@ -182,11 +182,11 @@ ...@@ -182,11 +182,11 @@
</form> </form>
</div> </div>
</form> {% include 'includes/mail_templates_box.html' with instance_id=visit.id %}
{% endblock %} {% endblock %}
</div>
{% endblock maincontent %} {% endblock maincontent %}
......
import os
from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.test import Client from django.test import Client
from django.test import TestCase from django.test import TestCase
from functions import create_worker from functions import create_worker
settings.MEDIA_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')
class LoggedInTestCase(TestCase): class LoggedInTestCase(TestCase):
def setUp(self): def setUp(self):
......
File added
File added
import datetime import datetime
import os
from django.contrib.auth.models import User from django.contrib.auth.models import User
from web.models import Location, AppointmentType, Subject, Worker, Visit, Appointment, ConfigurationItem from web.models import Location, AppointmentType, Subject, Worker, Visit, Appointment, ConfigurationItem, Language
from web.models.constants import SEX_CHOICES_MALE, SUBJECT_TYPE_CHOICES_CONTROL from web.models.constants import SEX_CHOICES_MALE, SUBJECT_TYPE_CHOICES_CONTROL
from web.views.notifications import get_today_midnight_date from web.views.notifications import get_today_midnight_date
...@@ -42,7 +43,8 @@ def create_subject(id=1): ...@@ -42,7 +43,8 @@ def create_subject(id=1):
sex=SEX_CHOICES_MALE, sex=SEX_CHOICES_MALE,
type=SUBJECT_TYPE_CHOICES_CONTROL, type=SUBJECT_TYPE_CHOICES_CONTROL,
screening_number="piotr's number" + str(id), screening_number="piotr's number" + str(id),
country="france") country="france"
)
def create_user(username=None, password=None): def create_user(username=None, password=None):
...@@ -84,6 +86,8 @@ def create_visit(subject=None): ...@@ -84,6 +86,8 @@ def create_visit(subject=None):
def create_appointment(visit=None, when=None): def create_appointment(visit=None, when=None):
if visit is None: if visit is None:
visit = create_visit() visit = create_visit()
# if when is None:
# when = get_today_midnight_date()
return Appointment.objects.create( return Appointment.objects.create(
visit=visit, visit=visit,
length=30, length=30,
...@@ -97,4 +101,14 @@ def create_configuration_item(): ...@@ -97,4 +101,14 @@ def create_configuration_item():
item.value = "xxx" item.value = "xxx"
item.name = "yyy" item.name = "yyy"
item.save() item.save()
return item; return item
def create_language(name="French", locale="fr_FR"):
language = Language(name=name, locale=locale)
language.save()
return language
def get_resource_path(filename):
return os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data', filename)
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
from django.core import mail from django.core import mail
from django.test import TestCase from django.test import TestCase
from web.email import EmailSender from web.smash_email import EmailSender
class TestEmailSender(TestCase): class TestEmailSender(TestCase):
......
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