Skip to content

Commit 6521120

Browse files
authored
Merge pull request #473 from hypsug0/fix468
Fix468
2 parents 32d01f0 + c317a8c commit 6521120

28 files changed

+68
-198
lines changed

.github/workflows/documentation.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ jobs:
6666

6767
- name: Setup Pages
6868
uses: actions/configure-pages@v4
69-
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
69+
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master')
7070

7171
- name: Upload artifact
7272
uses: actions/upload-pages-artifact@v3
73-
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
73+
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master')
7474
with:
7575
path: docs/_build/html/
7676

7777
- name: Deploy to GitHub Pages
7878
id: deployment
79-
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
79+
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master')
8080
uses: actions/deploy-pages@v4

backend/server.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ def get_app(config, _app=None, with_external_mods=True, url_prefix="/api"):
110110
except Exception as e:
111111
current_app.logger.debug(e)
112112
prefix = url_prefix
113-
app.register_blueprint(
114-
module.backend.blueprint.blueprint, url_prefix=prefix
115-
)
113+
app.register_blueprint(module.backend.blueprint.blueprint, url_prefix=prefix)
116114
try:
117115
module.backend.models.create_schema(db)
118116
except Exception as e:
@@ -122,10 +120,4 @@ def get_app(config, _app=None, with_external_mods=True, url_prefix="/api"):
122120
module.backend.blueprint.blueprint.config = conf
123121
app.config[manifest["module_name"]] = conf
124122

125-
# create_schemas(db)
126-
# db.create_all()
127-
# populate_modules(db)
128-
129-
# _app = app
130-
131123
return app

docs/installation.rst

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -310,41 +310,19 @@ Installation du backend et de la base des données
310310
Générer les schémas de GeoNature-citizen
311311
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312312

313-
Il faut maintenant faire au moins une requête au serveur pour le forcer à créer les tables dont il a besoin.
314-
315-
Lancement du backend pour générer les schémas :
316-
317313
::
318314

319315
# Assurez vous de bien être toujours connecté en tant que geonatadmin
320316
# avec le venv activé avant de lancer cette étape
321317
sudo chown geonatadmin:geonatadmin /home/geonatadmin/gncitizen/ -R
322318
cd ~/gncitizen/backend
323319
export FLASK_ENV=development; export FLASK_DEBUG=1; export FLASK_RUN_PORT=5002; export FLASK_APP=wsgi;
324-
nohup python -m flask run --host=0.0.0.0 > /dev/null 2>&1 &
325-
serverPID=$!
326-
sleep 1 && wget http://127.0.0.1:5002/ # ceci devrait renvoyer 404: NOT FOUND.
327-
kill $serverPID
328-
329-
330-
Enregistrement du module principal :
331-
332-
::
320+
python -m flask db upgrade
333321

334-
psql -d gncitizen -h localhost -p 5432 -U geonatuser -c "insert into gnc_core.t_modules values (1, 'observations', 'observations', 'observations', NULL, false, now(), now());"
335-
336-
Vous pouvez créer un programme test avec la ligne de commande suivante :
337-
338-
::
339-
340-
psql -d gncitizen -h localhost -p 5432 -U geonatuser -c "INSERT INTO gnc_core.t_programs VALUES (1, 'Au 68', 'inventaire du 68', 'desc', NULL, NULL, 1, 100, 't', '0106000020E6100000010000000103000000010000000500000001000070947C154042CA401665A5454001000070EE7C15402235D7E667A54540010000D81C7D1540AFBA27365AA5454000000040C47C1540DD9BD74A58A5454001000070947C154042CA401665A54540', now(), now());"
341-
342-
Celui-ci suppose l'existence d'une liste de taxons dont l'ID est 100, qui normalement existe sur TaxHub par défaut. Remplacez la valeur 100 par une liste existante si ce n'est pas le cas, ou créez une liste avec cet ID sur TaxHub.
343322

344323
Mettre en place le système de badge
345324
------------------------------------------------------
346325

347-
348326
::
349327

350328
mkdir ~/gncitizen/media
@@ -362,7 +340,7 @@ Installer l'environnement javascript
362340
::
363341

364342
cd ~/gncitizen/frontend/
365-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
343+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
366344
source ~/.bashrc
367345
nvm install
368346
npm install

frontend/src/app/api/global-cache.service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ export class GlobalCacheService {
1616
this.attributesCache = data;
1717
}
1818

19+
findAttributId(search_values: Array<string>): number | undefined {
20+
const result = Object.keys(this.attributesCache).find((k) => {
21+
return search_values.includes(this.attributesCache[k].nom_attribut);
22+
});
23+
24+
return result ? this.attributesCache[result].id_attribut : undefined;
25+
}
26+
1927
getMediaById(id: number): Media | undefined {
2028
return this.mediasCache[id];
2129
}

frontend/src/app/api/taxhub.service.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ export class TaxhubService {
2323
private readonly URL = MainConfig.API_ENDPOINT;
2424
taxon: Taxon;
2525
MEDIAS_TYPES_ALLOWED = ['Photo_gncitizen', 'Photo_principale', 'Photo'];
26-
ATTRIBUTS_ALLOWED = ['Nom_francais'];
26+
ATTRIBUTS_ALLOWED = ['Nom_francais', 'nom_francais'];
2727

2828
constructor(
2929
protected http: HttpClient,
3030
protected domSanitizer: DomSanitizer,
3131
private cacheService: GlobalCacheService
32-
) {}
32+
) { }
3333

