Ajouter models/ pour type Bucket #109

Merged
vlbeaudoin merged 8 commits from refactor/models into main 2023-08-19 20:31:38 -04:00
3 changed files with 15 additions and 23 deletions
Showing only changes of commit 0f60e58ec2 - Show all commits

View file

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

View file

@ -21,6 +21,7 @@ import (
"git.agecem.com/agecem/agecem-org/api"
"git.agecem.com/agecem/agecem-org/config"
"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/serverhandlers"
"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)
}
type Bucket struct {
Name string
DisplayName string
Documents []string
}
var data []Bucket
var data []models.Bucket
for bucket, displayName := range buckets {
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
*/
data = append(data, Bucket{
data = append(data, models.Bucket{
Name: bucket,
DisplayName: displayName,
Documents: documents,
@ -408,19 +403,13 @@ func handleAdminDocumentsUpload(c echo.Context) error {
return c.Render(http.StatusInternalServerError, "documentation-html", nil)
}
type Bucket struct {
Name string
DisplayName string
Documents []string
}
var data struct {
Buckets []Bucket
Buckets []models.Bucket
Message string
}
for bucketName, displayName := range buckets {
data.Buckets = append(data.Buckets, Bucket{
data.Buckets = append(data.Buckets, models.Bucket{
Name: bucketName,
DisplayName: displayName,
})
@ -430,14 +419,8 @@ func handleAdminDocumentsUpload(c echo.Context) error {
}
func handleAdminDocumentsUploadPOST(c echo.Context) error {
type Bucket struct {
Name string
DisplayName string
Documents []string
}
var data struct {
Buckets []Bucket
Buckets []models.Bucket
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
}