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.
|
||||
filterExplicit = r.FormValue("explicit")
|
||||
filterVisibility = r.FormValue("visibility")
|
||||
adminView = r.FormValue("admin_view") == "true"
|
||||
sort = r.FormValue("sort")
|
||||
sortOK bool
|
||||
)
|
||||
|
@ -60,7 +61,7 @@ func SiteGallery() http.HandlerFunc {
|
|||
Sort: sort,
|
||||
}
|
||||
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.
|
||||
var userIDs = []uint64{}
|
||||
|
@ -93,6 +94,7 @@ func SiteGallery() http.HandlerFunc {
|
|||
"Sort": sort,
|
||||
"FilterExplicit": filterExplicit,
|
||||
"FilterVisibility": filterVisibility,
|
||||
"AdminView": adminView,
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
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 (
|
||||
p = []*Photo{}
|
||||
query *gorm.DB
|
||||
|
||||
// Get the user ID and their preferences.
|
||||
userID = user.ID
|
||||
adminView = user.IsAdmin // Admins see everything on the site.
|
||||
explicitOK = user.Explicit // User opted-in for explicit content
|
||||
|
||||
blocklist = BlockedUserIDs(userID)
|
||||
|
@ -171,6 +170,9 @@ func PaginateGalleryPhotos(user *User, filterExplicit, filterVisibility string,
|
|||
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.
|
||||
friendIDs = append(friendIDs, userID)
|
||||
|
||||
|
|
|
@ -38,10 +38,10 @@
|
|||
|
||||
<div class="media block">
|
||||
<div class="media-left">
|
||||
{{template "avatar-64x64" .}}
|
||||
{{template "avatar-64x64" .User}}
|
||||
</div>
|
||||
<div class="media-content">
|
||||
<p class="title is-4">{{.NameOrUsername}}</p>
|
||||
<p class="title is-4">{{.User.NameOrUsername}}</p>
|
||||
<p class="subtitle is-6">
|
||||
<span class="icon"><i class="fa fa-user"></i></span>
|
||||
<a href="/u/{{.User.Username}}" target="_blank">{{.User.Username}}</a>
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
|
||||
<div class="media block">
|
||||
<div class="media-left">
|
||||
{{template "avatar-64x64" .}}
|
||||
{{template "avatar-64x64" .User}}
|
||||
</div>
|
||||
<div class="media-content">
|
||||
<p class="title is-4">{{.NameOrUsername}}</p>
|
||||
<p class="title is-4">{{.User.NameOrUsername}}</p>
|
||||
<p class="subtitle is-6">
|
||||
<span class="icon"><i class="fa fa-user"></i></span>
|
||||
<a href="/u/{{.User.Username}}" target="_blank">{{.User.Username}}</a>
|
||||
|
|
|
@ -253,6 +253,20 @@
|
|||
</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 class="has-text-centered">
|
||||
<a href="/photo/gallery" class="button">Reset</a>
|
||||
|
@ -356,6 +370,7 @@
|
|||
{{template "card-body" .}}
|
||||
|
||||
<!-- Like & Comments buttons -->
|
||||
{{if not $Root.AdminView}}
|
||||
<div class="mt-4 columns is-centered is-mobile is-gapless">
|
||||
<div class="column is-narrow mr-1">
|
||||
{{$Like := $Root.LikeMap.Get .ID}}
|
||||
|
@ -379,6 +394,7 @@
|
|||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<footer class="card-footer">
|
||||
|
@ -456,6 +472,7 @@
|
|||
{{template "card-body" .}}
|
||||
|
||||
<!-- Like & Comments buttons -->
|
||||
{{if not $Root.AdminView}}
|
||||
<div class="mt-4 columns is-centered is-mobile is-gapless">
|
||||
<div class="column is-narrow mr-1">
|
||||
{{$Like := $Root.LikeMap.Get .ID}}
|
||||
|
@ -479,6 +496,7 @@
|
|||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<footer class="card-footer">
|
||||
|
|
Loading…
Reference in New Issue
Block a user