can add signup notes
parent
8ecfe7a940
commit
46ee8932c1
|
@ -51,13 +51,12 @@ func (r *reviewer) Review(s *models.TownSignup, decision models.SignupDecision)
|
|||
|
||||
func (r *reviewer) AddNote(s *models.TownSignup, content string) error {
|
||||
note := &models.SignupNote{
|
||||
Created: time.Now(),
|
||||
Author: r.adminName,
|
||||
Content: content,
|
||||
Author: r.adminName,
|
||||
Content: content,
|
||||
SignupID: s.ID,
|
||||
}
|
||||
note.Insert(r.db)
|
||||
// TODO
|
||||
return nil
|
||||
|
||||
return note.Insert(r.db)
|
||||
}
|
||||
|
||||
func renderSignup(s models.TownSignup) string {
|
||||
|
@ -221,6 +220,10 @@ func _main() error {
|
|||
}
|
||||
|
||||
app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||
currPage, _ := pages.GetFrontPage()
|
||||
if currPage == "notate" {
|
||||
return event
|
||||
}
|
||||
switch event.Rune() {
|
||||
case 's':
|
||||
advanceSignup()
|
||||
|
|
|
@ -8,16 +8,42 @@ import (
|
|||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
// TODO this is in flux; might want SignupNote and UserNote structs separately
|
||||
type SignupNote struct {
|
||||
ID int64
|
||||
Created time.Time
|
||||
Author string
|
||||
Content string
|
||||
ID int64
|
||||
Created time.Time
|
||||
Author string
|
||||
Content string
|
||||
SignupID int64
|
||||
}
|
||||
|
||||
func (n *SignupNote) Insert(db *sql.DB) error {
|
||||
// TODO
|
||||
n.Created = time.Now()
|
||||
stmt, err := db.Prepare(`
|
||||
INSERT INTO notes (created, author, content, signupid)
|
||||
VALUES (
|
||||
?, ?, ?, ?
|
||||
)`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := stmt.Exec(
|
||||
n.Created.Unix(),
|
||||
n.Author,
|
||||
n.Content,
|
||||
n.SignupID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
liid, err := result.LastInsertId()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
n.ID = liid
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -78,7 +104,7 @@ func (s *TownSignup) All(db *sql.DB) ([]*TownSignup, error) {
|
|||
rows, err := db.Query(`
|
||||
SELECT
|
||||
id, created, email, how, why, links
|
||||
FROM signups WHERE decision = ""`)
|
||||
FROM signups WHERE decision IS NULL`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -86,9 +112,10 @@ func (s *TownSignup) All(db *sql.DB) ([]*TownSignup, error) {
|
|||
out := []*TownSignup{}
|
||||
for rows.Next() {
|
||||
su := &TownSignup{}
|
||||
var timestamp int64
|
||||
if err = rows.Scan(
|
||||
&su.ID,
|
||||
&su.Created,
|
||||
×tamp,
|
||||
&su.Email,
|
||||
&su.How,
|
||||
&su.Why,
|
||||
|
@ -97,6 +124,8 @@ func (s *TownSignup) All(db *sql.DB) ([]*TownSignup, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
su.Created = time.Unix(timestamp, 0)
|
||||
|
||||
// TODO fetch notes
|
||||
out = append(out, su)
|
||||
}
|
||||
|
@ -118,7 +147,7 @@ type TownAccount struct {
|
|||
Emails []string
|
||||
Username string
|
||||
Signup int
|
||||
Notes []AdminNote
|
||||
State UserState
|
||||
Admin bool
|
||||
//Notes []AdminNote
|
||||
State UserState
|
||||
Admin bool
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue