Skip to content

Commit

Permalink
Merge pull request #204 from maltaesousa/v1
Browse files Browse the repository at this point in the history
V1
  • Loading branch information
maltaesousa authored Apr 1, 2021
2 parents 22ec0ad + 4caf10d commit 52fbdad
Show file tree
Hide file tree
Showing 18 changed files with 138 additions and 87 deletions.
52 changes: 26 additions & 26 deletions back/api/management/commands/prepareusertests.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ def handle(self, *args, **options):
mma.identity.phone = '+41 32 000 00 00'
mma.identity.save()

mka = UserModel.objects.create_user(
username='mka', password='mka')
mka.identity.email = 'mka[email protected]'
mka.identity.first_name = 'Michaël'
mka.identity.last_name = 'Kalbermatten'
mka.identity.street = 'Rue de Tivoli 22'
mka.identity.postcode = '2000'
mka.identity.city = 'Neuchâtel'
mka.identity.country = 'Suisse'
mka.identity.company_name = 'Service du Registre Foncier et de la Géomatique - SITN'
mka.identity.phone = '+41 32 000 00 00'
mka.identity.subscribed = True
mka.identity.save()
mka2 = UserModel.objects.create_user(
username='mka2', password='mka2')
mka2.identity.email = 'mka2[email protected]'
mka2.identity.first_name = 'Michaël'
mka2.identity.last_name = 'Kalbermatten'
mka2.identity.street = 'Rue de Tivoli 22'
mka2.identity.postcode = '2000'
mka2.identity.city = 'Neuchâtel'
mka2.identity.country = 'Suisse'
mka2.identity.company_name = 'Service du Registre Foncier et de la Géomatique - SITN'
mka2.identity.phone = '+41 32 000 00 00'
mka2.identity.subscribed = True
mka2.identity.save()

# contacts
contact1 = Contact.objects.create(
Expand Down Expand Up @@ -116,7 +116,7 @@ def handle(self, *args, **options):
belongs_to=mmi
)
contact3.save()
contact_mka = Contact.objects.create(
contact_mka2 = Contact.objects.create(
first_name='Jean',
last_name='Doe',
email='[email protected]',
Expand All @@ -125,9 +125,9 @@ def handle(self, *args, **options):
country='Suisse',
company_name='Marine de Colombier',
phone='+41 00 787 29 16',
belongs_to=mka
belongs_to=mka2
)
contact_mka.save()
contact_mka2.save()

order_geom = Polygon((
(
Expand Down Expand Up @@ -195,15 +195,15 @@ def handle(self, *args, **options):
date_ordered=timezone.now())
order4.save()

order_mka = Order.objects.create(
order_mka2 = Order.objects.create(
title='Plan de situation pour enquête',
description='C\'est un test',
order_type=order_type_prive,
client=mka,
client=mka2,
geom=order_geom,
invoice_reference='Dossier n°545454',
date_ordered=timezone.now())
order_mka.save()
order_mka2.save()

order_download = Order.objects.create(
title='Commande prête à être téléchargée',
Expand Down Expand Up @@ -241,13 +241,13 @@ def handle(self, *args, **options):
OrderItem.objects.create(order=order2, product=product1),
OrderItem.objects.create(order=order3, product=product1, data_format=data_format),
OrderItem.objects.create(order=order4, product=product2),
OrderItem.objects.create(order=order_mka, product=product1, data_format=data_format)
OrderItem.objects.create(order=order_mka2, product=product1, data_format=data_format)
]
for order_item in orderitems:
order_item.set_price()
order_item.save()
order_item_deprecated = OrderItem.objects.create(
order=order_mka, product=product_deprecated, data_format=data_format)
order=order_mka2, product=product_deprecated, data_format=data_format)
order_item_deprecated.set_price(price=Money(400, 'CHF'), base_fee=Money(150, 'CHF'))
order_item_deprecated.price_status = OrderItem.PricingStatus.CALCULATED
order_item_deprecated.save()
Expand All @@ -274,11 +274,11 @@ def handle(self, *args, **options):

order4.save()

order_mka.invoice_contact = contact_mka
order_mka.set_price()
order_mka.date_ordered = datetime.datetime(2018, 12, 1, 8, 20, 3, 0, tzinfo=datetime.timezone.utc)
order_mka.status = Order.OrderStatus.ARCHIVED
order_mka.save()
order_mka2.invoice_contact = contact_mka2
order_mka2.set_price()
order_mka2.date_ordered = datetime.datetime(2018, 12, 1, 8, 20, 3, 0, tzinfo=datetime.timezone.utc)
order_mka2.status = Order.OrderStatus.ARCHIVED
order_mka2.save()

order_download.set_price()
empty_zip_data = b'PK\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Expand Down
2 changes: 1 addition & 1 deletion back/api/templates/email_admin_fr-ch.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% endif %}
{% if admin_url %}
<p>
<a href="https://sitn.ne.ch/geoshop2_api{% url admin_url admin_url_params %}">
<a href="https://sitn.ne.ch{% url admin_url admin_url_params %}">
{% url admin_url admin_url_params %}
</a>
</p>
Expand Down
8 changes: 4 additions & 4 deletions back/api/templates/email_password_reset.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% extends "email_base_template.html" %}
{% load i18n %}
{% block content %}
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}<br><br>

