diff --git a/core/views.py b/core/views.py index 03a6758..fbe1bc4 100644 --- a/core/views.py +++ b/core/views.py @@ -127,9 +127,9 @@ def load_coop_managers(request): logging.info(f"Created Coop: {coop_data}") coop_counter += 1 - coop_user = User.objects.create_user(email=row['email'], company=coop, role='COOP_MANAGER') - logging.info(f"Created User: {coop_user}") + coop_user = User.objects.create_user(email=row['email'], company=coop, role='COOP_MANAGER', is_active=False) # TODO: send confirmation email + logging.info(f"Created User: {coop_user}") user_counter += 1 except Exception as e: logging.error(f"Could not parse {row}") diff --git a/products/tests.py b/products/tests.py index cb5b223..71188ab 100644 --- a/products/tests.py +++ b/products/tests.py @@ -81,7 +81,7 @@ class ProductViewSetTest(APITestCase): self.assertEqual(response.status_code, status.HTTP_200_OK) # authenticated user - def test_auth_user_can_list_instance(self): + def test_auth_user_can_list_instances(self): """Regular logged-in user can list instance """ # Create instances @@ -100,6 +100,25 @@ class ProductViewSetTest(APITestCase): # Assert all instances are returned self.assertEqual(len(instances), len(response.data)) + def test_auth_user_can_get_instance(self): + """Regular logged-in user can list instance + """ + # Create instances + instance = self.factory() + + # Authenticate user + token = get_tokens_for_user(self.user) + self.client.credentials(HTTP_AUTHORIZATION=f"Bearer {token['access']}") + + # Request list + url = f"{self.endpoint}{instance.id}/" + response = self.client.get(url) + + # Assert access is allowed + self.assertEqual(response.status_code, status.HTTP_200_OK) + data = json.loads(response.content) + self.assertEquals(instance.id, data['id']) + def test_auth_user_can_create_instance(self): """Regular logged-in user can create new instance """ diff --git a/products/views.py b/products/views.py index 164e573..b2f660a 100644 --- a/products/views.py +++ b/products/views.py @@ -91,6 +91,9 @@ def load_coop_products(request): new_image = None else: new_image = None + + # TODO: if tags is empty, auto-generate tags + # assemble instance data product_data = { 'id': None if row['id'].strip()=='' else row['id'].strip(),