Skip to content

Commit

Permalink
(ajustements) : Les users dans metas uniformisation. dans le model de…
Browse files Browse the repository at this point in the history
… l'APP et dans les modeles de l'API.
  • Loading branch information
mamarmite committed Sep 9, 2024
1 parent 24dac3f commit 51da56b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/Places/Models/Place.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {PlaceSchema} from "@src/Places/Schemas/PlaceSchema";
import PlacesService from "@src/Places/Services/PlacesService";
import {middlewarePopulateProperty} from "@src/Taxonomy/Middlewares/TaxonomiesPopulate";
import {Meta} from "@src/Moderation/Schemas/MetaSchema";
import {populateUser} from "@src/Users/Middlewares/populateUser";
import {User} from "@src/Users/Models/User";

class Place extends AbstractModel {

Expand Down Expand Up @@ -177,10 +179,16 @@ class Place extends AbstractModel {
public registerEvents(): void {
this.schema.pre('find', function() {
middlewarePopulateProperty(this, "mainImage");

populateUser(this, "meta.requestedBy", User.getInstance().mongooseModel);
populateUser(this, "meta.lastModifiedBy", User.getInstance().mongooseModel);
});

this.schema.pre('findOne', function() {
middlewarePopulateProperty(this, 'mainImage');

populateUser(this, "meta.requestedBy", User.getInstance().mongooseModel);
populateUser(this, "meta.lastModifiedBy", User.getInstance().mongooseModel);
});
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/Places/Routes/PlacesRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class PlacesRoutes extends CrudRoute {
noHtmlStringSanitizerAlias('data.country'),
noHtmlStringSanitizerAlias('data.latitude'),
noHtmlStringSanitizerAlias('data.longitude'),


],
update: [
objectIdSanitizerAlias('data.id', false),
Expand Down
2 changes: 1 addition & 1 deletion src/Users/Models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class User extends AbstractModel {
}

public publicFields():string {
return "name firstName lastname avatar"
return "name firstName lastName avatar"
}

/**
Expand Down

0 comments on commit 51da56b

Please sign in to comment.