diff --git a/hypha/apply/dashboard/views.py b/hypha/apply/dashboard/views.py index 54cd30706ad98849d4c5a73bb586107fc5e9d9d3..3be519e7f58a645468b84bbb2185f7969a74f708 100644 --- a/hypha/apply/dashboard/views.py +++ b/hypha/apply/dashboard/views.py @@ -295,7 +295,7 @@ class ApplicantDashboardView(MultiTableMixin, TemplateView): return context def active_project_data(self, user): - return Project.objects.filter(vendor__user=user).active().for_table() + return Project.objects.filter(user=user).active().for_table() def my_active_submissions(self, user): active_subs = ApplicationSubmission.objects.filter( @@ -306,7 +306,7 @@ class ApplicantDashboardView(MultiTableMixin, TemplateView): yield submission.from_draft() def historical_project_data(self, user): - return Project.objects.filter(vendor__user=user).complete().for_table() + return Project.objects.filter(user=user).complete().for_table() def historical_submission_data(self, user): return ApplicationSubmission.objects.filter( diff --git a/hypha/apply/projects/forms/vendor.py b/hypha/apply/projects/forms/vendor.py index 7105da9d881be44a4e6b4193c29eb30d2db9800d..0edcdd25c79ca5c3df06d033429079d299cff0ee 100644 --- a/hypha/apply/projects/forms/vendor.py +++ b/hypha/apply/projects/forms/vendor.py @@ -6,7 +6,7 @@ from hypha.apply.stream_forms.fields import MultiFileField from django_file_form.forms import FileFormMixin # from addressfield.fields import AddressField -from ..models.vendor import Vendor, VendorFormSettings +from ..models.vendor import VendorFormSettings class BaseVendorForm: @@ -29,21 +29,18 @@ class BaseVendorForm: class CreateVendorFormStep1(BaseVendorForm, forms.Form): - class Meta: - fields = [ - 'name', - 'contractor_name', - 'type', - ] - model = Vendor - widgets = { - 'type': forms.RadioSelect, - } + TYPE_CHOICES = [ + ('organization', 'Yes, the account belongs to the organisation above'), + ('personal', 'No, it is a personal bank account'), + ] + + name = forms.CharField(required=True) + contractor_name = forms.CharField(required=True) + type = forms.ChoiceField(choices=TYPE_CHOICES, required=True, widget=forms.RadioSelect) def __init__(self, *args, **kwargs): super(CreateVendorFormStep1, self).__init__(*args, **kwargs) self.fields = self.apply_form_settings(self.fields) - self.fields['type'].choices = self.fields['type'].choices[1:] class CreateVendorFormStep2(BaseVendorForm, forms.Form): @@ -60,7 +57,7 @@ class CreateVendorFormStep2(BaseVendorForm, forms.Form): class CreateVendorFormStep3(FileFormMixin, BaseVendorForm, forms.Form): - due_diligence_documents = MultiFileField(required=False) + due_diligence_documents = MultiFileField(required=True) def __init__(self, *args, **kwargs): super(CreateVendorFormStep3, self).__init__(*args, **kwargs) @@ -73,12 +70,12 @@ class CreateVendorFormStep4(BaseVendorForm, forms.Form): for currency in list_currencies() ] - account_holder_name = forms.CharField(required=False) - account_routing_number = forms.CharField(required=False) - account_number = forms.CharField(required=False) + 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, - required=False, + required=True, initial='USD' ) diff --git a/hypha/apply/projects/models/project.py b/hypha/apply/projects/models/project.py index 7057702dbc6dda3ae452a6b3660c0fd4d01a1dad..2ff288edf54bf46dcceab891955f8cf66f539924 100644 --- a/hypha/apply/projects/models/project.py +++ b/hypha/apply/projects/models/project.py @@ -209,7 +209,6 @@ class Project(BaseStreamForm, AccessFormData, models.Model): # See if there is a form field named "legal name", if not use user name. legal_name = submission.get_answer_from_label('legal name') or submission.user.full_name - # import ipdb; ipdb.set_trace() vendor, _ = Vendor.objects.get_or_create( user=submission.user ) diff --git a/hypha/apply/projects/models/vendor.py b/hypha/apply/projects/models/vendor.py index 57c9c831381c4e9a506895ddbf98838d2dc29ffe..f33a11dac8c426072d537758990fc941725b2a16 100644 --- a/hypha/apply/projects/models/vendor.py +++ b/hypha/apply/projects/models/vendor.py @@ -107,6 +107,7 @@ class VendorFormSettings(BaseSetting): ) type_help_text = RichTextField( 'help_text', + blank=True, default='The name of the bank account must be the same as on the contract.' ) required_to_pay_taxes_label = models.TextField( @@ -123,6 +124,7 @@ class VendorFormSettings(BaseSetting): ) due_diligence_documents_help_text = RichTextField( 'help_text', + blank=True, default='Upload Due Diligence Documents. E.g. w8/w9 forms.' ) account_holder_name_label = models.TextField( @@ -131,6 +133,7 @@ class VendorFormSettings(BaseSetting): ) account_holder_name_help_text = RichTextField( '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.' ) @@ -140,6 +143,7 @@ class VendorFormSettings(BaseSetting): ) account_routing_number_help_text = RichTextField( 'help_text', + blank=True, default='Depending on your country, this might be called the ACH, SWIFT, BIC or ABA number.' ) account_number_label = models.TextField( @@ -148,6 +152,7 @@ class VendorFormSettings(BaseSetting): ) account_number_help_text = RichTextField( 'help_text', + blank=True, default='Depending on your country, this might be called the account number, IBAN, or BBAN number.' ) account_currency_label = models.TextField( @@ -156,6 +161,7 @@ class VendorFormSettings(BaseSetting): ) account_currency_help_text = RichTextField( 'label', + blank=True, default='This is the currency of this bank account.' ) need_extra_info_label = models.TextField( @@ -164,6 +170,7 @@ class VendorFormSettings(BaseSetting): ) need_extra_info_help_text = RichTextField( 'help_text', + blank=True, default='' ) branch_address_label = models.TextField( @@ -172,6 +179,7 @@ class VendorFormSettings(BaseSetting): ) branch_address_help_text = models.TextField( 'help_text', + blank=True, default='The address of the bank branch where you have the bank account ' 'located(not the bank account holder address)' ) @@ -181,6 +189,7 @@ class VendorFormSettings(BaseSetting): ) ib_account_routing_number_help_text = RichTextField( 'help_text', + blank=True, default='Depending on your country, this might be called ACH, SWIFT, BIC or ABA number' ) ib_account_number_label = models.TextField( @@ -189,6 +198,7 @@ class VendorFormSettings(BaseSetting): ) ib_account_number_help_text = RichTextField( 'help_text', + blank=True, default='Depending on your country, this might be called the account number, IBAN, or BBAN number' ) ib_account_currency_label = models.TextField( @@ -197,6 +207,7 @@ class VendorFormSettings(BaseSetting): ) ib_account_currency_help_text = RichTextField( 'help_text', + blank=True, default='This is the currency of this bank account' ) ib_branch_address_label = models.TextField( @@ -205,6 +216,7 @@ class VendorFormSettings(BaseSetting): ) ib_branch_address_help_text = RichTextField( 'help_text', + blank=True, default='Bank branch address(not the bank account holder address)' ) nid_type_label = models.TextField( @@ -213,6 +225,7 @@ class VendorFormSettings(BaseSetting): ) nid_type_help_text = RichTextField( 'help_text', + blank=True, default='This could be a passport, a National Identity number, ' 'or other national identity document.' ) @@ -222,7 +235,8 @@ class VendorFormSettings(BaseSetting): ) nid_number_help_text = RichTextField( 'help_text', - default='' + default='', + blank=True, ) other_info_label = models.TextField( 'label', @@ -230,6 +244,7 @@ class VendorFormSettings(BaseSetting): ) other_info_help_text = RichTextField( 'help_text', + blank=True, default='If you need to include other information not listed above, provide it here.' ) @@ -268,7 +283,7 @@ class VendorFormSettings(BaseSetting): ], 'Account Number'), MultiFieldPanel([ FieldPanel('account_currency_label'), - FieldPanel('account_currency_label'), + FieldPanel('account_currency_help_text'), ], 'Account Currency'), MultiFieldPanel([ FieldPanel('need_extra_info_label'), diff --git a/hypha/apply/projects/templates/application_projects/includes/supporting_documents.html b/hypha/apply/projects/templates/application_projects/includes/supporting_documents.html index c6726b2b0be4c6ea6c308ea57e50b37eae95a2bb..f8b7a96c3538714b6236cc10af10b1118f07e37a 100644 --- a/hypha/apply/projects/templates/application_projects/includes/supporting_documents.html +++ b/hypha/apply/projects/templates/application_projects/includes/supporting_documents.html @@ -26,7 +26,7 @@ <p class="docs-block__title">Contractor Setup Form</p> </div> <div class="docs-block__row-inner"> - <a class="docs-block__link" href="{% url 'apply:projects:vendor' pk=project.pk %}">Complete Contractor Setup</a> + <a class="docs-block__link" href="{% url 'apply:projects:vendor' pk=project.pk %}">Add info</a> </div> </li> diff --git a/hypha/apply/projects/templates/application_projects/vendor_form.html b/hypha/apply/projects/templates/application_projects/vendor_form.html index fc44c29f1b923f1494fc9b72ae30c40ef3bcbaa2..9c43819661560de88e846212f81a040ea8b80361 100644 --- a/hypha/apply/projects/templates/application_projects/vendor_form.html +++ b/hypha/apply/projects/templates/application_projects/vendor_form.html @@ -6,7 +6,6 @@ <div class="admin-bar"> <div class="admin-bar__inner"> <h2 class="heading heading--no-margin">{% if object %}Editing{% else %}Setup{% endif %} Contractor Information</h2> - <h5 class="heading heading--no-margin">{% if object %}{{ object.project.title }}{% else %}{{ project.title }}{% endif %}</h5> </div> </div> diff --git a/hypha/apply/projects/views/vendor.py b/hypha/apply/projects/views/vendor.py index 4efd239e898d32111c42eab27b061a7fdbc6de71..41c835cc64a0d04bdac73a32a7e6ccad72cf113a 100644 --- a/hypha/apply/projects/views/vendor.py +++ b/hypha/apply/projects/views/vendor.py @@ -28,14 +28,14 @@ def show_extra_info_form(wizard): class VendorAccessMixin: def dispatch(self, request, *args, **kwargs): is_admin = request.user.is_apply_staff - is_owner = request.user == self.get_object().project.user + is_owner = request.user == self.get_project().user if not (is_owner or is_admin): raise PermissionDenied return super().dispatch(request, *args, **kwargs) -class CreateVendorView(SessionWizardView): +class CreateVendorView(VendorAccessMixin, SessionWizardView): file_storage = PrivateStorage() form_list = [ ('basic', CreateVendorFormStep1), @@ -54,12 +54,7 @@ class CreateVendorView(SessionWizardView): def done(self, form_list, **kwargs): vendor_project = self.get_project() cleaned_data = self.get_all_cleaned_data() - vendor, create = Vendor.objects.get_or_create( - user=vendor_project.user - ) - if create: - vendor_project.vendor = vendor - vendor_project.save() + vendor = vendor_project.vendor need_extra_info = cleaned_data['need_extra_info'] bank_information = BankInformation.objects.create( account_holder_name=cleaned_data['account_holder_name'], diff --git a/hypha/apply/templates/forms/includes/field.html b/hypha/apply/templates/forms/includes/field.html index 77b96d800d8a210f5c53a671c9c625030f73943c..4d69a78e767211a5b7b86b9e9c4dfa94c23e5c7f 100644 --- a/hypha/apply/templates/forms/includes/field.html +++ b/hypha/apply/templates/forms/includes/field.html @@ -1,4 +1,4 @@ -{% load util_tags wagtailadmin_tags %} +{% load util_tags %} {% with widget_type=field|widget_type field_type=field|field_type %} <div class="form__group {% if widget_type == 'checkbox_input' %} form__group--checkbox{% endif %}{% if widget_type == 'clearable_file_input' or widget_type == 'multi_file_input' or widget_type == 'single_file_field_widget' or widget_type == 'multi_file_field_widget' %} form__group--file{% endif %}{% if field.help_text %} form__group--wrap{% endif %}{% if field.errors %} form__error{% endif %}{% if is_application and field.field.group_number > 1 %} field-group field-group-{{ field.field.group_number }}{% endif %}{% if is_application and field.field.grouper_for %} form-fields-grouper{% endif %}"{% if is_application and field.field.grouper_for %}data-grouper-for="{{ field.field.grouper_for }}" data-toggle-on="{{ field.field.choices.0.0 }}" data-toggle-off="{{ field.field.choices.1.0 }}"{% endif %}{% if is_application and field.field.group_number > 1 %} data-hidden="{% if not show_all_group_fields and not field.field.visible %}true{% else %}false{% endif %}" data-required="{{ field.field.required_when_visible }}"{% endif %}{% if field.field.word_limit %} data-word-limit="{{ field.field.word_limit }}"{% endif %}> diff --git a/hypha/static_src/src/javascript/apply/file-uploads.js b/hypha/static_src/src/javascript/apply/file-uploads.js index 5e3826a16169c4bd215967501267ac7f27aff235..34750a5293228b752fc611dcc15e62ecf6f3eb1a 100644 --- a/hypha/static_src/src/javascript/apply/file-uploads.js +++ b/hypha/static_src/src/javascript/apply/file-uploads.js @@ -24,8 +24,8 @@ jQuery(function ($) { // Initilise multi-step wizard forms function initWizard(form) { - const step = form.querySelector('[name=create_vendor_view-current_step]').value - if (step === "documents"){ + const step = form.querySelector('[name=create_vendor_view-current_step]').value; + if (step === 'documents') { window.initUploadFields( form, {