Explicit admin filter for the site gallery
* For admins, make it a specific opt-in filter for the Site Gallery to show all pictures regardless of friendship or grant (for moderation purposes). On this view, Like and Comment buttons are taken away. Non-admins are not shown the option and the back-end ignores the parameter for them. * Fix user avatars on compose and admin actions page.
This commit is contained in:
parent
2ef72fef0f
commit
90b97708f7
|
@ -27,6 +27,7 @@ func SiteGallery() http.HandlerFunc {
|
||||||
// Search filters.
|
// Search filters.
|
||||||
filterExplicit = r.FormValue("explicit")
|
filterExplicit = r.FormValue("explicit")
|
||||||
filterVisibility = r.FormValue("visibility")
|
filterVisibility = r.FormValue("visibility")
|
||||||
|
adminView = r.FormValue("admin_view") == "true"
|
||||||
sort = r.FormValue("sort")
|
sort = r.FormValue("sort")
|
||||||
sortOK bool
|
sortOK bool
|
||||||
)
|
)
|
||||||
|
@ -60,7 +61,7 @@ func SiteGallery() http.HandlerFunc {
|
||||||
Sort: sort,
|
Sort: sort,
|
||||||
}
|
}
|
||||||
pager.ParsePage(r)
|
pager.ParsePage(r)
|
||||||
photos, err := models.PaginateGalleryPhotos(currentUser, filterExplicit, filterVisibility, pager)
|
photos, err := models.PaginateGalleryPhotos(currentUser, filterExplicit, filterVisibility, adminView, pager)
|
||||||
|
|
||||||
// Bulk load the users associated with these photos.
|
// Bulk load the users associated with these photos.
|
||||||
var userIDs = []uint64{}
|
var userIDs = []uint64{}
|
||||||
|
@ -93,6 +94,7 @@ func SiteGallery() http.HandlerFunc {
|
||||||
"Sort": sort,
|
"Sort": sort,
|
||||||
"FilterExplicit": filterExplicit,
|
"FilterExplicit": filterExplicit,
|
||||||
"FilterVisibility": filterVisibility,
|
"FilterVisibility": filterVisibility,
|
||||||
|
"AdminView": adminView,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := tmpl.Execute(w, r, vars); err != nil {
|
if err := tmpl.Execute(w, r, vars); err != nil {
|
||||||
|
|
|
@ -154,14 +154,13 @@ PaginateGalleryPhotos gets a page of all public user photos for the site gallery
|
||||||
|
|
||||||
Admin view returns ALL photos regardless of Gallery status.
|
Admin view returns ALL photos regardless of Gallery status.
|
||||||
*/
|
*/
|
||||||
func PaginateGalleryPhotos(user *User, filterExplicit, filterVisibility string, pager *Pagination) ([]*Photo, error) {
|
func PaginateGalleryPhotos(user *User, filterExplicit, filterVisibility string, adminView bool, pager *Pagination) ([]*Photo, error) {
|
||||||
var (
|
var (
|
||||||
p = []*Photo{}
|
p = []*Photo{}
|
||||||
query *gorm.DB
|
query *gorm.DB
|
||||||
|
|
||||||
// Get the user ID and their preferences.
|
// Get the user ID and their preferences.
|
||||||
userID = user.ID
|
userID = user.ID
|
||||||
adminView = user.IsAdmin // Admins see everything on the site.
|
|
||||||
explicitOK = user.Explicit // User opted-in for explicit content
|
explicitOK = user.Explicit // User opted-in for explicit content
|
||||||
|
|
||||||
blocklist = BlockedUserIDs(userID)
|
blocklist = BlockedUserIDs(userID)
|
||||||
|
@ -171,6 +170,9 @@ func PaginateGalleryPhotos(user *User, filterExplicit, filterVisibility string,
|
||||||
placeholders = []interface{}{}
|
placeholders = []interface{}{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Admins see everything on the site (only an admin user can get an admin view).
|
||||||
|
adminView = user.IsAdmin && adminView
|
||||||
|
|
||||||
// Include ourself in our friend IDs.
|
// Include ourself in our friend IDs.
|
||||||
friendIDs = append(friendIDs, userID)
|
friendIDs = append(friendIDs, userID)
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,10 @@
|
||||||
|
|
||||||
<div class="media block">
|
<div class="media block">
|
||||||
<div class="media-left">
|
<div class="media-left">
|
||||||
{{template "avatar-64x64" .}}
|
{{template "avatar-64x64" .User}}
|
||||||
</div>
|
</div>
|
||||||
<div class="media-content">
|
<div class="media-content">
|
||||||
<p class="title is-4">{{.NameOrUsername}}</p>
|
<p class="title is-4">{{.User.NameOrUsername}}</p>
|
||||||
<p class="subtitle is-6">
|
<p class="subtitle is-6">
|
||||||
<span class="icon"><i class="fa fa-user"></i></span>
|
<span class="icon"><i class="fa fa-user"></i></span>
|
||||||
<a href="/u/{{.User.Username}}" target="_blank">{{.User.Username}}</a>
|
<a href="/u/{{.User.Username}}" target="_blank">{{.User.Username}}</a>
|
||||||
|
|
|
@ -26,10 +26,10 @@
|
||||||
|
|
||||||
<div class="media block">
|
<div class="media block">
|
||||||
<div class="media-left">
|
<div class="media-left">
|
||||||
{{template "avatar-64x64" .}}
|
{{template "avatar-64x64" .User}}
|
||||||
</div>
|
</div>
|
||||||
<div class="media-content">
|
<div class="media-content">
|
||||||
<p class="title is-4">{{.NameOrUsername}}</p>
|
<p class="title is-4">{{.User.NameOrUsername}}</p>
|
||||||
<p class="subtitle is-6">
|
<p class="subtitle is-6">
|
||||||
<span class="icon"><i class="fa fa-user"></i></span>
|
<span class="icon"><i class="fa fa-user"></i></span>
|
||||||
<a href="/u/{{.User.Username}}" target="_blank">{{.User.Username}}</a>
|
<a href="/u/{{.User.Username}}" target="_blank">{{.User.Username}}</a>
|
||||||
|
|
|
@ -253,6 +253,20 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{if .CurrentUser.IsAdmin}}
|
||||||
|
<div class="column">
|
||||||
|
<div class="field">
|
||||||
|
<label class="label has-text-danger" for="admin_view">Admin view:</label>
|
||||||
|
<div class="select is-fullwidth">
|
||||||
|
<select id="admin_view" name="admin_view">
|
||||||
|
<option value="">Default (disabled)</option>
|
||||||
|
<option value="true"{{if .AdminView}} selected{{end}}>Show all photos</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="has-text-centered">
|
<div class="has-text-centered">
|
||||||
<a href="/photo/gallery" class="button">Reset</a>
|
<a href="/photo/gallery" class="button">Reset</a>
|
||||||
|
@ -356,6 +370,7 @@
|
||||||
{{template "card-body" .}}
|
{{template "card-body" .}}
|
||||||
|
|
||||||
<!-- Like & Comments buttons -->
|
<!-- Like & Comments buttons -->
|
||||||
|
{{if not $Root.AdminView}}
|
||||||
<div class="mt-4 columns is-centered is-mobile is-gapless">
|
<div class="mt-4 columns is-centered is-mobile is-gapless">
|
||||||
<div class="column is-narrow mr-1">
|
<div class="column is-narrow mr-1">
|
||||||
{{$Like := $Root.LikeMap.Get .ID}}
|
{{$Like := $Root.LikeMap.Get .ID}}
|
||||||
|
@ -379,6 +394,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer class="card-footer">
|
<footer class="card-footer">
|
||||||
|
@ -456,6 +472,7 @@
|
||||||
{{template "card-body" .}}
|
{{template "card-body" .}}
|
||||||
|
|
||||||
<!-- Like & Comments buttons -->
|
<!-- Like & Comments buttons -->
|
||||||
|
{{if not $Root.AdminView}}
|
||||||
<div class="mt-4 columns is-centered is-mobile is-gapless">
|
<div class="mt-4 columns is-centered is-mobile is-gapless">
|
||||||
<div class="column is-narrow mr-1">
|
<div class="column is-narrow mr-1">
|
||||||
{{$Like := $Root.LikeMap.Get .ID}}
|
{{$Like := $Root.LikeMap.Get .ID}}
|
||||||
|
@ -479,6 +496,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer class="card-footer">
|
<footer class="card-footer">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user