diff --git a/back/api/helpers.py b/back/api/helpers.py index f20a2497..642f91ed 100644 --- a/back/api/helpers.py +++ b/back/api/helpers.py @@ -55,17 +55,19 @@ def send_geoshop_email(subject, message='', recipient=None, template_name=None, ) -def _zip_them_all(full_zip_path, zip_list_path): +def _zip_them_all(full_zip_path, files_list_path): """ Takes a list of zip paths and brings the content together in a single zip """ full_zip_file = zipfile.ZipFile(full_zip_path, 'w', zipfile.ZIP_DEFLATED) - for zip_path in zip_list_path: - if zip_path != '': - zip_file = zipfile.ZipFile('{}/{}'.format(settings.MEDIA_ROOT, zip_path), 'r') + for file_path in files_list_path: + if file_path.endswith(".zip"): + zip_file = zipfile.ZipFile('{}/{}'.format(settings.MEDIA_ROOT, file_path), 'r') for unzipped_file in zip_file.namelist(): full_zip_file.writestr(unzipped_file, zip_file.open(unzipped_file).read()) + elif file_path != '': + full_zip_file.write('{}/{}'.format(settings.MEDIA_ROOT, file_path)) full_zip_file.close() @@ -75,7 +77,7 @@ def zip_all_orderitems(order): Takes all zips'content from order items and makes one single zip of it calling _zip_them_all as a backgroud process. """ - zip_list_path = list(order.items.all().values_list('extract_result', flat=True)) + files_list_path = list(order.items.all().values_list('extract_result', flat=True)) today = timezone.now() first_part = str(uuid.uuid4())[0:9] @@ -86,6 +88,6 @@ def zip_all_orderitems(order): order.extract_result.name = zip_path.as_posix() full_zip_path = Path(settings.MEDIA_ROOT, zip_path) - back_process = Process(target=_zip_them_all, args=(full_zip_path, zip_list_path)) + back_process = Process(target=_zip_them_all, args=(full_zip_path, files_list_path)) back_process.daemon = True back_process.start() diff --git a/back/api/locale/fr/LC_MESSAGES/django.po b/back/api/locale/fr/LC_MESSAGES/django.po index 83ccef88..425423cc 100644 --- a/back/api/locale/fr/LC_MESSAGES/django.po +++ b/back/api/locale/fr/LC_MESSAGES/django.po @@ -369,7 +369,7 @@ msgstr "Devis réalisé" #: .\api\models.py:353 msgid "Ready" -msgstr "Prêt" +msgstr "A traiter" #: .\api\models.py:354 msgid "In extract" diff --git a/back/api/models.py b/back/api/models.py index 10075a77..d2faf568 100644 --- a/back/api/models.py +++ b/back/api/models.py @@ -5,6 +5,7 @@ from django.contrib.auth import get_user_model from django.contrib.postgres.search import SearchVectorField from django.contrib.postgres.indexes import GinIndex, BTreeIndex +from django.utils import timezone from django.utils.html import mark_safe from django.utils.translation import gettext_lazy as _ from django.urls import reverse @@ -446,6 +447,7 @@ def confirm(self): item.ask_price() has_all_prices_calculated = has_all_prices_calculated and False if has_all_prices_calculated: + self.date_ordered = timezone.now() self.status = Order.OrderStatus.READY else: self.status = Order.OrderStatus.PENDING diff --git a/back/api/serializers.py b/back/api/serializers.py index 7c9137c3..6b5fc380 100644 --- a/back/api/serializers.py +++ b/back/api/serializers.py @@ -528,6 +528,11 @@ class ProductDigestSerializer(serializers.ModelSerializer): view_name='metadata-detail', lookup_field='id_name' ) + pricing = serializers.SlugRelatedField( + required=False, + queryset=DataFormat.objects.all(), + slug_field='name' + ) class Meta: model = Product diff --git a/back/api/views.py b/back/api/views.py index bc69a457..13ad5b3d 100644 --- a/back/api/views.py +++ b/back/api/views.py @@ -237,8 +237,9 @@ class OrderViewSet(MultiSerializerMixin, viewsets.ModelViewSet): To modify or delete an existing item, please use `/orderitem/` endpoint. """ - search_fields = ['title', 'description'] - filter_backends = [filters.SearchFilter] + search_fields = ['title', 'description', 'id'] + ordering_fields = ['id'] + filter_backends = [filters.SearchFilter, filters.OrderingFilter] serializers = { 'default': OrderSerializer, 'list': OrderDigestSerializer, diff --git a/front/src/app/_services/api-order.service.ts b/front/src/app/_services/api-order.service.ts index 9a8c451a..c2ff2183 100644 --- a/front/src/app/_services/api-order.service.ts +++ b/front/src/app/_services/api-order.service.ts @@ -67,7 +67,7 @@ export class ApiOrderService { ); } - getOrders(offset?: number, limit?: number): Observable | null> { + getOrders(offset?: number, limit?: number, ordering?: string): Observable | null> { if (!this.apiUrl) { this.apiUrl = this.configService.config.apiUrl; } @@ -79,6 +79,9 @@ export class ApiOrderService { if (offset) { url.searchParams.append('offset', offset.toString()); } + if (ordering) { + url.searchParams.append('ordering', ordering); + } return this.http.get | null>(url.toString()) .pipe( diff --git a/front/src/app/account/orders/order/order.component.html b/front/src/app/account/orders/order/order.component.html index c82bb532..9a45770c 100644 --- a/front/src/app/account/orders/order/order.component.html +++ b/front/src/app/account/orders/order/order.component.html @@ -7,7 +7,14 @@ [matIconName]="order?.statusAsReadableIconText?.iconName" [fontColor]="order?.statusAsReadableIconText?.color" [fontSize]="16"> - N°{{order?.id}} - {{order?.title}} +
+
+ N°{{order?.id}} - {{order?.title}} +
+
+ {{order?.date_ordered | date}} +
+
{{order?.description}} diff --git a/front/src/app/account/orders/order/order.component.scss b/front/src/app/account/orders/order/order.component.scss index 0c1ad64a..647c83a4 100644 --- a/front/src/app/account/orders/order/order.component.scss +++ b/front/src/app/account/orders/order/order.component.scss @@ -1,3 +1,4 @@ +@import '../../../../theme.scss'; :host { .mat-expansion-panel-header-title { @@ -6,6 +7,18 @@ gs2-icon-text { margin-right: 16px; } + + .title-block { + display: flex; + justify-content: space-between; + width: 100%; + + .date-el { + font-weight: 400; + font-style: italic; + padding-right: 1em; + } + } } .mat-expansion-panel-header-description { diff --git a/front/src/app/account/orders/orders.component.html b/front/src/app/account/orders/orders.component.html index 74173704..1ef20504 100644 --- a/front/src/app/account/orders/orders.component.html +++ b/front/src/app/account/orders/orders.component.html @@ -1,10 +1,14 @@
- - + + Rechercher une commande... + +
- - diff --git a/front/src/app/account/orders/orders.component.scss b/front/src/app/account/orders/orders.component.scss index 2463f03b..07c51273 100644 --- a/front/src/app/account/orders/orders.component.scss +++ b/front/src/app/account/orders/orders.component.scss @@ -36,7 +36,7 @@ border-radius: 4px; display: block; align-self: flex-start; - width: 60%; + width: 50%; } .orders-container { diff --git a/front/src/app/account/orders/orders.component.ts b/front/src/app/account/orders/orders.component.ts index 32f43d7d..4630281d 100644 --- a/front/src/app/account/orders/orders.component.ts +++ b/front/src/app/account/orders/orders.component.ts @@ -102,13 +102,12 @@ export class OrdersComponent implements OnInit, OnDestroy { getBatch(offset: number) { const init: { [key: string]: IOrderSummary } = {}; - return this.apiOrderService.getOrders(offset, this.batch) + return this.apiOrderService.getOrders(offset, this.batch, '-id') .pipe( tap(response => this.total = response ? response.count : 0), map((response) => { if (response) { return response.results - .sort((a) => a.status === 'PENDING' ? 1 : a.status === 'READY' ? 1 : 0) .map(p => { p.statusAsReadableIconText = Order.initializeStatus(p); p.id = GeoshopUtils.ExtractIdFromUrl(p.url); diff --git a/front/src/app/welcome/catalog/catalog.component.html b/front/src/app/welcome/catalog/catalog.component.html index 7b36f223..93de83d8 100644 --- a/front/src/app/welcome/catalog/catalog.component.html +++ b/front/src/app/welcome/catalog/catalog.component.html @@ -21,7 +21,7 @@
{{product.label}}
- + {{product.pricing}}