correct
This commit is contained in:
@@ -47,12 +47,12 @@ func (r *AbstractResource) CanDelete() bool {
|
||||
return r.IsDraft // only draft bookings can be deleted
|
||||
}
|
||||
|
||||
type AbstractIntanciatedResource[T ResourceInstanceITF] struct {
|
||||
type AbstractInstanciatedResource[T ResourceInstanceITF] struct {
|
||||
AbstractResource // AbstractResource contains the basic fields of an object (id, name)
|
||||
Instances []T `json:"instances,omitempty" bson:"instances,omitempty"` // Bill is the bill of the resource // Bill is the bill of the resource
|
||||
}
|
||||
|
||||
func (abs *AbstractIntanciatedResource[T]) ConvertToPricedResource(
|
||||
func (abs *AbstractInstanciatedResource[T]) ConvertToPricedResource(
|
||||
t tools.DataType, request *tools.APIRequest) pricing.PricedItemITF {
|
||||
instances := map[string]string{}
|
||||
profiles := []pricing.PricingProfileITF{}
|
||||
@@ -71,14 +71,14 @@ func (abs *AbstractIntanciatedResource[T]) ConvertToPricedResource(
|
||||
}
|
||||
}
|
||||
|
||||
func (abs *AbstractIntanciatedResource[T]) ClearEnv() utils.DBObject {
|
||||
func (abs *AbstractInstanciatedResource[T]) ClearEnv() utils.DBObject {
|
||||
for _, instance := range abs.Instances {
|
||||
instance.ClearEnv()
|
||||
}
|
||||
return abs
|
||||
}
|
||||
|
||||
func (r *AbstractIntanciatedResource[T]) GetSelectedInstance() utils.DBObject {
|
||||
func (r *AbstractInstanciatedResource[T]) GetSelectedInstance() utils.DBObject {
|
||||
if r.SelectedInstanceIndex != nil && len(r.Instances) > *r.SelectedInstanceIndex {
|
||||
return r.Instances[*r.SelectedInstanceIndex]
|
||||
}
|
||||
@@ -88,11 +88,11 @@ func (r *AbstractIntanciatedResource[T]) GetSelectedInstance() utils.DBObject {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (abs *AbstractIntanciatedResource[T]) SetAllowedInstances(request *tools.APIRequest) {
|
||||
func (abs *AbstractInstanciatedResource[T]) SetAllowedInstances(request *tools.APIRequest) {
|
||||
abs.Instances = verifyAuthAction[T](abs.Instances, request)
|
||||
}
|
||||
|
||||
func (d *AbstractIntanciatedResource[T]) Trim() {
|
||||
func (d *AbstractInstanciatedResource[T]) Trim() {
|
||||
d.Type = d.GetType()
|
||||
if ok, _ := (&peer.Peer{AbstractObject: utils.AbstractObject{UUID: d.CreatorID}}).IsMySelf(); !ok {
|
||||
for _, instance := range d.Instances {
|
||||
@@ -101,7 +101,7 @@ func (d *AbstractIntanciatedResource[T]) Trim() {
|
||||
}
|
||||
}
|
||||
|
||||
func (abs *AbstractIntanciatedResource[T]) VerifyAuth(request *tools.APIRequest) bool {
|
||||
func (abs *AbstractInstanciatedResource[T]) VerifyAuth(request *tools.APIRequest) bool {
|
||||
return len(verifyAuthAction[T](abs.Instances, request)) > 0 || abs.AbstractObject.VerifyAuth(request)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user