3434
getTaxon(cd_nom: number): Observable<Taxon> {
3535
return this.http
@@ -42,11 +42,6 @@ export class TaxhubService {
4242
);
4343
return taxon;
4444
}),
45-
// tap(taxon => {
46-
// // this.state.set(TAXON_KEY, taxon as any);
47-
// console.debug("taxhub taxon", taxon);
48-
// return taxon;
49-
// }),
5045
catchError(this.handleError<Taxon>(`getTaxon(${cd_nom})`))
5146
);
5247
}
@@ -140,14 +135,12 @@ export class TaxhubService {
140135
// Set attributs
141136
item.nom_francais = null;
142137
if (item.attributs && item.attributs.length > 0) {
143-
const attributs = item.attributs.find((attr: any) =>
144-
this.cacheService.getAttributeById(attr.id_attribut)
145-
);
146-
this.ATTRIBUTS_ALLOWED.map((attributName) => {
147-
if (attributName === 'Nom_francais') {
148-
item.nom_francais = attributs.valeur_attribut;
149-
}
150-
});
138+
// Trouver l'attribut "nom_francais" si existe
139+
const attrId = this.cacheService.findAttributId(this.ATTRIBUTS_ALLOWED)
140+
141+
// Peupler la clé "nom_francais" si valeur
142+
const frAttribute = item.attributs.find((attr) => attrId === attr.id_attribut);
143+
item.nom_francais = frAttribute ? frAttribute.valeur_attribut : null;
151144
}
152145
return { ...item };
153146
}));

frontend/src/app/auth/auth.interceptor.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class AuthInterceptor implements HttpInterceptor {
3131
public errorHandler: ErrorHandler,
3232
private auth: AuthService,
3333
private router: Router
34-
) {}
34+
) { }
3535

3636
addToken(request: HttpRequest<any>, token: string): HttpRequest<any> {
3737
if (token) {
@@ -82,9 +82,8 @@ export class AuthInterceptor implements HttpInterceptor {
8282
} else {
8383
return this.token$.pipe(
8484
filter((token: string | null) => !!token),
85-
tap((token) => console.debug(token)),
85+
tap((_token) => { }),
8686
switchMap((token: string) => {
87-
console.debug('waited after refresh:', token);
8887
return next.handle(this.addToken(request, token));
8988
})
9089
);

frontend/src/app/auth/confirm-email/confirm-email.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class ConfirmEmailComponent implements OnInit {
1515
private activeRoute: ActivatedRoute,
1616
private router: Router,
1717
private authService: AuthService
18-
) {}
18+
) { }
1919

2020
ngOnInit() {
2121
const token = this.activeRoute.snapshot.params.token;
@@ -41,7 +41,6 @@ export class ConfirmEmailComponent implements OnInit {
4141
this.confirmedMessage =
4242
"Le lien de confirmation n'est pas valide.";
4343
this.confirmResponse = error.error;
44-
console.log('confirm error', error);
4544
setTimeout(() => {
4645
this.router.navigate(['home']);
4746
}, 3000);

frontend/src/app/auth/user-dashboard/user-dashboard.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ export class UserDashboardComponent implements OnInit {
130130
this.myobs = data[0];
131131
this.mysites = data[1];
132132
if (MainConfig['REWARDS']) {
133-
// console.debug('data3', data[2]);
134133
this.badges = data[2];
135134
localStorage.setItem('badges', JSON.stringify(this.badges));
136-
// console.debug('badges', this.badges);
137135
if (this.badges.length > 0) {
138136
this.badges.forEach((badge) => {
139137
if (
@@ -249,7 +247,7 @@ export class UserDashboardComponent implements OnInit {
249247
this.router.navigate(['/home']);
250248
}
251249
})
252-
.catch((err) => console.log('err', err));
250+
.catch((err) => console.error(err));
253251
}
254252

255253
onExportPersonalData() {

frontend/src/app/auth/user-dashboard/user.service.service.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ export class UserService {
2828
}
2929

3030
updatePersonalData(personalInfo) {
31-
// console.log('up', personalInfo);
32-
3331
return this.http
3432
.patch(`${MainConfig.API_ENDPOINT}/user/info`, personalInfo, {
3533
headers: this.headers,

frontend/src/app/core/topbar/topbar.component.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Program } from '../../programs/programs.models';
1212
import { GncProgramsService } from '../../api/gnc-programs.service';
1313
import { ActivatedRoute } from '@angular/router';
1414
import { HttpClient } from '@angular/common/http';
15-
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
15+
import { SafeUrl } from '@angular/platform-browser';
1616
import { ModalsTopbarService } from './modalTopbar.service';
1717

1818
@Component({
@@ -148,36 +148,15 @@ export class TopbarComponent implements OnInit {
148148
console.error(err);
149149
this.auth
150150
.logout()
151-
.then((logout) => {
151+
.then((_logout) => {
152152
// console.log('Logout Status:', logout.status);
153153
})
154-
.catch((err) => {
154+
.catch((_err) => {
155155
// console.error('Logout error:', err);
156156
});
157157
return throwError(err);
158158
}
159159
);
160-
/*this.auth.ensureAuthorized().pipe(
161-
tap(user => {
162-
console.log("ensureAuthorized result", user);
163-
if (user && user["features"] && user["features"].id_role) {
164-
this.username = user["features"].username;
165-
this.isAdmin = user["features"].admin ? true : false;
166-
}
167-
}),
168-
catchError(err => {
169-
console.error(err);
170-
this.auth
171-
.logout()
172-
.then(logout => {
173-
console.log("Logout Status:", logout.status);
174-
})
175-
.catch(err => {
176-
console.error("Logout error:", err);
177-
});
178-
return throwError(err);
179-
})
180-
);*/
181160
}
182161
}
183162
}

0 commit comments

Comments
 (0)