Browse Source

User pages: include removed posts for admins

merge-requests/32/head
Deimos 6 years ago
parent
commit
e278dd9cfb
  1. 5
      tildes/tildes/models/user/user.py
  2. 12
      tildes/tildes/views/user.py

5
tildes/tildes/models/user/user.py

@ -218,3 +218,8 @@ class User(DatabaseModel):
return self.permissions
raise ValueError("Unknown permissions format")
@property
def is_admin(self) -> bool:
"""Return whether the user has admin permissions."""
return "admin" in self.auth_principals

12
tildes/tildes/views/user.py

@ -31,8 +31,8 @@ def _get_user_recent_activity(
.join_all_relationships()
)
# include removed comments if the user's looking at their own page
if user == request.user:
# include removed comments if the user's looking at their own page or is an admin
if user == request.user or request.user.is_admin:
query = query.include_removed()
comments = query.all()
@ -45,8 +45,8 @@ def _get_user_recent_activity(
.join_all_relationships()
)
# include removed topics if the user's looking at their own page
if user == request.user:
# include removed topics if the user's looking at their own page or is an admin
if user == request.user or request.user.is_admin:
query = query.include_removed()
topics = query.all()
@ -89,8 +89,8 @@ def get_user(
query = query.join_all_relationships()
# include removed posts if the user's looking at their own page
if user == request.user:
# include removed posts if the user's looking at their own page or is an admin
if user == request.user or request.user.is_admin:
query = query.include_removed()
posts = query.get_page(per_page)

Loading…
Cancel
Save