usercanclose
This commit is contained in:
parent
20389272ab
commit
26952fc455
@ -243,6 +243,17 @@ func SettingsHandler(ctx *gin.Context) {
|
||||
go table.UpdatePanelSettings(guildId, panelTitle, panelContent, int(panelColour))
|
||||
}
|
||||
|
||||
// Users can close
|
||||
usersCanCloseChan := make(chan bool)
|
||||
go table.IsUserCanClose(guildId, usersCanCloseChan)
|
||||
usersCanClose := <-usersCanCloseChan
|
||||
|
||||
usersCanCloseStr := ctx.Query("userscanclose")
|
||||
if csrfCorrect {
|
||||
usersCanClose = usersCanCloseStr == "on"
|
||||
table.SetUserCanClose(guildId, usersCanClose)
|
||||
}
|
||||
|
||||
utils.Respond(ctx, template.TemplateSettings.Render(map[string]interface{}{
|
||||
"name": store.Get("name").(string),
|
||||
"guildId": guildIdStr,
|
||||
@ -260,6 +271,7 @@ func SettingsHandler(ctx *gin.Context) {
|
||||
"paneltitle": panelTitle,
|
||||
"panelcontent": panelContent,
|
||||
"panelcolour": strconv.FormatInt(int64(panelColour), 16),
|
||||
"usersCanClose": usersCanClose,
|
||||
}))
|
||||
} else {
|
||||
ctx.Redirect(302, "/login")
|
||||
|
27
database/table/userscanclose.go
Normal file
27
database/table/userscanclose.go
Normal file
@ -0,0 +1,27 @@
|
||||
package table
|
||||
|
||||
import "github.com/TicketsBot/GoPanel/database"
|
||||
|
||||
type UserCanClose struct {
|
||||
Guild int64 `gorm:"column:GUILDID;unique;primary_key"`
|
||||
CanClose *bool `gorm:"column:CANCLOSE"`
|
||||
}
|
||||
|
||||
func (UserCanClose) TableName() string {
|
||||
return "usercanclose"
|
||||
}
|
||||
|
||||
func IsUserCanClose(guild int64, ch chan bool) {
|
||||
var node UserCanClose
|
||||
database.Database.Where(UserCanClose{Guild: guild}).First(&node)
|
||||
|
||||
if node.CanClose == nil {
|
||||
ch <- true
|
||||
} else {
|
||||
ch <- *node.CanClose
|
||||
}
|
||||
}
|
||||
|
||||
func SetUserCanClose(guild int64, value bool) {
|
||||
database.Database.Where(&UserCanClose{Guild: guild}).Assign(&UserCanClose{CanClose: &value}).FirstOrCreate(&UserCanClose{})
|
||||
}
|
@ -42,7 +42,7 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 pr-1">
|
||||
<div class="col-md-5 pr-1">
|
||||
<label>Archive Channel</label>
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
@ -56,7 +56,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 px-1">
|
||||
<div class="col-md-5 px-1">
|
||||
<div class="form-group">
|
||||
<label>Channel Category</label>
|
||||
<select class="form-control" name="category">
|
||||
@ -66,6 +66,15 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 px-1">
|
||||
<div class="form-group">
|
||||
<label>Allow users to close tickets</label>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="userscanclose" value="on" {{#usersCanClose}}checked{{/usersCanClose}} style="width:30px;height:30px;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
Loading…
x
Reference in New Issue
Block a user