Add an evidence field to compliance reports

This allows us to show a page with information about what the district
is concerned about when asking the user to fill a report.
This commit is contained in:
Eli Ribble 2026-04-21 21:35:40 +00:00
parent a0ac5c0674
commit fe2041f22b
No known key found for this signature in database
7 changed files with 99 additions and 32 deletions

View file

@ -0,0 +1,32 @@
package types
import (
"fmt"
"github.com/gorilla/mux"
"github.com/rs/zerolog/log"
)
type Evidence interface {
PopulateURL(*mux.Router) error
}
type EvidenceComplianceReportRequest struct {
ComplianceReportRequestPublicID string
URL string
}
func (e *EvidenceComplianceReportRequest) PopulateURL(r *mux.Router) error {
route_name := "compliance-request.image.pool.ByIDGet"
handler := r.Get(route_name)
if handler == nil {
return fmt.Errorf("failed to get handler '%s'", route_name)
}
uri, err := handler.URL("public_id", e.ComplianceReportRequestPublicID)
if err != nil {
return fmt.Errorf("failed to create uri from '%s'", e.ComplianceReportRequestPublicID)
}
uri.Scheme = "https"
e.URL = uri.String()
log.Debug().Str("url", e.URL).Msg("populated evidence URL")
return nil
}

View file

@ -5,19 +5,20 @@ import (
)
type PublicReport struct {
Address Address `db:"address" json:"address"`
Created time.Time `db:"created" json:"created"`
ID int32 `db:"id" json:"-"`
Images []Image `db:"images" json:"images"`
Location *Location `db:"location" json:"location"`
Log []LogEntry `db:"-" json:"log"`
DistrictID *int32 `db:"organization_id" json:"-"`
District *string `db:"-" json:"district"`
PublicID string `db:"public_id" json:"public_id"`
Reporter Contact `db:"reporter" json:"reporter"`
Status string `db:"status" json:"status"`
Type string `db:"report_type" json:"type"`
URI string `db:"-" json:"uri"`
Address Address `db:"address" json:"address"`
Created time.Time `db:"created" json:"created"`
Evidence []*EvidenceComplianceReportRequest `db:"-" json:"evidence"`
ID int32 `db:"id" json:"-"`
Images []Image `db:"images" json:"images"`
Location *Location `db:"location" json:"location"`
Log []LogEntry `db:"-" json:"log"`
DistrictID *int32 `db:"organization_id" json:"-"`
District *string `db:"-" json:"district"`
PublicID string `db:"public_id" json:"public_id"`
Reporter Contact `db:"reporter" json:"reporter"`
Status string `db:"status" json:"status"`
Type string `db:"report_type" json:"type"`
URI string `db:"-" json:"uri"`
}
type PublicReportCompliance struct {
PublicReport