Пример #1
0
 def post(self, request, *args, **kwargs):
     self.section = self.get_object()
     response = super(DeleteSection, self).post(request, *args, **kwargs)
     reindex_orders_in(Section, questionnaire=self.section.questionnaire)
     message = "Section successfully deleted."
     messages.success(request, message)
     return response
Пример #2
0
 def _delete_empty_groups_and_reorder(self):
     old_orders = self.get_old_orders()
     if old_orders:
         order = old_orders.keys()[0]
         group_subsection = order.question_group.subsection
         QuestionGroup.delete_empty_groups(group_subsection)
         reindex_orders_in(QuestionGroup, subsection=group_subsection)
Пример #3
0
 def post(self, request, *args, **kwargs):
     self.success_url = self._set_success_url()
     response = super(DeleteSubSection, self).post(request, *args, **kwargs)
     reindex_orders_in(SubSection, section=self.object.section)
     message = "Subsection successfully deleted."
     messages.success(request, message)
     return response
Пример #4
0
Файл: grid.py Проект: eJRF/ejrf
 def post(self, request, *args, **kwargs):
     referer_url = request.META.get('HTTP_REFERER', None)
     subsection = SubSection.objects.get(id=kwargs['subsection_id'])
     QuestionGroup.objects.filter(id=kwargs['questionGroup_id']).delete()
     reindex_orders_in(QuestionGroup, subsection=subsection)
     messages.success(request, "Grid successfully removed from questionnaire.")
     return HttpResponseRedirect(referer_url)
Пример #5
0
 def post(self, request, *args, **kwargs):
     self.success_url = self._set_success_url()
     if request.user.user_profile.can_delete(self.object):
         response = super(DeleteSubSection, self).post(request, *args, **kwargs)
         reindex_orders_in(SubSection, section=self.object.section)
         message = "Subsection successfully deleted."
         messages.success(request, message)
         return response
     message = "You are not permitted to delete a core subsection"
     messages.error(request, message)
     return HttpResponseRedirect(self.object.get_absolute_url())
Пример #6
0
 def post(self, request, *args, **kwargs):
     self.section = self.get_object()
     user_profile = self.request.user.user_profile
     if user_profile.can_delete(self.section):
         response = super(DeleteSection, self).post(request, *args, **kwargs)
         reindex_orders_in(Section, questionnaire=self.section.questionnaire)
         message = "Section successfully deleted."
         messages.success(request, message)
         return response
     message = "You are not permitted to delete a core section"
     messages.error(request, message)
     return HttpResponseRedirect(self.section.get_absolute_url())
Пример #7
0
 def post(self, request, *args, **kwargs):
     referer_url = request.META.get('HTTP_REFERER', None)
     subsection = SubSection.objects.get(id=kwargs['subsection_id'])
     question = Question.objects.get(id=kwargs['question_id'])
     groups_in_subsection = subsection.question_group.all()
     question.question_group.remove(*groups_in_subsection)
     question.orders.filter(question_group__in=groups_in_subsection).delete()
     question.root_skip_rules.filter(subsection=subsection).delete()
     question.skip_rules.filter(subsection=subsection).delete()
     QuestionGroup.objects.annotate(Count('question')).filter(question__count__lte=0, subsection=subsection).delete()
     reindex_orders_in(QuestionGroup, subsection=subsection)
     messages.success(request, "Question successfully unassigned from questionnaire.")
     return HttpResponseRedirect(referer_url)
Пример #8
0
    def test_re_indexes_section_orders_after_deletion_of_subsection(self):
        SubSection.objects.get(id=self.sub_section2.id).delete()

        reindex_orders_in(SubSection, section=self.section_1)

        self.assertEqual([1, 2], list(SubSection.objects.values_list('order', flat=True)))
Пример #9
0
    def test_re_indexes_section_orders_after_deletion_of_section(self):
        Section.objects.get(id=self.section_3.id).delete()

        reindex_orders_in(Section, questionnaire=self.questionnaire)

        self.assertEqual([1, 2, 3], list(Section.objects.values_list('order', flat=True)))
Пример #10
0
 def _remove_empty_groups(self):
     QuestionGroup.delete_empty_groups(self.group.subsection)
     reindex_orders_in(QuestionGroup, subsection=self.group.subsection)