Clean out a bunch of unused nuisance report fields
Feedback had us simplify the form significantly
This commit is contained in:
parent
612f2fba77
commit
1fbe41b725
10 changed files with 264 additions and 1220 deletions
|
|
@ -3,7 +3,6 @@ package rmo
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/config"
|
||||
|
|
@ -57,16 +56,9 @@ func postNuisance(w http.ResponseWriter, r *http.Request) {
|
|||
respondError(w, "Failed to parse form", err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
tod_early := boolFromForm(r, "tod-early")
|
||||
tod_day := boolFromForm(r, "tod-day")
|
||||
tod_evening := boolFromForm(r, "tod-evening")
|
||||
tod_night := boolFromForm(r, "tod-night")
|
||||
|
||||
source_stagnant := boolFromForm(r, "source-stagnant")
|
||||
source_container := boolFromForm(r, "source-container")
|
||||
source_roof := boolFromForm(r, "source-container")
|
||||
|
||||
request_call := boolFromForm(r, "request-call")
|
||||
source_gutters := boolFromForm(r, "source-gutters")
|
||||
|
||||
duration_str := postFormValueOrNone(r, "duration")
|
||||
var duration enums.PublicreportNuisancedurationtype
|
||||
|
|
@ -76,14 +68,6 @@ func postNuisance(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
inspection_type_str := postFormValueOrNone(r, "inspection-type")
|
||||
var inspection_type enums.PublicreportNuisanceinspectiontype
|
||||
err = inspection_type.Scan(inspection_type_str)
|
||||
if err != nil {
|
||||
respondError(w, fmt.Sprintf("Failed to interpret 'inspection-type' of '%s'", inspection_type_str), err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
source_location_str := postFormValueOrNone(r, "source-location")
|
||||
var source_location enums.PublicreportNuisancelocationtype
|
||||
err = source_location.Scan(source_location_str)
|
||||
|
|
@ -91,33 +75,8 @@ func postNuisance(w http.ResponseWriter, r *http.Request) {
|
|||
respondError(w, fmt.Sprintf("Failed to interpret 'source-location' of '%s'", source_location_str), err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
preferred_date_range_str := postFormValueOrNone(r, "preferred-date-range")
|
||||
var preferred_date_range enums.PublicreportNuisancepreferreddaterangetype
|
||||
err = preferred_date_range.Scan(preferred_date_range_str)
|
||||
if err != nil {
|
||||
respondError(w, fmt.Sprintf("Failed to interpret 'preferred-date-range' of '%s'", preferred_date_range_str), err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
preferred_time_str := postFormValueOrNone(r, "preferred-time")
|
||||
var preferred_time enums.PublicreportNuisancepreferredtimetype
|
||||
err = preferred_time.Scan(preferred_time_str)
|
||||
if err != nil {
|
||||
respondError(w, fmt.Sprintf("Failed to interpret 'preferred-time' of '%s'", preferred_time_str), err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
severity_str := r.PostFormValue("severity")
|
||||
severity, err := strconv.ParseInt(severity_str, 10, 16)
|
||||
if err != nil {
|
||||
respondError(w, fmt.Sprintf("Failed to interpret 'severity' of '%s' as an integer", severity_str), err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
source_description := r.PostFormValue("source-description")
|
||||
address := r.PostFormValue("address")
|
||||
name := r.PostFormValue("name")
|
||||
phone := r.PostFormValue("phone")
|
||||
email := r.PostFormValue("email")
|
||||
additional_info := r.PostFormValue("additional-info")
|
||||
|
||||
public_id, err := GenerateReportID()
|
||||
|
|
@ -126,33 +85,22 @@ func postNuisance(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
log.Info().Str("address", address).Str("name", name).Msg("Got report")
|
||||
setter := models.PublicreportNuisanceSetter{
|
||||
AdditionalInfo: omit.From(additional_info),
|
||||
Created: omit.From(time.Now()),
|
||||
Duration: omit.From(duration),
|
||||
Email: omit.From(email),
|
||||
InspectionType: omit.From(inspection_type),
|
||||
Location: omitnull.FromPtr[string](nil),
|
||||
PreferredDateRange: omit.From(preferred_date_range),
|
||||
PreferredTime: omit.From(preferred_time),
|
||||
PublicID: omit.From(public_id),
|
||||
RequestCall: omit.From(request_call),
|
||||
Severity: omit.From(int16(severity)),
|
||||
SourceContainer: omit.From(source_container),
|
||||
SourceDescription: omit.From(source_description),
|
||||
SourceRoof: omit.From(source_roof),
|
||||
SourceLocation: omit.From(source_location),
|
||||
SourceStagnant: omit.From(source_stagnant),
|
||||
Status: omit.From(enums.PublicreportReportstatustypeReported),
|
||||
TimeOfDayDay: omit.From(tod_day),
|
||||
TimeOfDayEarly: omit.From(tod_early),
|
||||
TimeOfDayEvening: omit.From(tod_evening),
|
||||
TimeOfDayNight: omit.From(tod_night),
|
||||
ReporterAddress: omit.From(address),
|
||||
ReporterEmail: omit.From(email),
|
||||
ReporterName: omit.From(name),
|
||||
ReporterPhone: omit.From(phone),
|
||||
AdditionalInfo: omit.From(additional_info),
|
||||
Created: omit.From(time.Now()),
|
||||
Duration: omit.From(duration),
|
||||
Location: omitnull.FromPtr[string](nil),
|
||||
PublicID: omit.From(public_id),
|
||||
SourceContainer: omit.From(source_container),
|
||||
SourceDescription: omit.From(source_description),
|
||||
SourceGutter: omit.From(source_gutters),
|
||||
SourceLocation: omit.From(source_location),
|
||||
SourceStagnant: omit.From(source_stagnant),
|
||||
Status: omit.From(enums.PublicreportReportstatustypeReported),
|
||||
ReporterAddress: omit.FromPtr[string](nil),
|
||||
ReporterEmail: omit.FromPtr[string](nil),
|
||||
ReporterName: omit.FromPtr[string](nil),
|
||||
ReporterPhone: omit.FromPtr[string](nil),
|
||||
}
|
||||
nuisance, err := models.PublicreportNuisances.Insert(&setter).One(r.Context(), db.PGInstance.BobDB)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
|
||||
<!-- Report Form -->
|
||||
<form id="mosquitoNuisanceForm" action="{{ .URL.NuisanceSubmit }}" method="POST" enctype="multipart/form-data">
|
||||
<!-- Location & Contact Section -->
|
||||
<!-- Location Section -->
|
||||
<div class="form-section">
|
||||
<div class="section-heading">
|
||||
<i class="bi bi-geo-alt"></i>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue