forked from github/plane
feat: user activities endpoint (#590)
This commit is contained in:
parent
6d8eda9814
commit
9064709d5d
@ -21,6 +21,7 @@ from plane.api.views import (
|
|||||||
# User
|
# User
|
||||||
UserEndpoint,
|
UserEndpoint,
|
||||||
UpdateUserOnBoardedEndpoint,
|
UpdateUserOnBoardedEndpoint,
|
||||||
|
UserActivityEndpoint,
|
||||||
## End User
|
## End User
|
||||||
# Workspaces
|
# Workspaces
|
||||||
WorkSpaceViewSet,
|
WorkSpaceViewSet,
|
||||||
@ -185,6 +186,7 @@ urlpatterns = [
|
|||||||
UpdateUserOnBoardedEndpoint.as_view(),
|
UpdateUserOnBoardedEndpoint.as_view(),
|
||||||
name="change-password",
|
name="change-password",
|
||||||
),
|
),
|
||||||
|
path("users/activities/", UserActivityEndpoint.as_view(), name="user-activities"),
|
||||||
# user workspaces
|
# user workspaces
|
||||||
path(
|
path(
|
||||||
"users/me/workspaces/",
|
"users/me/workspaces/",
|
||||||
|
@ -16,6 +16,7 @@ from .project import (
|
|||||||
from .people import (
|
from .people import (
|
||||||
UserEndpoint,
|
UserEndpoint,
|
||||||
UpdateUserOnBoardedEndpoint,
|
UpdateUserOnBoardedEndpoint,
|
||||||
|
UserActivityEndpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .oauth import OauthEndpoint
|
from .oauth import OauthEndpoint
|
||||||
|
@ -7,10 +7,18 @@ from sentry_sdk import capture_exception
|
|||||||
# Module imports
|
# Module imports
|
||||||
from plane.api.serializers import (
|
from plane.api.serializers import (
|
||||||
UserSerializer,
|
UserSerializer,
|
||||||
|
IssueActivitySerializer,
|
||||||
)
|
)
|
||||||
|
|
||||||
from plane.api.views.base import BaseViewSet, BaseAPIView
|
from plane.api.views.base import BaseViewSet, BaseAPIView
|
||||||
from plane.db.models import User, Workspace, WorkspaceMemberInvite, Issue
|
from plane.db.models import (
|
||||||
|
User,
|
||||||
|
Workspace,
|
||||||
|
WorkspaceMemberInvite,
|
||||||
|
Issue,
|
||||||
|
IssueActivity,
|
||||||
|
)
|
||||||
|
from plane.utils.paginator import BasePaginator
|
||||||
|
|
||||||
|
|
||||||
class UserEndpoint(BaseViewSet):
|
class UserEndpoint(BaseViewSet):
|
||||||
@ -73,3 +81,25 @@ class UpdateUserOnBoardedEndpoint(BaseAPIView):
|
|||||||
{"error": "Something went wrong please try again later"},
|
{"error": "Something went wrong please try again later"},
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class UserActivityEndpoint(BaseAPIView, BasePaginator):
|
||||||
|
def get(self, request):
|
||||||
|
try:
|
||||||
|
queryset = IssueActivity.objects.filter(actor=request.user).select_related(
|
||||||
|
"actor"
|
||||||
|
)
|
||||||
|
|
||||||
|
return self.paginate(
|
||||||
|
request=request,
|
||||||
|
queryset=queryset,
|
||||||
|
on_results=lambda issue_activities: IssueActivitySerializer(
|
||||||
|
issue_activities, many=True
|
||||||
|
).data,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
capture_exception(e)
|
||||||
|
return Response(
|
||||||
|
{"error": "Something went wrong please try again later"},
|
||||||
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user