Skip to content

Commit

Permalink
EDA-1159: As a buyer, I want to be able to see the list of approved O…
Browse files Browse the repository at this point in the history
…rganizations
  • Loading branch information
sarias-eb committed Jun 11, 2020
1 parent 2531136 commit 771fd00
Show file tree
Hide file tree
Showing 9 changed files with 306 additions and 887 deletions.
2 changes: 2 additions & 0 deletions supplier_app/new_urls/AP_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
TaxpayerHistory,
change_taxpayer_status,
company_invite,
BuyerTaxpayersList,
)

from users_app.views import (
Expand All @@ -20,6 +21,7 @@
url(r'^$', CompanyListView.as_view(), name='company-list'),
url(r'^create$', CompanyCreatorView.as_view(), name='company-create'),
url(r'^invite$', company_invite, name='company-invite'),
url(r'^taxpayerList$', BuyerTaxpayersList.as_view(), name='buyer-taxpayer-list'),
]

taxpayer_pattern = [
Expand Down
59 changes: 58 additions & 1 deletion supplier_app/tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2910,4 +2910,61 @@ def test_change_taxpayer_status_raise_exception(self):

def test_show_message_raise_exception(self):
with self.assertRaises(NotImplementedError):
self.main.show_message()
self.main.show_message()


class TestBuyerTaxpayersList(TestCase):
def setUp(self):
self.company1 = CompanyFactory(
name='Empresa 1',
description='Descripcion de la empresa 1'
)
self.company2 = CompanyFactory(
name='Empresa 2',
description='Descripcion de la empresa 2'
)
self.taxpayer_ar1 = TaxPayerArgentinaFactory(
business_name=BUSINESS_EXAMPLE_NAME_1,
workday_id='1',
taxpayer_state=STATUS_PENDING,
cuit='20317899653',
company=self.company1,
)
self.taxpayer_ar2 = TaxPayerArgentinaFactory(
business_name=BUSINESS_EXAMPLE_NAME_2,
workday_id='2',
taxpayer_state=STATUS_CHANGE_REQUIRED,
cuit='20392379685',
company=self.company2,
)
self.taxpayerebentity_1 = TaxPayerEBEntityFactory(
taxpayer=self.taxpayer_ar1,
)
self.taxpayerebentity_2 = TaxPayerEBEntityFactory(
taxpayer=self.taxpayer_ar2,
)
self.company_list = [
CompanyFactory(),
CompanyFactory(),
CompanyFactory(),
]
self.user_buyer_with_google_social = UserFactory(email='[email protected]')
self.buyer_group = Group.objects.get(name='buyer')
self.user_buyer_with_google_social.groups.add(self.buyer_group)
self.client = Client()
self.client.force_login(self.user_buyer_with_google_social)

def test_taxpayer_eb_list(self):
response = self.client.get(reverse('buyer-taxpayer-list'))
company1 = response.context[0]['company_list'][0]
self.assertIn(company1, self.company_list)
self.assertTrue(
len(response.context[0]['taxpayerebentity_list']) == 2
)
self.assertTrue(
len(response.context[0]['company_list']) == 3
)

def test_taxpayer_eb_list_template(self):
response = self.client.get(reverse('buyer-taxpayer-list'))
self.assertTemplateUsed(response, 'supplier_app/Buyer/taxpayer_list.html')
22 changes: 22 additions & 0 deletions supplier_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,3 +656,25 @@ def get(self, request, *args, **kwargs):
pdf = render_to_pdf('supplier_app/html-to-pdf-page.html', self.get_context_data())
return HttpResponse(pdf, content_type='application/pdf')


class BuyerTaxpayersList(UserLoginPermissionRequiredMixin, ListView):
model = TaxPayerArgentina
template_name = 'supplier_app/Buyer/taxpayer_list.html'
permission_required = (
CAN_CREATE_COMPANY_PERM,
)

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
company_list = list(Company.objects.all())
taxpayereb_list = context['taxpayerebentity_list']
for taxpayereb in taxpayereb_list:
for company in company_list:
if taxpayereb.taxpayer.company == company:
company_list.remove(company)
context['company_list'] = company_list
return context

def get_queryset(self):
queryset = TaxPayerEBEntity.objects.all()
return queryset
Binary file modified supplier_management_site/locale/es/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 771fd00

Please sign in to comment.