From 58b36f2823449fd363dbc381f3fd49f0f2877c38 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 20 Jan 2025 13:37:06 +0100 Subject: [PATCH] light modification --- models/resources/resource.go | 2 +- models/resources/resource_accessor.go | 1 + models/utils/common.go | 2 -- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/models/resources/resource.go b/models/resources/resource.go index 2cf9f8c..bb9c7f3 100644 --- a/models/resources/resource.go +++ b/models/resources/resource.go @@ -81,11 +81,11 @@ func (abs *AbstractIntanciatedResource[T]) ConvertToPricedResource( } func (abs *AbstractIntanciatedResource[T]) SetAllowedInstances(request *tools.APIRequest) { - abs.AbstractResource.AbstractObject.Type = abs.GetType() abs.Instances = verifyAuthAction[T](abs.Instances, request) } func (d *AbstractIntanciatedResource[T]) Trim() { + d.AbstractResource.AbstractObject.Type = d.GetType() if ok, _ := (&peer.Peer{AbstractObject: utils.AbstractObject{UUID: d.CreatorID}}).IsMySelf(); !ok { for _, instance := range d.Instances { instance.ClearPeerGroups() diff --git a/models/resources/resource_accessor.go b/models/resources/resource_accessor.go index edcf8e9..43e8c2b 100644 --- a/models/resources/resource_accessor.go +++ b/models/resources/resource_accessor.go @@ -96,6 +96,7 @@ func (abs *resourceMongoAccessor[T]) getResourceFilter(search string) *dbs.Filte return &dbs.Filters{ Or: map[string][]dbs.Filter{ // filter by like name, short_description, description, owner, url if no filters are provided "abstractintanciatedresource.abstractresource.abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}}, + "abstractintanciatedresource.abstractresource.abstractobject.type": {{Operator: dbs.LIKE.String(), Value: search}}, "abstractintanciatedresource.abstractresource.short_description": {{Operator: dbs.LIKE.String(), Value: search}}, "abstractintanciatedresource.abstractresource.description": {{Operator: dbs.LIKE.String(), Value: search}}, "abstractintanciatedresource.abstractresource.owners.name": {{Operator: dbs.LIKE.String(), Value: search}}, diff --git a/models/utils/common.go b/models/utils/common.go index 1a006bf..1e86108 100644 --- a/models/utils/common.go +++ b/models/utils/common.go @@ -124,12 +124,10 @@ func genericLoadAll[T DBObject](res *mgb.Cursor, code int, err error, onlyDraft if err = res.All(mongo.MngoCtx, &results); err != nil { return nil, 404, err } - fmt.Println("results", results, res) for _, r := range results { if !r.VerifyAuth(a.GetRequest()) || f(r) == nil || (onlyDraft && !r.IsDrafted()) || (!onlyDraft && r.IsDrafted()) { continue } - fmt.Println(!r.VerifyAuth(a.GetRequest()), f(r) == nil, (onlyDraft && !r.IsDrafted()) || (!onlyDraft && r.IsDrafted()), onlyDraft && !r.IsDrafted(), !onlyDraft && r.IsDrafted()) objs = append(objs, f(r)) } fmt.Println("results 2", results, objs)