mirror of
https://github.com/sissbruecker/linkding
synced 2024-11-22 03:13:02 +00:00
Add archive endpoints
This commit is contained in:
parent
0980e6a2b2
commit
79dd4179d2
2 changed files with 30 additions and 1 deletions
18
API.md
18
API.md
|
@ -59,7 +59,7 @@ Example response:
|
|||
}
|
||||
```
|
||||
|
||||
**Archived**
|
||||
**List Archived**
|
||||
|
||||
```
|
||||
GET /api/bookmarks/archived/
|
||||
|
@ -121,6 +121,22 @@ Example payload:
|
|||
}
|
||||
```
|
||||
|
||||
**Archive**
|
||||
|
||||
```
|
||||
POST /api/bookmarks/<id>/archive/
|
||||
```
|
||||
|
||||
Archives a bookmark.
|
||||
|
||||
**Unarchive**
|
||||
|
||||
```
|
||||
POST /api/bookmarks/<id>/unarchive/
|
||||
```
|
||||
|
||||
Unarchives a bookmark.
|
||||
|
||||
**Delete**
|
||||
|
||||
```
|
||||
|
|
|
@ -6,6 +6,7 @@ from rest_framework.routers import DefaultRouter
|
|||
from bookmarks import queries
|
||||
from bookmarks.api.serializers import BookmarkSerializer, TagSerializer
|
||||
from bookmarks.models import Bookmark, Tag
|
||||
from bookmarks.services.bookmarks import archive_bookmark, unarchive_bookmark
|
||||
|
||||
|
||||
class BookmarkViewSet(viewsets.GenericViewSet,
|
||||
|
@ -39,6 +40,18 @@ class BookmarkViewSet(viewsets.GenericViewSet,
|
|||
data = serializer(page, many=True).data
|
||||
return self.get_paginated_response(data)
|
||||
|
||||
@action(methods=['post'], detail=True)
|
||||
def archive(self, request, pk):
|
||||
bookmark = self.get_object()
|
||||
archive_bookmark(bookmark)
|
||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
@action(methods=['post'], detail=True)
|
||||
def unarchive(self, request, pk):
|
||||
bookmark = self.get_object()
|
||||
unarchive_bookmark(bookmark)
|
||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
class TagViewSet(viewsets.GenericViewSet,
|
||||
mixins.ListModelMixin,
|
||||
|
|
Loading…
Reference in a new issue