light modification

This commit is contained in:
mr 2025-01-20 13:37:06 +01:00
parent 2452d37acf
commit 58b36f2823
3 changed files with 2 additions and 3 deletions

View File

@ -81,11 +81,11 @@ func (abs *AbstractIntanciatedResource[T]) ConvertToPricedResource(
} }
func (abs *AbstractIntanciatedResource[T]) SetAllowedInstances(request *tools.APIRequest) { func (abs *AbstractIntanciatedResource[T]) SetAllowedInstances(request *tools.APIRequest) {
abs.AbstractResource.AbstractObject.Type = abs.GetType()
abs.Instances = verifyAuthAction[T](abs.Instances, request) abs.Instances = verifyAuthAction[T](abs.Instances, request)
} }
func (d *AbstractIntanciatedResource[T]) Trim() { func (d *AbstractIntanciatedResource[T]) Trim() {
d.AbstractResource.AbstractObject.Type = d.GetType()
if ok, _ := (&peer.Peer{AbstractObject: utils.AbstractObject{UUID: d.CreatorID}}).IsMySelf(); !ok { if ok, _ := (&peer.Peer{AbstractObject: utils.AbstractObject{UUID: d.CreatorID}}).IsMySelf(); !ok {
for _, instance := range d.Instances { for _, instance := range d.Instances {
instance.ClearPeerGroups() instance.ClearPeerGroups()

View File

@ -96,6 +96,7 @@ func (abs *resourceMongoAccessor[T]) getResourceFilter(search string) *dbs.Filte
return &dbs.Filters{ return &dbs.Filters{
Or: map[string][]dbs.Filter{ // filter by like name, short_description, description, owner, url if no filters are provided 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.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.short_description": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractintanciatedresource.abstractresource.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}}, "abstractintanciatedresource.abstractresource.owners.name": {{Operator: dbs.LIKE.String(), Value: search}},

View File

@ -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 { if err = res.All(mongo.MngoCtx, &results); err != nil {
return nil, 404, err return nil, 404, err
} }
fmt.Println("results", results, res)
for _, r := range results { for _, r := range results {
if !r.VerifyAuth(a.GetRequest()) || f(r) == nil || (onlyDraft && !r.IsDrafted()) || (!onlyDraft && r.IsDrafted()) { if !r.VerifyAuth(a.GetRequest()) || f(r) == nil || (onlyDraft && !r.IsDrafted()) || (!onlyDraft && r.IsDrafted()) {
continue 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)) objs = append(objs, f(r))
} }
fmt.Println("results 2", results, objs) fmt.Println("results 2", results, objs)