mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
edit button
This commit is contained in:
@@ -1 +1,15 @@
|
||||
package dbmodels
|
||||
|
||||
func IsAdminOrEditor(user *FixedUser) bool {
|
||||
if user == nil {
|
||||
return false
|
||||
}
|
||||
return user.Role == "Admin" || user.Role == "Editor"
|
||||
}
|
||||
|
||||
func IsAdmin(user *FixedUser) bool {
|
||||
if user == nil {
|
||||
return false
|
||||
}
|
||||
return user.Role == "Admin"
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels"
|
||||
"github.com/Theodor-Springmann-Stiftung/musenalm/helpers/functions"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"golang.org/x/net/websocket"
|
||||
@@ -139,6 +140,10 @@ func (e *Engine) funcs() error {
|
||||
// TOC
|
||||
e.AddFunc("TOCFromHTML", functions.TOCFromHTML)
|
||||
|
||||
// User Functions
|
||||
e.AddFunc("IsAdminOrEditor", dbmodels.IsAdminOrEditor)
|
||||
e.AddFunc("IsAdmin", dbmodels.IsAdmin)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -19,10 +19,15 @@
|
||||
|
||||
|
||||
<div class="container-oversize mt-12 pb-0 mb-0">
|
||||
<div class="pb-1.5 ml-32"><i class="ri-book-line"></i> Almanach</div>
|
||||
{{- if $model.request.user -}}
|
||||
DDD
|
||||
<div class="pb-1.5 mx-32 flex flex-row items-center justify-between gap-2">
|
||||
<div><i class="ri-book-line"></i> Almanach</div>
|
||||
{{- if (IsAdminOrEditor $model.request.user) -}}
|
||||
<div>
|
||||
<i class="ri-edit-line"></i>
|
||||
<a href="/almanach/{{ $model.result.Entry.MusenalmID }}/edit">Bearbeiten</a>
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
<div class="pt-0 {{ if $hasContents -}}contentsentrydata{{- end -}}" id="entrydata">
|
||||
<div class="container-normal !py-8">
|
||||
<div class="flex flex-col">
|
||||
|
||||
Reference in New Issue
Block a user