diff --git a/hypha/apply/categories/blocks.py b/hypha/apply/categories/blocks.py index 11a126770332d3c91317ba94a74775e0f3b40ba1..9bd9ef2974534fb3eac44a8a361291129b0dc8b4 100644 --- a/hypha/apply/categories/blocks.py +++ b/hypha/apply/categories/blocks.py @@ -78,11 +78,12 @@ class CategoryQuestionBlock(OptionalFormFieldBlock): return forms.RadioSelect def prepare_data(self, value, data, serialize): + if not data: + return data if isinstance(data, str): data = [data] category = value['category'] - if data: - data = category.options.filter(id__in=data).values_list('value', flat=True) + data = category.options.filter(id__in=data).values_list('value', flat=True) return data def get_searchable_content(self, value, data): diff --git a/hypha/apply/projects/forms/vendor.py b/hypha/apply/projects/forms/vendor.py index cde9ab79cc95b1421a5f8de782428933586b1065..961aefb4f97a8bfcb68474a6705d3a4b29e24e5b 100644 --- a/hypha/apply/projects/forms/vendor.py +++ b/hypha/apply/projects/forms/vendor.py @@ -1,14 +1,29 @@ -from babel.numbers import get_currency_name, list_currencies +import datetime +from operator import itemgetter + +from babel.core import get_global +from babel.numbers import get_currency_name, get_territory_currencies from django import forms from django_file_form.forms import FileFormMixin from addressfield.fields import AddressField from hypha.apply.stream_forms.fields import MultiFileField -# from addressfield.fields import AddressField from ..models.vendor import VendorFormSettings +def get_active_currencies(): + active_currencies = [] + territories = get_global('territory_currencies').keys() + for territory in territories: + currencies = get_territory_currencies(territory, datetime.date.today()) + if currencies: + for currency in currencies: + if currency not in active_currencies: + active_currencies.append(currencies[0]) + return active_currencies + + class BaseVendorForm: def __init__(self, site=None, *args, **kwargs): if site: @@ -67,14 +82,14 @@ class CreateVendorFormStep3(FileFormMixin, BaseVendorForm, forms.Form): class CreateVendorFormStep4(BaseVendorForm, forms.Form): CURRENCY_CHOICES = [ (currency, f'{get_currency_name(currency)} - {currency}') - for currency in list_currencies() + for currency in get_active_currencies() ] account_holder_name = forms.CharField(required=True) account_routing_number = forms.CharField(required=True) account_number = forms.CharField(required=True) account_currency = forms.ChoiceField( - choices=CURRENCY_CHOICES, + choices=sorted(CURRENCY_CHOICES, key=itemgetter(1)), required=True, initial='USD' ) @@ -100,13 +115,13 @@ class CreateVendorFormStep5(BaseVendorForm, forms.Form): class CreateVendorFormStep6(BaseVendorForm, forms.Form): CURRENCY_CHOICES = [ (currency, f'{get_currency_name(currency)} - {currency}') - for currency in list_currencies() + for currency in get_active_currencies() ] branch_address = AddressField() ib_account_routing_number = forms.CharField(required=False) ib_account_number = forms.CharField(required=False) ib_account_currency = forms.ChoiceField( - choices=CURRENCY_CHOICES, + choices=sorted(CURRENCY_CHOICES, key=itemgetter(1)), required=False, initial='USD' ) diff --git a/hypha/apply/projects/migrations/0037_rename_verbose_name_of_vendor_form_settings.py b/hypha/apply/projects/migrations/0037_rename_verbose_name_of_vendor_form_settings.py new file mode 100644 index 0000000000000000000000000000000000000000..7f83e85f56d93d64f4ab8a4e19bee18b6b6b100e --- /dev/null +++ b/hypha/apply/projects/migrations/0037_rename_verbose_name_of_vendor_form_settings.py @@ -0,0 +1,89 @@ +# Generated by Django 2.2.24 on 2021-06-18 04:54 + +from django.db import migrations, models +import wagtail.core.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('application_projects', '0036_add_vendor'), + ] + + operations = [ + migrations.AlterField( + model_name='vendorformsettings', + name='account_holder_name_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='This name must be same as the person or organisation that signed the contract. This person is authorised to sign contracts on behalf of the person or organisation named above.', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='account_number_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='Depending on your country, this might be called the account number, IBAN, or BBAN number.', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='account_routing_number_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='Depending on your country, this might be called the ACH, SWIFT, BIC or ABA number.', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='branch_address_help_text', + field=models.TextField(blank=True, default='The address of the bank branch where you have the bank account located(not the bank account holder address)', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='due_diligence_documents_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='Upload Due Diligence Documents. E.g. w8/w9 forms.', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='ib_account_currency_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='This is the currency of this bank account', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='ib_account_number_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='Depending on your country, this might be called the account number, IBAN, or BBAN number', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='ib_account_routing_number_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='Depending on your country, this might be called ACH, SWIFT, BIC or ABA number', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='ib_branch_address_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='Bank branch address(not the bank account holder address)', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='need_extra_info_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='nid_number_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='nid_type_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='This could be a passport, a National Identity number, or other national identity document.', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='other_info_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='If you need to include other information not listed above, provide it here.', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='required_to_pay_taxes_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='', verbose_name='help text'), + ), + migrations.AlterField( + model_name='vendorformsettings', + name='type_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='The name of the bank account must be the same as on the contract.', verbose_name='help text'), + ), + ] diff --git a/hypha/apply/projects/migrations/0038_rename_verbose_name_of_vendor_form_settings.py b/hypha/apply/projects/migrations/0038_rename_verbose_name_of_vendor_form_settings.py new file mode 100644 index 0000000000000000000000000000000000000000..8d7eaa03fea8c9fdfd5b974ca2c46d4d1bcdd919 --- /dev/null +++ b/hypha/apply/projects/migrations/0038_rename_verbose_name_of_vendor_form_settings.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.24 on 2021-06-18 06:27 + +from django.db import migrations +import wagtail.core.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('application_projects', '0037_rename_verbose_name_of_vendor_form_settings'), + ] + + operations = [ + migrations.AlterField( + model_name='vendorformsettings', + name='account_currency_help_text', + field=wagtail.core.fields.RichTextField(blank=True, default='This is the currency of this bank account.', verbose_name='help text'), + ), + ] diff --git a/hypha/apply/projects/models/vendor.py b/hypha/apply/projects/models/vendor.py index 2c0635646e0ee5f2dacd357cdb6160c47c373f15..887747d1d4cf30a6cb13a59f4368e65a20279627 100644 --- a/hypha/apply/projects/models/vendor.py +++ b/hypha/apply/projects/models/vendor.py @@ -42,8 +42,8 @@ class BankInformation(models.Model): class Vendor(models.Model): TYPE_CHOICES = [ - ('organization', 'Yes, the account belongs to the organisation above'), - ('personal', 'No, it is a personal bank account'), + ('organization', _('Yes, the account belongs to the organisation above')), + ('personal', _('No, it is a personal bank account')), ] user = models.OneToOneField( @@ -103,7 +103,7 @@ class VendorFormSettings(BaseSetting): default='3. Is the bank account owned by the person or organisation in the Question 1 above?' ) type_help_text = RichTextField( - 'help_text', + 'help text', blank=True, default='The name of the bank account must be the same as on the contract.' ) @@ -112,7 +112,7 @@ class VendorFormSettings(BaseSetting): default='Is the organisation required to pay US taxes?' ) required_to_pay_taxes_help_text = RichTextField( - 'help_text', + 'help text', default='', blank=True, ) due_diligence_documents_label = models.TextField( @@ -120,7 +120,7 @@ class VendorFormSettings(BaseSetting): default='Due Diligence Documents' ) due_diligence_documents_help_text = RichTextField( - 'help_text', + 'help text', blank=True, default='Upload Due Diligence Documents. E.g. w8/w9 forms.' ) @@ -129,7 +129,7 @@ class VendorFormSettings(BaseSetting): default='Bank Account Holder name' ) account_holder_name_help_text = RichTextField( - 'help_text', + 'help text', blank=True, default='This name must be same as the person or organisation that signed the contract. ' 'This person is authorised to sign contracts on behalf of the person or organisation named above.' @@ -139,7 +139,7 @@ class VendorFormSettings(BaseSetting): default='Bank Account Routing number' ) account_routing_number_help_text = RichTextField( - 'help_text', + 'help text', blank=True, default='Depending on your country, this might be called the ACH, SWIFT, BIC or ABA number.' ) @@ -148,7 +148,7 @@ class VendorFormSettings(BaseSetting): default='Bank Account Number' ) account_number_help_text = RichTextField( - 'help_text', + 'help text', blank=True, default='Depending on your country, this might be called the account number, IBAN, or BBAN number.' ) @@ -157,7 +157,7 @@ class VendorFormSettings(BaseSetting): default='Bank Account Currency' ) account_currency_help_text = RichTextField( - 'label', + 'help text', blank=True, default='This is the currency of this bank account.' ) @@ -166,7 +166,7 @@ class VendorFormSettings(BaseSetting): default='Do you need to provide us with extra information?' ) need_extra_info_help_text = RichTextField( - 'help_text', + 'help text', blank=True, default='' ) @@ -175,7 +175,7 @@ class VendorFormSettings(BaseSetting): default='Bank Account Branch Address' ) branch_address_help_text = models.TextField( - 'help_text', + 'help text', blank=True, default='The address of the bank branch where you have the bank account ' 'located(not the bank account holder address)' @@ -185,7 +185,7 @@ class VendorFormSettings(BaseSetting): default='Intermediary Bank Account Routing Number' ) ib_account_routing_number_help_text = RichTextField( - 'help_text', + 'help text', blank=True, default='Depending on your country, this might be called ACH, SWIFT, BIC or ABA number' ) @@ -194,7 +194,7 @@ class VendorFormSettings(BaseSetting): default='Intermediary Bank Account Number' ) ib_account_number_help_text = RichTextField( - 'help_text', + 'help text', blank=True, default='Depending on your country, this might be called the account number, IBAN, or BBAN number' ) @@ -203,7 +203,7 @@ class VendorFormSettings(BaseSetting): default='Intermediary Bank Account Currency' ) ib_account_currency_help_text = RichTextField( - 'help_text', + 'help text', blank=True, default='This is the currency of this bank account' ) @@ -212,7 +212,7 @@ class VendorFormSettings(BaseSetting): default='Intermediary Bank Branch Address' ) ib_branch_address_help_text = RichTextField( - 'help_text', + 'help text', blank=True, default='Bank branch address(not the bank account holder address)' ) @@ -221,7 +221,7 @@ class VendorFormSettings(BaseSetting): default='Account Holder National Identity Document Type' ) nid_type_help_text = RichTextField( - 'help_text', + 'help text', blank=True, default='This could be a passport, a National Identity number, ' 'or other national identity document.' @@ -231,7 +231,7 @@ class VendorFormSettings(BaseSetting): default='Account Holder National Identity Document Number' ) nid_number_help_text = RichTextField( - 'help_text', + 'help text', default='', blank=True, ) @@ -240,7 +240,7 @@ class VendorFormSettings(BaseSetting): default='Other Information' ) other_info_help_text = RichTextField( - 'help_text', + 'help text', blank=True, default='If you need to include other information not listed above, provide it here.' ) diff --git a/hypha/apply/projects/templates/application_projects/vendor_form.html b/hypha/apply/projects/templates/application_projects/vendor_form.html index f8e6ff33f8ce76cd00774e3c367fcc38f7dfd6a7..b10a294de961fec53b2b3176126d61532ae81744 100644 --- a/hypha/apply/projects/templates/application_projects/vendor_form.html +++ b/hypha/apply/projects/templates/application_projects/vendor_form.html @@ -1,11 +1,11 @@ {% extends "base-apply.html" %} -{% load static %} +{% load static i18n %} -{% block title %}{% if object %}Edit{% else %}Update{% endif %} Contractor{% if object %}{{ object.project.title }}{% else %}{{ project.title }}{% endif %}{% endblock %} +{% block title %}{% trans "Update Contractor Information" %}{% endblock %} {% block content %} <div class="admin-bar"> <div class="admin-bar__inner"> - <h2 class="heading heading--no-margin">Update Contractor Information</h2> + <h2 class="heading heading--no-margin">{% trans "Update Contractor Information" %}</h2> </div> </div> diff --git a/hypha/apply/projects/templates/application_projects/vendor_success.html b/hypha/apply/projects/templates/application_projects/vendor_success.html index eaa9d124af601cb676b926f8f3f3c0ca4e08afcf..27c953800d35c4a281bb0f458f492be0050a7598 100644 --- a/hypha/apply/projects/templates/application_projects/vendor_success.html +++ b/hypha/apply/projects/templates/application_projects/vendor_success.html @@ -1,16 +1,16 @@ {% extends "base-apply.html" %} -{% load static %} +{% load static i18n %} -{% block title %}Contractor Setup Completed{% endblock %} +{% block title %}{% trans "Contractor Setup Completed" %}{% endblock %} {% block content %} <div class="admin-bar"> <div class="admin-bar__inner"> - <h2 class="heading heading--no-margin">Contractor Setup Completed</h2> + <h2 class="heading heading--no-margin">{% trans "Contractor Setup Completed" %}</h2> </div> </div> <div class="wrapper wrapper--small"> <h3>Thank you for submitting your information.</h3> - <p>Your OTF Programme Manager will be in touch with you if there are any issues.</p> + <p>Your {{ ORG_SHORT_NAME }} Programme Manager will be in touch with you if there are any issues.</p> <h3>What will happen next?</h3> <p>We will use this information to create the contract for your project.</p> <p>Once this has happened, we will send you a message with your contract.</p> diff --git a/hypha/locale/en/LC_MESSAGES/django.po b/hypha/locale/en/LC_MESSAGES/django.po index 9eb83c22ac2fba9809fd9e528a893579cf30f73b..592a6499c0f0f4f1384e9cf48a5a68a9f2206ad7 100644 --- a/hypha/locale/en/LC_MESSAGES/django.po +++ b/hypha/locale/en/LC_MESSAGES/django.po @@ -2470,3 +2470,19 @@ msgstr "" #: hypha/templates/blocks/apply_link_block.html:4 msgid "Apply for the" msgstr "" + +#: hypha/apply/projects/templates/application_projects/vendor_form.html:4,8 +msgid "Update Contractor Information" +msgstr "" + +#: hypha/apply/projects/templates/application_projects/vendor_success.html:4,8 +msgid "Contractor Setup Completed" +msgstr "" + +#: hypha/apply/projects/models/vendor.py:45 +msgid "Yes, the account belongs to the organisation above" +msgstr "" + +#: hypha/apply/projects/models/vendor.py:46 +msgid "No, it is a personal bank account" +msgstr ""