예제 #1
0
 def _sort_items(self):
     section = SurveySection.find_one(survey=self.survey,
                                      id=request.form['section_id'],
                                      _eager=SurveySection.children)
     section_items = {x.id: x for x in section.children}
     item_ids = map(int, request.form.getlist('item_ids'))
     changed_section = None
     for position, item_id in enumerate(item_ids, 1):
         try:
             section_items[item_id].position = position
         except KeyError:
             # item is not in section, was probably moved
             item = SurveyItem.find_one(
                 SurveyItem.survey == self.survey,
                 SurveyItem.id == item_id,
                 SurveyItem.type != SurveyItemType.section,
                 _eager=SurveyItem.parent)
             changed_section = item.parent
             item.position = position
             item.parent = section
             logger.info('Item %s moved to section %s by %s', item, section,
                         session.user)
     logger.info('Items in %s reordered by %s', section, session.user)
     if changed_section is not None:
         for position, item in enumerate(changed_section.children, 1):
             item.position = position
예제 #2
0
 def _process_args(self):
     RHManageSurveysBase._process_args(self)
     self.section = SurveySection.find_one(
         SurveySection.id == request.view_args['section_id'],
         ~Survey.is_deleted,
         _join=SurveySection.survey,
         _eager=SurveySection.survey)
     self.survey = self.section.survey
예제 #3
0
 def _checkParams(self, params):
     RHManageSurveysBase._checkParams(self, params)
     self.section = SurveySection.find_one(
         SurveySection.id == request.view_args['section_id'],
         ~Survey.is_deleted,
         _join=SurveySection.survey,
         _eager=SurveySection.survey)
     self.survey = self.section.survey
예제 #4
0
 def _sort_items(self):
     section = SurveySection.find_one(survey=self.survey, id=request.form['section_id'],
                                      _eager=SurveySection.children)
     section_items = {x.id: x for x in section.children}
     item_ids = map(int, request.form.getlist('item_ids'))
     changed_section = None
     for position, item_id in enumerate(item_ids, 1):
         try:
             section_items[item_id].position = position
         except KeyError:
             # item is not in section, was probably moved
             item = SurveyItem.find_one(SurveyItem.survey == self.survey, SurveyItem.id == item_id,
                                        SurveyItem.type != SurveyItemType.section, _eager=SurveyItem.parent)
             changed_section = item.parent
             item.position = position
             item.parent = section
             logger.info('Item {} moved to section {} by {}'.format(item, section, session.user))
     logger.info('Items in {} reordered by {}'.format(section, session.user))
     if changed_section is not None:
         for position, item in enumerate(changed_section.children, 1):
             item.position = position
예제 #5
0
 def _checkParams(self, params):
     RHManageSurveysBase._checkParams(self, params)
     self.section = SurveySection.find_one(SurveySection.id == request.view_args['section_id'], ~Survey.is_deleted,
                                           _join=SurveySection.survey, _eager=SurveySection.survey)
     self.survey = self.section.survey
예제 #6
0
 def _process_args(self):
     RHManageSurveysBase._process_args(self)
     self.section = SurveySection.find_one(SurveySection.id == request.view_args['section_id'], ~Survey.is_deleted,
                                           _join=SurveySection.survey, _eager=SurveySection.survey)
     self.survey = self.section.survey