{% trans "Please go to the following page and choose a new password:" %}
{% trans "Please go to the following page and choose a new password:" %}<br>
{% block reset_link %}
{{ protocol }}://{{ domain }}/auth/reset/{{ uid }}/{{ token }}
{% endblock %}
{% trans 'Your username, in case you’ve forgotten:' %} {{ user.get_username }}
{% endblock %}<br><br>
{% trans 'Your username, in case you’ve forgotten:' %}<strong> {{ user.get_username }}</strong>
{% endblock %}
12 changes: 0 additions & 12 deletions back/api/templates/registration/password_reset_email.html

This file was deleted.

4 changes: 2 additions & 2 deletions front/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.png",
"src/favicon.ico",
"src/assets"
],
"styles": [
Expand Down Expand Up @@ -92,7 +92,7 @@
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.png",
"src/favicon.ico",
"src/assets"
],
"styles": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
<span>Voir l'aide</span>
</div>
</button>

<a color="primary" mat-button href="https://rsn.ne.ch/DATA/program/books/rsne/htm/2154211.htm" target="_blank">
Informations sur la tarification
</a>
<hr>
<span class="padding-horizontal-15 questions">Avez-vous des questions ?</span>

<a mat-button color="primary" [href]="'tel:' + phoneNumber">
Expand Down
11 changes: 6 additions & 5 deletions front/src/app/account/profile/modify-profile.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-card class="scrollable-content" *ngIf="user">
<mat-card *ngIf="user">
<mat-card-header>
<mat-card-title>GeoShop - Modification du profil</mat-card-title>
</mat-card-header>
Expand Down Expand Up @@ -127,10 +127,11 @@
placeholder="N° IDE">
<mat-error *ngIf="formModifyUser?.get('ideId')?.hasError('pattern')">Mauvais format du numéro IDE, accepté : CHE-012.345.678</mat-error>
</mat-form-field>

<button class="action-button-container" color="primary" mat-raised-button type="submit" [disabled]="formModifyUser.invalid">
Soumettre
</button>
<div class="bottom-container">
<button class="action-button-container" color="primary" mat-raised-button type="submit" [disabled]="formModifyUser.invalid">
Soumettre
</button>
</div>
</form>
</mat-card-content>
</mat-card>
36 changes: 14 additions & 22 deletions front/src/app/account/profile/modify-profile.component.scss
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
:host {
display: flex;
justify-content: center;
align-content: center;
margin: 10px;
height: calc(100vh - 84px);
height: calc(100vh - 64px);

.mat-card {
display: flex;
flex-direction: column;
min-width: 720px;

.mat-card-content {
display: flex;
flex-direction: column;
flex: 1;
}
margin: 10px auto;
flex: 1;
max-width: 960px;
}

ul {
list-style-type: none;
form {
height: calc(100vh - 64px - 60px - 30px);
overflow-y: auto;
}

form {
.bottom-container {
display: flex;
flex-direction: column;
flex: 1;
}
justify-content: flex-end;

.action-button-container {
align-self: flex-end;
margin-top: auto;
.mat-button {
&:only-child {
margin-right: auto;
}
}
}
}
13 changes: 7 additions & 6 deletions front/src/app/account/profile/modify-profile.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {Component, HostBinding, OnInit} from '@angular/core';
import {FormControl, FormGroup, FormBuilder, Validators} from '@angular/forms';
import {of} from 'rxjs';
import {catchError} from 'rxjs/operators';
import {PHONE_REGEX} from '../../_helpers/regex';
import {ApiService} from '../../_services/api.service';
import {IIdentity} from '../../_models/IIdentity';
import {MatSnackBar} from '@angular/material/snack-bar';
import {Router} from '@angular/router';
import {IUser, IUserToPost} from '../../_models/IUser';
Expand Down Expand Up @@ -50,8 +47,8 @@ export class ModifyProfileComponent implements OnInit {
postcode: new FormControl(this.user.postcode, Validators.required),
city: new FormControl(this.user.city, Validators.required),
country: new FormControl(this.user.country, Validators.required),
companyName: new FormControl(this.user.company_name, Validators.required),
ideId: new FormControl(this.user.ide_id, Validators.required),
companyName: new FormControl(this.user.company_name),
ideId: new FormControl(this.user.ide_id),
});
}

