Exemple #1
0
    def test_bulk_set_slot_on_permitted_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.item2.id],
                'slot_name': self.slot_name,
                'slot_type': self.slot_type,
                'value': test_value,
                "confirmed": True
            })
        self.assertEqual(response.status_code, 302)
        self.assertEqual(
            2,
            len(
                models.concepts_with_similar_slots(user=self.editor,
                                                   name=self.slot_name,
                                                   value=test_value)))
        self.assertEqual(
            2,
            len(
                models.concepts_with_similar_slots(user=self.editor,
                                                   _type=self.slot_type,
                                                   value=test_value)))
Exemple #2
0
    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': 'add_slots',
                '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(
                models.concepts_with_similar_slots(user=self.editor,
                                                   name=self.slot_name,
                                                   value=test_value)))
        self.assertEqual(
            1,
            len(
                models.concepts_with_similar_slots(user=self.editor,
                                                   _type=self.slot_type,
                                                   value=test_value)))
def count_similar(user, slot):
    return concepts_with_similar_slots(user, slot=slot).count()
Exemple #4
0
def count_similar(user, slot):
    return concepts_with_similar_slots(user, slot=slot).count()
Exemple #5
0
 def get_queryset(self, *args, **kwargs):
     value = self.request.GET.get('value', None)
     return concepts_with_similar_slots(
         self.request.user, _type=self.get_slot_type(), value=value
     ).all()
Exemple #6
0
 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()