From 68e6dc7d705311a5e1718680e4abc481cbea9fc4 Mon Sep 17 00:00:00 2001 From: Las Zenow Date: Fri, 19 Jul 2013 00:37:07 +0200 Subject: [PATCH] Display only the options of your role --- template.go | 20 +++++++++++--------- templates/book.html | 4 ++-- templates/header.html | 2 ++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/template.go b/template.go index 4d1ecaa..b5b6cd7 100644 --- a/template.go +++ b/template.go @@ -6,15 +6,16 @@ import ( ) type Status struct { - Search string - User string - Notif []Notification - Home bool - About bool - News bool - Upload bool - Stats bool - Help bool + Search string + User string + IsAdmin bool + Notif []Notification + Home bool + About bool + News bool + Upload bool + Stats bool + Help bool } func GetStatus(w http.ResponseWriter, r *http.Request) Status { @@ -22,6 +23,7 @@ func GetStatus(w http.ResponseWriter, r *http.Request) Status { sess := GetSession(r) sess.Save(w, r) s.User = sess.User + s.IsAdmin = sess.IsAdmin() s.Notif = sess.Notif return s } diff --git a/templates/book.html b/templates/book.html index efb4eed..14b534b 100644 --- a/templates/book.html +++ b/templates/book.html @@ -1,6 +1,6 @@ {{template "header.html" .S}} -{{$user := .S.User}} +{{$isAdmin := .S.IsAdmin}} {{with .Book}}