49 lines
909 B
Go
49 lines
909 B
Go
package controllers
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"git.dynamicdiscord.de/malobeo/portal/services"
|
|
)
|
|
|
|
type CardController struct{}
|
|
|
|
func (gc *CardController) CardHandler(c *gin.Context) {
|
|
action := c.PostForm("action")
|
|
idStr := c.Param("id")
|
|
id, err := strconv.Atoi(idStr)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
c.HTML(http.StatusBadRequest, "groups.html", gin.H{"error": err})
|
|
return
|
|
}
|
|
|
|
if action == "activate" {
|
|
_, err := services.Cards.SetActive(c, int32(id), true)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
c.HTML(http.StatusBadRequest, "groups.html", gin.H{"error": err})
|
|
return
|
|
}
|
|
}
|
|
|
|
if action == "deactivate" {
|
|
_, err := services.Cards.SetActive(c, int32(id), false)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
c.HTML(http.StatusBadRequest, "groups.html", gin.H{"error": err})
|
|
return
|
|
}
|
|
}
|
|
|
|
groupC := GroupController{}
|
|
groupC.GroupView(c)
|
|
}
|