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:
parent
a0ac5c0674
commit
fe2041f22b
7 changed files with 99 additions and 32 deletions
32
platform/types/evidence.go
Normal file
32
platform/types/evidence.go
Normal 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
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue