feat(users): add paginated admin metadata APIs
This commit is contained in:
@@ -178,6 +178,19 @@ class UserListSchema(ModelSchema):
|
||||
major: Optional[str] = None
|
||||
university: Optional[str] = None
|
||||
mobile: Optional[str] = None
|
||||
profile_picture: Optional[str] = None
|
||||
profile_picture_thumbnail_url: Optional[str] = None
|
||||
profile_picture_preview_url: Optional[str] = None
|
||||
student_id: Optional[str] = None
|
||||
year_of_study: Optional[int] = None
|
||||
bio: Optional[str] = None
|
||||
is_email_verified: bool
|
||||
is_mobile_verified: bool
|
||||
is_deleted: bool
|
||||
deleted_at: Optional[datetime] = None
|
||||
can_access_blog_admin: bool
|
||||
can_write_blog_posts: bool
|
||||
can_review_blog_posts: bool
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
@@ -188,13 +201,19 @@ class UserListSchema(ModelSchema):
|
||||
"mobile",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"student_id",
|
||||
"year_of_study",
|
||||
"bio",
|
||||
"is_active",
|
||||
"is_staff",
|
||||
"is_superuser",
|
||||
"date_joined",
|
||||
"major",
|
||||
"university",
|
||||
"is_email_verified",
|
||||
"is_mobile_verified",
|
||||
"is_deleted",
|
||||
"deleted_at",
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
@@ -205,6 +224,37 @@ class UserListSchema(ModelSchema):
|
||||
def resolve_university(obj):
|
||||
return obj.get_university_display()
|
||||
|
||||
@staticmethod
|
||||
def resolve_can_access_blog_admin(obj):
|
||||
return can_access_blog_admin(obj)
|
||||
|
||||
@staticmethod
|
||||
def resolve_can_write_blog_posts(obj):
|
||||
return can_write_blog_posts(obj)
|
||||
|
||||
@staticmethod
|
||||
def resolve_can_review_blog_posts(obj):
|
||||
return can_review_blog_posts(obj)
|
||||
|
||||
@staticmethod
|
||||
def resolve_profile_picture(obj, context):
|
||||
request = context["request"]
|
||||
if obj.profile_picture and hasattr(obj.profile_picture, "url"):
|
||||
return request.build_absolute_uri(obj.profile_picture.url)
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def resolve_profile_picture_thumbnail_url(obj, context):
|
||||
request = context["request"]
|
||||
url = derivative_url(obj.profile_picture, THUMBNAIL_VARIANT)
|
||||
return request.build_absolute_uri(url) if url else None
|
||||
|
||||
@staticmethod
|
||||
def resolve_profile_picture_preview_url(obj, context):
|
||||
request = context["request"]
|
||||
url = derivative_url(obj.profile_picture, PREVIEW_VARIANT)
|
||||
return request.build_absolute_uri(url) if url else None
|
||||
|
||||
|
||||
class AuthorizationRoleSchema(Schema):
|
||||
key: str
|
||||
|
||||
Reference in New Issue
Block a user