Update and consolidate to-do list

This commit is contained in:
Brandon Dyck 2020-09-27 22:32:01 -06:00
parent 591d81ff13
commit 0ff6402c34
3 changed files with 28 additions and 13 deletions

View File

@ -22,8 +22,6 @@ type Store struct {
}
func NewStore(filename string, genString GenString) (*Store, error) {
// TODO This stat needs to change, though I can't remember how, now that
// SQLite has been updated.
var needCreate bool
if _, err := os.Stat(filename); os.IsNotExist(err) {
needCreate = true

View File

@ -268,7 +268,6 @@ func (h *handler) handleCreate(w http.ResponseWriter, r *http.Request) {
}
func (h *handler) handleDoCreate(w http.ResponseWriter, r *http.Request) {
// TODO consider redirecting to admin
earliest, err := date.Parse(formDateLayout, r.FormValue(fieldNameEarliest))
if invalidForm(w, err) {
return
@ -351,7 +350,6 @@ func (h *handler) handleCreateSuccess(w http.ResponseWriter, r *http.Request) {
func (h *handler) handleAdmin(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
eventID := query.Get(fieldNameEventID)
// TODO authenticate with admin code
metadata, err := h.store.GetEventMetadata(context.Background(), back.GetEventMetadataQuery{
AlphaID: eventID,
})
@ -367,7 +365,6 @@ func (h *handler) handleAdmin(w http.ResponseWriter, r *http.Request) {
return
}
// TODO show results (number of responses, grid)
body := hm.Terms{
e.Form()(
e.Label(a.For(fieldNameEventName))(hm.Text("Event name")),
@ -381,8 +378,6 @@ func (h *handler) handleAdmin(w http.ResponseWriter, r *http.Request) {
e.Textarea(a.Name(fieldNameDescription))(hm.Text(metadata.Description)),
e.Br(),
// TODO Should the date fields be disabled, or should we cull invalid
// response times after changing event dates?
e.Label(a.For(fieldNameEarliest))(hm.Text("Earliest date")),
e.Input(
a.Name(fieldNameEarliest),
@ -412,8 +407,6 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func (h *handler) writePage(w io.Writer, title string, contents hm.Term) error {
// TODO Need optional subtitles, and titles should be optional.
// Take a Page struct with title, subtitle, and contents.
page := e.Html()(
e.Head()(
e.Title()(hm.Text(h.title+" — "+title)),

View File

@ -1,8 +1,32 @@
Essential:
------------
Show results on admin page
Make earliest and latest dates required for creation
Prevent blank event names and guest names
Consider some front-end, regex-based field validation
Authenticate admin page with admin code
It might be sufficient to require that when getting the response summary.
Deal with the admin date fields
Should the date fields be disabled, or should we cull invalid
response times after changing event dates?
Consider redirecting from /create/do to admin
Cleanup:
------------
Make the sqlite pool size configurable
Get rid of the surrogate keys
Give response (and therefore response_time) a composite key
Rename all of the alpha ID nonsense
Show results on admin page
Get rid of the Stat call in NewStore.
I can't remember the details. I think the old version
of sqlitex was panicking if I failed to open a DB file.
Maybe instead of statting, I would try to open an
existing file, but instead create it on failure.
Add optional subtitles to (*front.handler).writePage
Take a Page struct with title, subtitle, and contents.
Make titles optional in (*front.handler).writePage
More features:
---------------
Allow updating metadata on admin page
Prevent blank event names and guest names
Make earliest and latest dates required for creation
Consider some front-end, regex-based field validation