def mark_thread_read(thread, user, **kwargs): """This marks each unread note in a thread as read - in bulk.""" object_list = [] unread_notes = filter_notes_by_read_status(thread.notes, user, False) for note in unread_notes: object_list.append(CommunicationNoteRead(note=note, user=user)) CommunicationNoteRead.objects.bulk_create(object_list)
def mark_thread_read(thread, user, **kwargs): """This marks each unread note in a thread as read - in bulk.""" object_list = [] unread_notes = filter_notes_by_read_status(thread.notes, user, False) for note in unread_notes: object_list.append(CommunicationNoteRead(note=note, user=user)) CommunicationNoteRead.objects.bulk_create(object_list)
def filter_queryset(self, request, queryset, view): """ Return only read notes if `show_read=true` is truthy and only unread notes if `show_read=false. """ val = request.GET.get('show_read') if val is None: return queryset show_read = BooleanField().from_native(val) return filter_notes_by_read_status(queryset, request.amo_user, show_read)
def filter_queryset(self, request, queryset, view): """ Return only read notes if `show_read=true` is truthy and only unread notes if `show_read=false. """ val = request.GET.get('show_read') if val is None: return queryset show_read = BooleanField().from_native(val) return filter_notes_by_read_status(queryset, request.amo_user, show_read)