Display only the options of your role
This commit is contained in:
parent
272719a67a
commit
68e6dc7d70
3 changed files with 15 additions and 11 deletions
20
template.go
20
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
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{template "header.html" .S}}
|
||||
|
||||
{{$user := .S.User}}
|
||||
{{$isAdmin := .S.IsAdmin}}
|
||||
{{with .Book}}
|
||||
<script>
|
||||
function delBook(){
|
||||
|
@ -43,7 +43,7 @@ function delBook(){
|
|||
</dl>
|
||||
</div>
|
||||
<div class="span3">
|
||||
{{if $user}}
|
||||
{{if $isAdmin}}
|
||||
<div class="row">
|
||||
<div class="btn-group pull-right">
|
||||
<a href="/edit/{{.Id}}" class="btn btn-primary"><i class="icon-pencil"></i> Edit</a>
|
||||
|
|
|
@ -65,9 +65,11 @@
|
|||
<i class="icon-user icon-white"></i> {{.User}}<b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
{{if .IsAdmin}}
|
||||
<li><a href="/new/"><i class="icon-book"></i> New books</a></li>
|
||||
<li><a href="/news/edit"><i class="icon-certificate"></i> Edit news</a></li>
|
||||
<li class="divider"></li>
|
||||
{{end}}
|
||||
<li><a href="/settings/"><i class="icon-wrench"></i> Settings</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="/logout/"><i class="icon-off"></i> Log Out</a></li>
|
||||
|
|
Reference in a new issue