コード例 #1
0
ファイル: sections.py プロジェクト: remo4sam/ejrf
 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
ファイル: question_re_indexer.py プロジェクト: eJRF/ejrf
 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
ファイル: sections.py プロジェクト: remo4sam/ejrf
 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
ファイル: sections.py プロジェクト: eJRF/ejrf
 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
ファイル: sections.py プロジェクト: eJRF/ejrf
 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
ファイル: assign_questions.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'])
     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
ファイル: test_section_model_util.py プロジェクト: eJRF/ejrf
    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
ファイル: test_section_model_util.py プロジェクト: eJRF/ejrf
    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
ファイル: question_re_indexer.py プロジェクト: eJRF/ejrf
 def _remove_empty_groups(self):
     QuestionGroup.delete_empty_groups(self.group.subsection)
     reindex_orders_in(QuestionGroup, subsection=self.group.subsection)