def test_bulk_set_slot_on_forbidden_items(self): self.login_editor() self.assertEqual(self.editor.profile.favourites.count(), 0) test_value = 'Insert Tab A into Slot B' response = self.client.post( reverse('aristotle:bulk_action'), { 'bulkaction': 'aristotle_mdr.contrib.slots.forms.BulkAssignSlotsForm', 'items': [self.item1.id, self.item4.id, self.item5.id], 'slot_name': self.slot_name, 'slot_type': self.slot_type, 'value': test_value, "confirmed": True }, ) self.assertEqual(response.status_code, 302) self.assertEqual( 1, len( concepts_with_similar_slots(user=self.editor, name=self.slot_name, value=test_value))) self.assertEqual( 1, len( concepts_with_similar_slots(user=self.editor, _type=self.slot_type, value=test_value)))
def test_bulk_set_slot_on_forbidden_items(self): self.login_editor() self.assertEqual(self.editor.profile.favourites.count(), 0) test_value = 'Insert Tab A into Slot B' response = self.client.post( reverse('aristotle:bulk_action'), { 'bulkaction': 'aristotle_mdr.contrib.slots.forms.BulkAssignSlotsForm', 'items': [self.item1.id, self.item4.id, self.item5.id], 'slot_name': self.slot_name, 'slot_type': self.slot_type, 'value': test_value, "confirmed": True }, ) self.assertEqual(response.status_code, 302) self.assertEqual(1, len(concepts_with_similar_slots(user=self.editor, name=self.slot_name, value=test_value))) self.assertEqual(1, len(concepts_with_similar_slots(user=self.editor, _type=self.slot_type, value=test_value)))
def get_queryset(self, *args, **kwargs): value = self.request.GET.get('value', None) return concepts_with_similar_slots( self.request.user, self.kwargs['slot_name'], value=value ).all()
def get_queryset(self, *args, **kwargs): value = self.request.GET.get('value', None) return concepts_with_similar_slots(self.request.user, self.kwargs['slot_name'], value=value).all()
def count_similar(user, slot): return concepts_with_similar_slots(user, slot=slot).count()