Commit b9bbb41d authored by Gladys Forte's avatar Gladys Forte

Merge pull request #760 in RMS/api-main-service from core-dev-gladys to RMSv2

* commit 'f4a51fcb':
  {dev bugfix} added separate validation for checking of atleast 1 approver
parents cf31da83 f4a51fcb
...@@ -76,6 +76,8 @@ from django.http import HttpResponse ...@@ -76,6 +76,8 @@ from django.http import HttpResponse
from xhtml2pdf import pisa from xhtml2pdf import pisa
from app.helper.decorators import * from app.helper.decorators import *
from app.applicationlayer.utils import error_message
config = configparser.ConfigParser() config = configparser.ConfigParser()
config_file = os.path.join('./', 'env.ini') config_file = os.path.join('./', 'env.ini')
...@@ -880,6 +882,13 @@ class ChangeRequestFormsViewset(viewsets.ModelViewSet): ...@@ -880,6 +882,13 @@ class ChangeRequestFormsViewset(viewsets.ModelViewSet):
form_code = kwargs['form_code'] form_code = kwargs['form_code']
form_data = request.data form_data = request.data
# Restrict a requestor to submit a CR without atleast 1 approver
counter = change_request_template.validation_existing_approver(
form_data['frm_approvers'])
if counter == 0:
return error_message('400', 'Please select at least 1 approver before submitting this request.',
'failed', status.HTTP_400_BAD_REQUEST)
# generate batchno history # generate batchno history
batchno = get_max_batchno("batch") batchno = get_max_batchno("batch")
......
# Generated by Django 2.2 on 2020-02-05 17:07
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('entities', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='changerequestformattachments',
name='file_upload',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.PROTECT, related_name='form_attachments', to='entities.MasterAttachment'),
preserve_default=False,
),
migrations.AlterField(
model_name='changerequesttemplateattachments',
name='file_upload',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.PROTECT, related_name='template_attachments', to='entities.MasterAttachment'),
preserve_default=False,
),
]
...@@ -707,9 +707,7 @@ class ChangeRequestTemplateAttachments(BaseAttachment): ...@@ -707,9 +707,7 @@ class ChangeRequestTemplateAttachments(BaseAttachment):
file_upload = models.ForeignKey( file_upload = models.ForeignKey(
MasterAttachment, MasterAttachment,
on_delete=models.PROTECT, on_delete=models.PROTECT,
related_name='template_attachments', related_name='template_attachments'
blank=True,
null=True
) )
template_no = models.ForeignKey( template_no = models.ForeignKey(
ChangeRequestTemplateHeader, ChangeRequestTemplateHeader,
...@@ -936,9 +934,7 @@ class ChangeRequestFormAttachments(BaseAttachment): ...@@ -936,9 +934,7 @@ class ChangeRequestFormAttachments(BaseAttachment):
file_upload = models.ForeignKey( file_upload = models.ForeignKey(
MasterAttachment, MasterAttachment,
on_delete=models.PROTECT, on_delete=models.PROTECT,
related_name='form_attachments', related_name='form_attachments'
blank=True,
null=True
) )
class Meta: class Meta:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment