in pulseapi/entries/views.py [0:0]
def post(self, request, *args, **kwargs):
validation_result = post_validate(request)
if validation_result is True:
# invalidate the nonce, so this form cannot be
# resubmitted with the current id
request.session['nonce'] = False
user = request.user
entryids = self.request.query_params.get('ids', None)
def bookmark_entry(entryid):
# find the entry for this id
try:
entry = Entry.objects.get(id=entryid)
except ObjectDoesNotExist:
return
# find out if there is already a {user,entry,(timestamp)} triple
profile = user.profile
bookmarks = entry.bookmarked_by.filter(profile=profile)
# make a bookmark if there isn't one already
if not bookmarks:
UserBookmarks.objects.create(entry=entry, profile=profile)
if entryids is not None and user.is_authenticated:
for entryid in entryids.split(','):
bookmark_entry(entryid)
return Response("Entries bookmarked.", status=status.HTTP_204_NO_CONTENT)
else:
return Response(
"post validation failed",
status=status.HTTP_403_FORBIDDEN
)