Skip to content
Snippets Groups Projects
Commit c0070e26 authored by Valentin Groues's avatar Valentin Groues :eyes:
Browse files

Merge branch '223-voucher-should-have-optional-activy-type-free-text' into 'master'

Resolve "voucher should have optional activy type (free text)"

Closes #223

See merge request NCER-PD/scheduling-system!151
parents 56d698dc 0302719f
No related branches found
No related tags found
1 merge request!151Resolve "voucher should have optional activy type (free text)"
Pipeline #6296 failed
......@@ -57,6 +57,7 @@ class VoucherForm(ModelForm):
if instance and instance.pk:
self.fields['voucher_type'].widget.attrs['readonly'] = True
self.fields['hours'].widget.attrs['readonly'] = True
self.fields['activity_type'].widget.attrs['readonly'] = True
self.fields['usage_partner'].widget.attrs['readonly'] = True
if instance.status in [VOUCHER_STATUS_USED, VOUCHER_STATUS_EXPIRED]:
......
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-07-17 12:54
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('web', '0116_auto_20180611_1346'),
]
operations = [
migrations.AddField(
model_name='voucher',
name='activity_type',
field=models.CharField(blank=True, default=b'', max_length=40, verbose_name=b'Activity type'),
),
]
......@@ -291,10 +291,13 @@ class MailTemplate(models.Model):
@staticmethod
def get_voucher_replacements(voucher):
if voucher is not None:
voucher_type = voucher.voucher_type.description
if voucher.activity_type != '':
voucher_type += ' (' + voucher.activity_type + ")"
return {
"##C_NUMBER##": voucher.number,
"##C_PATIENT_NAME##": voucher.study_subject.subject.first_name + ' ' + voucher.study_subject.subject.last_name,
"##C_VOUCHER_TYPE##": voucher.voucher_type.description,
"##C_VOUCHER_TYPE##": voucher_type,
"##C_ISSUE_DATE_SHORT##": voucher.issue_date.strftime(DATE_FORMAT_SHORT).decode(date_format_encoding()),
"##C_EXPIRY_START_SHORT##": voucher.expiry_date.strftime(DATE_FORMAT_SHORT).decode(
date_format_encoding()),
......
......@@ -48,6 +48,13 @@ class Voucher(models.Model):
default=VOUCHER_STATUS_NEW
)
activity_type = models.CharField(max_length=40,
verbose_name='Activity type',
null=False,
blank=True,
default=''
)
feedback = models.TextField(max_length=2000,
blank=True,
verbose_name='Feedback'
......
......@@ -147,6 +147,21 @@ class MailTemplateModelTests(TestCase):
voucher.issue_date.strftime(DATE_FORMAT_SHORT)
])
def test_valid_voucher_replacement(self):
subject = create_study_subject()
voucher = create_voucher(study_subject=subject)
voucher.activity_type = 'act type'
replacements = MailTemplate.get_voucher_replacements(voucher)
activity_type_in_replacements = False
for key in replacements:
self.assertIsNotNone(key)
self.assertIsNotNone(replacements[key], msg="None value for key: " + key)
if voucher.activity_type in replacements[key]:
activity_type_in_replacements = True
self.assertTrue(activity_type_in_replacements)
def test_valid_subject_replacement(self):
subject = create_study_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