Browse Source

Bugfixes for the "ppsOnly"

Dmitry Yu Okunev 4 years ago
parent
commit
42448a7177
2 changed files with 7 additions and 4 deletions
  1. 2 2
      formular.go
  2. 5 2
      unit.go

+ 2 - 2
formular.go

@@ -76,7 +76,7 @@ func (sql Formular) PPSOnly() *FormularScope {
 	return sql.Scope().PPSOnly()
 }
 func (sql *FormularScope) PPSOnly() *FormularScope {
-	return sql.Where("CategoryCode IN (1, 8)")
+	return sql.Where("Cod_Catgory IN (1, 8)")
 }
 
 // TODO: Remove this "VIEW" from this model
@@ -164,7 +164,7 @@ func (f Formular) IsActive() bool {
 type Formulars []Formular
 
 func (formulars Formulars) PrepareIsActive() Formulars {
-	for idx, _ := range formulars {
+	for idx := range formulars {
 		formulars[idx].PrepareIsActive()
 	}
 

+ 5 - 2
unit.go

@@ -185,7 +185,7 @@ func (units UnitPtrs) DoRecursive(f func(*Unit, interface{}) bool, arg interface
 }
 
 func (units Units) ToPtrSlice() (result UnitPtrs) {
-	for idx, _ := range units {
+	for idx := range units {
 		result = append(result, &units[idx])
 	}
 	return
@@ -247,7 +247,7 @@ func (u Unit) GetFormulars() Formulars {
 	return u.formulars
 }
 
-func (units Units) PrepareFormulars(activeOnly bool, additionalCondition ...interface{}) Units {
+func (units Units) PrepareFormulars(activeOnly, ppsOnly bool, additionalCondition ...interface{}) Units {
 	if len(units) == 0 {
 		return units
 	}
@@ -260,6 +260,9 @@ func (units Units) PrepareFormulars(activeOnly bool, additionalCondition ...inte
 	if activeOnly {
 		scope = scope.ActiveOnly()
 	}
+	if ppsOnly {
+		scope = scope.PPSOnly()
+	}
 
 	if len(nums) == 0 && len(ids) == 0 {
 		return units