Skip to content

Commit

Permalink
Merge pull request #201 from maltaesousa/rc2
Browse files Browse the repository at this point in the history
Rc2
  • Loading branch information
maltaesousa authored Mar 29, 2021
2 parents 044f5ea + 4b8f241 commit 1aeba1f
Show file tree
Hide file tree
Showing 20 changed files with 86 additions and 155 deletions.
14 changes: 8 additions & 6 deletions back/api/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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]
Expand All @@ -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()
2 changes: 1 addition & 1 deletion back/api/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions back/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions back/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions back/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion front/src/app/_services/api-order.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ApiOrderService {
);
}

getOrders(offset?: number, limit?: number): Observable<IApiResponse<IOrderSummary> | null> {
getOrders(offset?: number, limit?: number, ordering?: string): Observable<IApiResponse<IOrderSummary> | null> {
if (!this.apiUrl) {
this.apiUrl = this.configService.config.apiUrl;
}
Expand All @@ -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<IApiResponse<IOrderSummary> | null>(url.toString())
.pipe(
Expand Down
9 changes: 8 additions & 1 deletion front/src/app/account/orders/order/order.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
[matIconName]="order?.statusAsReadableIconText?.iconName"
[fontColor]="order?.statusAsReadableIconText?.color"
[fontSize]="16"></gs2-icon-text>
<span class="title" [class]="panel.expanded ? '' : 'text-ellipsis-2'">N°{{order?.id}} - {{order?.title}}</span>
<div class="title-block">
<div class="title-el">
<span class="title" [class]="panel.expanded ? '' : 'text-ellipsis-2'">N°{{order?.id}} - {{order?.title}}</span>
</div>
<div class="date-el">
<span class="title" [class]="panel.expanded ? '' : 'text-ellipsis-2'">{{order?.date_ordered | date}}</span>
</div>
</div>
</mat-panel-title>
<mat-panel-description>
<span [class]="panel.expanded ? '' : 'text-ellipsis-2'">{{order?.description}}</span>
Expand Down
13 changes: 13 additions & 0 deletions front/src/app/account/orders/order/order.component.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import '../../../../theme.scss';
:host {

.mat-expansion-panel-header-title {
Expand All @@ -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 {
Expand Down
12 changes: 8 additions & 4 deletions front/src/app/account/orders/orders.component.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<div class="actions-container">
<mat-form-field class="filter-container" color="primary">
<input matInput [formControl]="orderFilterControl" placeholder="Rechercher une commande...">
<mat-form-field class="filter-container" color="primary" appearance="fill">
<mat-label>Rechercher une commande...</mat-label>
<input matInput [formControl]="orderFilterControl">
<button mat-button matPrefix mat-icon-button>
<mat-icon>search</mat-icon>
</button>
<div matSuffix class="flex-row">
<mat-spinner *ngIf="isSearchLoading$|async" diameter="16" color="accent"
<mat-spinner mat-icon-button *ngIf="isSearchLoading$|async" diameter="15" color="accent"
style="margin-right: 10px"></mat-spinner>
<button mat-button *ngIf="orderFilterControl.value" mat-icon-button aria-label="Clear"
<button mat-button *ngIf="orderFilterControl.value" aria-label="Clear" mat-icon-button
(click)="orderFilterControl.setValue('');">
<mat-icon>close</mat-icon>
</button>
Expand Down
2 changes: 1 addition & 1 deletion front/src/app/account/orders/orders.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
border-radius: 4px;
display: block;
align-self: flex-start;
width: 60%;
width: 50%;
}

.orders-container {
Expand Down
3 changes: 1 addition & 2 deletions front/src/app/account/orders/orders.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion front/src/app/welcome/catalog/catalog.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<img class="item-logo rounded-image" alt="Logo du produit" aria-label="Logo du produit"
src="{{mediaUrl}}/{{product.thumbnail_link}}">
<div class="item-label text-ellipsis-2" [matTooltip]="product.label">{{product.label}}</div>
<!--<span class="item-price text-accent">{{product.Price}}</span>-->
<span class="item-price text-secondary">{{product.pricing}}</span>
<button class="item-help" matTooltip="Voir les meta données" aria-label="Voir les meta données"
[disabled]="!product.metadata"
color="primary" mat-button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@
<mat-card-header>
<div mat-card-avatar class="header-image"
[style.backgroundImage]="'url(' + mediaUrl + '/' + data.image_link + ')'"></div>
<mat-card-title>{{data.name}}</mat-card-title>
<mat-card-subtitle>Métadonnée</mat-card-subtitle>
<mat-card-title-group>
<mat-card-title>{{data.name}}</mat-card-title>
<mat-card-subtitle>Métadonnée</mat-card-subtitle>
</mat-card-title-group>
<div class="link-button" *ngIf="data.documents?.length > 0">
<a mat-raised-button href="{{ data.documents[0].link }}" target="_blank">{{ data.documents[0].name }}</a>
</div>
</mat-card-header>
<mat-card-content>

Expand Down Expand Up @@ -61,6 +66,20 @@

<img [src]="data.legend_link" alt="Légende">
</mat-expansion-panel>
<mat-expansion-panel *ngIf="data.documents?.length > 1">
<mat-expansion-panel-header>
<mat-panel-title>En savoir plus...</mat-panel-title>
<mat-panel-description></mat-panel-description>
</mat-expansion-panel-header>
<mat-list>
<div *ngFor="let document of data.documents; let first = first;">
<mat-list-item *ngIf="!first">
<mat-icon mat-list-icon color="primary">open_in_new</mat-icon>
<a mat-button href="{{ document.link }}" target="_blank" color="primary">{{ document.name }}</a>
</mat-list-item>
</div>
</mat-list>
</mat-expansion-panel>
</mat-accordion>

</mat-card-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
flex: 1;
overflow-y: auto;
}

.link-button {
margin-left: auto;
}
}

.header-image {
Expand Down
2 changes: 2 additions & 0 deletions front/src/app/welcome/welcome.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {MatButtonToggleModule} from '@angular/material/button-toggle';
import {PageformatComponent} from './map/pageformat/pageformat.component';
import {DragDropModule} from '@angular/cdk/drag-drop';
import {MatSelectModule} from '@angular/material/select';
import {MatListModule} from '@angular/material/list';
import {SharedModule} from '../shared/shared.module';

const MODULES = [
Expand All @@ -32,6 +33,7 @@ const MODULES = [
MatTooltipModule,
MatInputModule,
MatCardModule,
MatListModule,
MatProgressSpinnerModule,
AngularSplitModule,
MatButtonModule,
Expand Down
4 changes: 4 additions & 0 deletions front/src/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ $info: #4177F6;
color: mat-color($accent);
}

.text-secondary {
font-style: italic;
}

.text-error {
color: mat-color($warning);

Expand Down
19 changes: 0 additions & 19 deletions scripts/0_create_db.ps1

This file was deleted.

51 changes: 0 additions & 51 deletions scripts/1_prepare_db.ps1

This file was deleted.

34 changes: 0 additions & 34 deletions scripts/2_deploy_prepub_database.ps1

This file was deleted.

Loading

0 comments on commit 1aeba1f

Please sign in to comment.