Expand Down Expand Up @@ -81,7 +78,11 @@ export class ModifyProfileComponent implements OnInit {
this.apiService.change(user)
.subscribe(async (res) => {
if (res) {
this.snackBar.open('Vos modifications ont été soumises aux gestionnaires du Geoshop et un email de confirmation vous a été envoyé. Vos modifications seront validées par leur soin d\'ici quelques jours.', 'Ok', {panelClass: 'notification-info'});
this.snackBar.open(
'Vos modifications ont été soumises aux gestionnaires du Geoshop' +
' et un email de confirmation vous a été envoyé. Vos modifications' +
' seront validées dans les meilleurs délais.',
'Ok', {panelClass: 'notification-info'});
await this.router.navigate(['/account/profile']);
} else {
this.formModifyUser.markAsDirty();
Expand Down
4 changes: 2 additions & 2 deletions front/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<mat-toolbar color="primary">

<div class="flex-row">
<a mat-button class="header-title" [routerLink]="['welcome']">GeoShop</a>
<a mat-button class="header-title" [routerLink]="['welcome']">GeoShop du système d'information du territoire neuchâtelois</a>
<mat-divider *ngIf="subTitle" vertical="true" color="accent"></mat-divider>
<span class="header-subtitle">{{subTitle}}</span>
</div>
Expand All @@ -10,7 +10,7 @@
<div class="right-container">

<button mat-icon-button [matMenuTriggerFor]="helpOverlay">
<mat-icon>help</mat-icon>
<mat-icon>contact_support</mat-icon>
</button>
<mat-menu #helpOverlay="matMenu" class="overlay-menu-container">
<gs2-help-overlay></gs2-help-overlay>
Expand Down
7 changes: 5 additions & 2 deletions front/src/app/auth/register/register.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ export class RegisterComponent implements OnInit, AfterViewInit {
}

get birthDay() {
return this.formAddress.get('birthDay');
if (this.formAddress.get('birthDay')?.value) {
return this.formAddress.get('birthDay')?.value.toISOString().slice(0, 10);
}
return null;
}

get password() {
Expand Down Expand Up @@ -165,7 +168,7 @@ export class RegisterComponent implements OnInit, AfterViewInit {
company_name: this.companyName?.value,
ide_id: this.ideId?.value,
phone: this.phone?.value,
birthday: this.birthDay?.value?.toISOString().slice(0,10),
birthday: this.birthDay,
};
this.apiService.register(user)
.subscribe(async (res) => {
Expand Down
3 changes: 2 additions & 1 deletion front/src/app/welcome/catalog/catalog.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
src="{{mediaUrl}}/{{product.thumbnail_link}}">
<div class="item-label text-ellipsis-2" [matTooltip]="product.label">{{product.label}}</div>

<!--
<ng-container *ngIf="product.pricing === 'Gratuit'; then gratuit; else payant">
</ng-container>
<ng-template #gratuit>
<span class="item-price text-secondary">Gratuit</span>
</ng-template>
<ng-template #payant>
<span class="item-price text-secondary">Tarification selon le type de mandat</span>
</ng-template>
</ng-template>-->

<button class="item-help" matTooltip="Voir les meta données" aria-label="Voir les meta données"
[disabled]="!product.metadata"
Expand Down
4 changes: 2 additions & 2 deletions front/src/assets/configs/config.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
],
"contact": {
"phone": {
"label": "+41 (0) 32 889 57 63",
"label": "+41 32 889 57 63",
"number": "+41328895763"
},
"email": "chantal.monnier@ne.ch"
"email": "sitn@ne.ch"
},
"initialCenter": [
2551473.73, 1211195.03
Expand Down
Binary file added front/src/assets/favicon.ico
Binary file not shown.
Binary file removed front/src/assets/favicon.png
Binary file not shown.
2 changes: 1 addition & 1 deletion front/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<title>GeoShop</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="assets/favicon.png">
<link rel="icon" type="image/x-icon" href="assets/favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
Expand Down
31 changes: 31 additions & 0 deletions scripts/1_fetch_prod_db.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$pwd = pwd
foreach ($line in Get-Content $PSScriptRoot\..\back\.env.prod) {
$args = $line -split "="
If ($args[0] -And !$args[0].StartsWith("#")) {
$cmd = '$env:' + $args[0].Trim('"') + '="' + $args[1].Trim('"') + '"'
Invoke-Expression $cmd
}
}

$filename = ("geoshop.backup")
$dumpFile = ("{0}\{1}"-f $PSScriptRoot, $filename)

$previous_PGPASSWORD = $env:PGPASSWORD
$env:PGPASSWORD = $env:PGPOSTGRESPASSWORD

If (Test-Path $dumpFile) {
Remove-Item $dumpFile
}

pg_dump -U postgres -F c -n $env:PGSCHEMA -b -f $dumpFile $env:PGDATABASE

If (Test-Path $dumpFile) {
psql -U postgres -h localhost -d geoshop -c "DROP SCHEMA IF EXISTS old_$env:PGSCHEMA CASCADE;"
psql -U postgres -h localhost -d geoshop -c "ALTER SCHEMA $env:PGSCHEMA RENAME TO old_$env:PGSCHEMA;"
pg_restore -U postgres -h localhost -F c -d geoshop $dumpFile
} Else {
Write-Host "$(Get-Date -Format g) pg_restore has not been done"
}
$env:PGPASSWORD = $previous_PGPASSWORD

cd $pwd
Loading

0 comments on commit 52fbdad

Please sign in to comment.