Ajouter models/ pour type Bucket

models.Bucket est utilisé dans cmd/server pour contenir les données
relatives à la documentation dans certaines routes html
This commit is contained in:
Victor Lacasse-Beaudoin 2023-08-19 14:48:08 -04:00
parent 966dc49a9e
commit 0f60e58ec2
3 changed files with 15 additions and 23 deletions

View file

@ -16,6 +16,8 @@ ADD config/ config/
ADD media/ media/ ADD media/ media/
ADD models/ models/
ADD templates/ templates/ ADD templates/ templates/
ADD serverhandlers/ serverhandlers/ ADD serverhandlers/ serverhandlers/

View file

@ -21,6 +21,7 @@ import (
"git.agecem.com/agecem/agecem-org/api" "git.agecem.com/agecem/agecem-org/api"
"git.agecem.com/agecem/agecem-org/config" "git.agecem.com/agecem/agecem-org/config"
"git.agecem.com/agecem/agecem-org/media" "git.agecem.com/agecem/agecem-org/media"
"git.agecem.com/agecem/agecem-org/models"
"git.agecem.com/agecem/agecem-org/public" "git.agecem.com/agecem/agecem-org/public"
"git.agecem.com/agecem/agecem-org/serverhandlers" "git.agecem.com/agecem/agecem-org/serverhandlers"
"git.agecem.com/agecem/agecem-org/templates" "git.agecem.com/agecem/agecem-org/templates"
@ -306,13 +307,7 @@ func handleDocumentation(c echo.Context) error {
return c.Render(http.StatusInternalServerError, "documentation-html", nil) return c.Render(http.StatusInternalServerError, "documentation-html", nil)
} }
type Bucket struct { var data []models.Bucket
Name string
DisplayName string
Documents []string
}
var data []Bucket
for bucket, displayName := range buckets { for bucket, displayName := range buckets {
content, err := client.Call(http.MethodGet, fmt.Sprintf("/v1/bucket/%s", bucket)) content, err := client.Call(http.MethodGet, fmt.Sprintf("/v1/bucket/%s", bucket))
@ -345,7 +340,7 @@ func handleDocumentation(c echo.Context) error {
documents_processed := documents documents_processed := documents
*/ */
data = append(data, Bucket{ data = append(data, models.Bucket{
Name: bucket, Name: bucket,
DisplayName: displayName, DisplayName: displayName,
Documents: documents, Documents: documents,
@ -408,19 +403,13 @@ func handleAdminDocumentsUpload(c echo.Context) error {
return c.Render(http.StatusInternalServerError, "documentation-html", nil) return c.Render(http.StatusInternalServerError, "documentation-html", nil)
} }
type Bucket struct {
Name string
DisplayName string
Documents []string
}
var data struct { var data struct {
Buckets []Bucket Buckets []models.Bucket
Message string Message string
} }
for bucketName, displayName := range buckets { for bucketName, displayName := range buckets {
data.Buckets = append(data.Buckets, Bucket{ data.Buckets = append(data.Buckets, models.Bucket{
Name: bucketName, Name: bucketName,
DisplayName: displayName, DisplayName: displayName,
}) })
@ -430,14 +419,8 @@ func handleAdminDocumentsUpload(c echo.Context) error {
} }
func handleAdminDocumentsUploadPOST(c echo.Context) error { func handleAdminDocumentsUploadPOST(c echo.Context) error {
type Bucket struct {
Name string
DisplayName string
Documents []string
}
var data struct { var data struct {
Buckets []Bucket Buckets []models.Bucket
Message string Message string
} }

7
models/models.go Normal file
View file

@ -0,0 +1,7 @@
package models
type Bucket struct {
Name string
DisplayName string
Documents []string
}