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