Compare commits

...

2 Commits

Author SHA1 Message Date
b5f1b17684 Fix loading of tickets missing range class. 2025-04-23 11:54:45 +01:00
f9853c921d Refactoring finalised ... I think. 2025-04-23 11:30:03 +01:00
4 changed files with 14 additions and 2 deletions

View File

@@ -47,6 +47,7 @@ func MessagesInboxHandler(db *sql.DB) http.HandlerFunc {
tmpl := templateHelpers.LoadTemplateFiles("messages.html", "templates/account/messages/index.html")
if err := tmpl.ExecuteTemplate(w, "layout", context); err != nil {
// ToDo: Make this load all error pages without defining explictly.
templateHelpers.RenderError(w, r, 500)
}
}

View File

@@ -91,6 +91,7 @@ func TemplateFuncs() template.FuncMap {
return ""
}
},
"rangeClass": rangeClass,
}
}
@@ -132,7 +133,6 @@ func PageRange(current, total int) []int {
return pages
}
// ToDo: Should be ball range class, and should it even be here?
func rangeClass(n int) string {
switch {
case n >= 1 && n <= 9:

View File

@@ -15,7 +15,7 @@ var db *sql.DB
func InitDB(filepath string) *sql.DB {
var err error
cfg := config.Get()
db, err := sql.Open("sqlite", filepath)
db, err = sql.Open("sqlite", filepath)
if err != nil {
log.Fatal("❌ Failed to open DB:", err)
}
@@ -29,6 +29,7 @@ func InitDB(filepath string) *sql.DB {
SchemaUsersMessages,
SchemaUsersNotifications,
SchemaAuditLog,
SchemaAuditLogin,
SchemaLogTicketMatching,
SchemaAdminAccessLog,
SchemaNewAuditLog,

View File

@@ -175,6 +175,16 @@ CREATE TABLE IF NOT EXISTS audit_log (
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
);`
const SchemaAuditLogin = `
CREATE TABLE IF NOT EXISTS audit_login (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT,
success BOOLEAN,
ip TEXT,
user_agent TEXT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
);`
const SchemaSyndicates = `
CREATE TABLE IF NOT EXISTS syndicates (
id INTEGER PRIMARY KEY AUTOINCREMENT,