diff --git a/back_latienda/settings/base.py b/back_latienda/settings/base.py
index af2f1b1..4996fc6 100644
--- a/back_latienda/settings/base.py
+++ b/back_latienda/settings/base.py
@@ -85,7 +85,7 @@ TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, '../templates'),],
- # 'APP_DIRS': True,
+ 'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
@@ -93,12 +93,6 @@ TEMPLATES = [
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
- 'loaders': [
- (
- 'django.template.loaders.filesystem.Loader',
- [os.path.join(BASE_DIR, '../templates')],
- ),
- ],
},
},
]
@@ -159,7 +153,7 @@ USE_TZ = True
# https://docs.djangoproject.com/en/2.2/howto/static-files/
STATIC_URL = '/static/'
-STATIC_ROOT = 'static'
+
TAXONOMY_FILE = 'shop-taxonomy.es-ES.txt'
diff --git a/back_latienda/urls.py b/back_latienda/urls.py
index 5d42e68..b18a320 100644
--- a/back_latienda/urls.py
+++ b/back_latienda/urls.py
@@ -44,6 +44,7 @@ urlpatterns = [
path('api/v1/my_company/', company_views.my_company, name='my-company'),
path('api/v1/companies/sample/', company_views.random_company_sample , name='company-sample'),
path('api/v1/purchase_email/', product_views.purchase_email, name='purchase-email'),
+ path('api/v1/products/all_categories/', product_views.all_categories, name='all-categories'),
path('api/v1/stats/me/', stat_views.track_user, name='user-tracker'),
path('api/v1/autocomplete/category-tag/', product_views.CategoryTagAutocomplete.as_view(), name='category-autocomplete'),
path('api/v1/', include(router.urls)),
diff --git a/companies/views.py b/companies/views.py
index 97e2897..f6ebe7e 100644
--- a/companies/views.py
+++ b/companies/views.py
@@ -18,6 +18,7 @@ from stats.models import StatsLog
from companies.models import Company
from companies.serializers import CompanySerializer
from utils.tag_filters import CompanyTagFilter
+from rest_framework import filters
from back_latienda.permissions import IsCreator, IsSiteAdmin
from utils import woocommerce
@@ -28,6 +29,9 @@ class CompanyViewSet(viewsets.ModelViewSet):
serializer_class = CompanySerializer
permission_classes = [IsAuthenticatedOrReadOnly, IsCreator]
filterset_class = CompanyTagFilter
+ filter_backends = [filters.SearchFilter]
+ search_fields = ['company_name__unaccent__icontains', 'short_name__unaccent__icontains']
+
def perform_create(self, serializer):
serializer.save(creator=self.request.user)
diff --git a/products/tests.py b/products/tests.py
index 6efa7dd..d0f979b 100644
--- a/products/tests.py
+++ b/products/tests.py
@@ -13,7 +13,7 @@ from rest_framework import status
from companies.factories import CompanyFactory
from products.factories import ProductFactory, ActiveProductFactory
-from products.models import Product
+from products.models import Product, CategoryTag
from core.factories import CustomUserFactory
from core.utils import get_tokens_for_user
@@ -1258,3 +1258,37 @@ class PurchaseEmailTest(APITestCase):
payload = response.json()
self.assertTrue( 'email' in payload['error'])
+
+class AllCategoriesTest(APITestCase):
+
+ def setUp(self):
+ """Tests setup
+ """
+ self.endpoint = '/api/v1/products/all_categories/'
+ # self.factory = ProductFactory
+ self.model = CategoryTag
+ # create user
+ self.email = f"user@mail.com"
+ self.password = ''.join(random.choices(string.ascii_uppercase, k = 10))
+ self.user = CustomUserFactory(email=self.email, is_active=True)
+ self.user.set_password(self.password)
+ self.user.save()
+
+ def test_get_all_categories(self):
+ # create instances
+ instances = [
+ self.model.objects.create(name='A'),
+ self.model.objects.create(name='B'),
+ self.model.objects.create(name='C'),
+ self.model.objects.create(name='D'),
+ self.model.objects.create(name='E'),
+ ]
+
+ response = self.client.get(self.endpoint)
+
+ # assertions
+ self.assertEquals(response.status_code, 200)
+
+ payload = response.json()
+
+ self.assertEquals(len(instances), len(payload))
diff --git a/products/views.py b/products/views.py
index a4e99bf..5653222 100644
--- a/products/views.py
+++ b/products/views.py
@@ -307,7 +307,7 @@ def purchase_email(request):
email.send()
logging.info(f"Email sent to {company}")
# send confirmation email to user
- user_message = render_to_string('purchase_contact_confirmation.html', {
+ user_message = render_to_string('purchase_contact_confirmation_v2.html', {
'company': company,
'product': product,
'company_message': company_message,
@@ -333,3 +333,13 @@ def purchase_email(request):
# response
return Response()
+
+
+@api_view(['GET'])
+@permission_classes([AllowAny,])
+def all_categories(request):
+ all_categories = []
+ for instance in CategoryTag.objects.all():
+ all_categories.append(instance.label)
+ return Response(data=all_categories)
+
diff --git a/templates/purchase_contact_confirmation_v2.html b/templates/purchase_contact_confirmation_v2.html
index e69de29..fff1cf7 100644
--- a/templates/purchase_contact_confirmation_v2.html
+++ b/templates/purchase_contact_confirmation_v2.html
@@ -0,0 +1,1043 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Confirmación de solicitud
+ enviada
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Enlace al
+ producto
+
+ Nombre del
+ producto
+
+ {{product.name}}
+
+ {{product.sku}}
+
+ {{product.price}}€
+
+
+
+
+
+
+
+ ¡Hola! Tu solicitud de
+ compra de este producto ha
+ sido comunicado a la
+ cooperativa. Pronto tendrás
+ noticias suyas. Para
+ cualquier duda o asistencia,
+ ponte en contacto con
+ {{company.short_name}}.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Datos cooperativa
+
+
+
+
+
+
+ Nombre:
+
+ {{company.company_name}}
+
+
+
+
+
+
+ Email:
+
+ {{company.email}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2021 La Tienda.coop
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+