Remove unused HTML endpoints
This commit is contained in:
parent
1aa6d8d58f
commit
0ad97ce4ff
@ -15,44 +15,6 @@ type AccountData struct {
|
||||
Transactions []postgres.GetTransactionsForAccountRow
|
||||
}
|
||||
|
||||
func (h *Handler) account(c *gin.Context) {
|
||||
data := c.MustGet("data").(AlwaysNeededData)
|
||||
|
||||
accountID := c.Param("accountid")
|
||||
accountUUID, err := uuid.Parse(accountID)
|
||||
if err != nil {
|
||||
c.Redirect(http.StatusTemporaryRedirect, "/login")
|
||||
return
|
||||
}
|
||||
|
||||
account, err := h.Service.GetAccount(c.Request.Context(), accountUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
}
|
||||
|
||||
categories, err := h.Service.GetCategories(c.Request.Context(), data.Budget.ID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
}
|
||||
|
||||
transactions, err := h.Service.GetTransactionsForAccount(c.Request.Context(), accountUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
}
|
||||
|
||||
d := AccountData{
|
||||
data,
|
||||
&account,
|
||||
categories,
|
||||
transactions,
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "account.html", d)
|
||||
}
|
||||
|
||||
func (h *Handler) transactionsForAccount(c *gin.Context) {
|
||||
accountID := c.Param("accountid")
|
||||
accountUUID, err := uuid.Parse(accountID)
|
||||
|
@ -1,19 +0,0 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type AccountsData struct {
|
||||
AlwaysNeededData
|
||||
}
|
||||
|
||||
func (h *Handler) accounts(c *gin.Context) {
|
||||
d := AccountsData{
|
||||
c.MustGet("data").(AlwaysNeededData),
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "accounts.html", d)
|
||||
}
|
@ -9,18 +9,7 @@ import (
|
||||
"github.com/pressly/goose/v3"
|
||||
)
|
||||
|
||||
type AdminData struct {
|
||||
}
|
||||
|
||||
func (h *Handler) admin(c *gin.Context) {
|
||||
d := AdminData{}
|
||||
|
||||
c.HTML(http.StatusOK, "admin.html", d)
|
||||
}
|
||||
|
||||
func (h *Handler) clearDatabase(c *gin.Context) {
|
||||
d := AdminData{}
|
||||
|
||||
if err := goose.Reset(h.Service.DB, "schema"); err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
}
|
||||
@ -28,20 +17,6 @@ func (h *Handler) clearDatabase(c *gin.Context) {
|
||||
if err := goose.Up(h.Service.DB, "schema"); err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "admin.html", d)
|
||||
}
|
||||
|
||||
type SettingsData struct {
|
||||
AlwaysNeededData
|
||||
}
|
||||
|
||||
func (h *Handler) settings(c *gin.Context) {
|
||||
d := SettingsData{
|
||||
c.MustGet("data").(AlwaysNeededData),
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "settings.html", d)
|
||||
}
|
||||
|
||||
func (h *Handler) clearBudget(c *gin.Context) {
|
||||
@ -113,5 +88,4 @@ func (h *Handler) cleanNegativeBudget(c *gin.Context) {
|
||||
break
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
@ -43,22 +43,14 @@ func (h *Handler) Serve() {
|
||||
},
|
||||
)
|
||||
|
||||
router.GET("/login", h.login)
|
||||
router.GET("/register", h.register)
|
||||
|
||||
withLogin := router.Group("")
|
||||
withLogin.Use(h.verifyLoginWithRedirect)
|
||||
withLogin.GET("/admin", h.admin)
|
||||
withLogin.GET("/admin/clear-database", h.clearDatabase)
|
||||
|
||||
withBudget := router.Group("")
|
||||
withBudget.Use(h.verifyLoginWithForbidden)
|
||||
withBudget.Use(h.getImportantData)
|
||||
withBudget.GET("/budget/:budgetid/:year/:month", h.budgeting)
|
||||
withBudget.GET("/budget/:budgetid/all-accounts", h.allAccounts)
|
||||
withBudget.GET("/budget/:budgetid/accounts", h.accounts)
|
||||
withBudget.GET("/budget/:budgetid/account/:accountid", h.account)
|
||||
withBudget.GET("/budget/:budgetid/settings", h.settings)
|
||||
withBudget.GET("/budget/:budgetid/settings/clear", h.clearBudget)
|
||||
withBudget.GET("/budget/:budgetid/settings/clean-negative", h.cleanNegativeBudget)
|
||||
withBudget.GET("/budget/:budgetid/transaction/:transactionid", h.transaction)
|
||||
@ -74,6 +66,7 @@ func (h *Handler) Serve() {
|
||||
authenticated.Use(h.verifyLoginWithForbidden)
|
||||
authenticated.GET("/dashboard", h.dashboard)
|
||||
authenticated.GET("/account/:accountid/transactions", h.transactionsForAccount)
|
||||
authenticated.GET("/admin/clear-database", h.clearDatabase)
|
||||
|
||||
withBudget2 := authenticated.Group("")
|
||||
withBudget2.Use(h.getImportantData)
|
||||
|
@ -45,24 +45,6 @@ func (h *Handler) verifyLoginWithRedirect(c *gin.Context) {
|
||||
c.Next()
|
||||
}
|
||||
|
||||
func (h *Handler) login(c *gin.Context) {
|
||||
if _, err := h.verifyLogin(c); err == nil {
|
||||
c.Redirect(http.StatusTemporaryRedirect, "/dashboard")
|
||||
return
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "login.html", nil)
|
||||
}
|
||||
|
||||
func (h *Handler) register(c *gin.Context) {
|
||||
if _, err := h.verifyLogin(c); err == nil {
|
||||
c.Redirect(http.StatusTemporaryRedirect, "/dashboard")
|
||||
return
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "register.html", nil)
|
||||
}
|
||||
|
||||
type loginInformation struct {
|
||||
Password string `json:"password"`
|
||||
User string `json:"user"`
|
||||
|
Loading…
x
Reference in New Issue
Block a user