コード例 #1
0
ファイル: forms.py プロジェクト: duoduo3369/oj_test
    def save(self, commit=True, update=False,item_relation_combination_id=None,item_relation_id=None,):

        item_relation_combination_objects = []
        choice_list = []
        
        for item_info in self.item_info_list:
            field_info_list = self.cleaned_data[item_info.title_field_name].split(',')
            choice_list.append(field_info_list[0])
            if field_info_list[0] == 'True' :
                if field_info_list[1] != 'None' and field_info_list[2] != 'None':
                    item_relation_combination = ItemRelationCombination(item_id = item_info.item_id,
                                                                        item_relation_id = item_relation_id,
                                                                        combination_number = int(field_info_list[1]),
                                                                        show_order = int(field_info_list[2]),
                                                                        )

                    item_relation_combination_objects.append(item_relation_combination)
                else:
                    return None

        if not 'True' in choice_list:
            return None
        
        session = Session()
        session.add_all(item_relation_combination_objects)
        session.commit()
        session.close()

        return item_relation_id  
コード例 #2
0
ファイル: forms.py プロジェクト: duoduo3369/oj_test
    def save(self, commit=True, update=False,description_type_id=None,):

        description_type_item_relation_combination_objects = []
        choice_list = []
        
        for obj in self.form_info_list:
            field_info_list = self.cleaned_data[obj.title_field_name].split(',')
            choice_list.append(field_info_list[0])
            if field_info_list[0] == 'True' :
                if field_info_list[1] != 'None' and field_info_list[2] != 'None':
#                    description_type_item_relation_combination --> obj_dtitrc
                    obj_dtitrc = DescriptionTypeItemRelationCombination(description_type_id = description_type_id,
                                                                        item_relation_id = obj.item_relation_id,
                                                                        multi_number = int(field_info_list[1]),
                                                                        show_order = int(field_info_list[2]),
                                                                        relation_items_number = obj.relation_items_number,
                                                                        )

                    description_type_item_relation_combination_objects.append(obj_dtitrc)
                else:
                    return None

        if not 'True' in choice_list:
            return None
        
        session = Session()
        session.add_all(description_type_item_relation_combination_objects)
        session.commit()
        session.close()

        return description_type_id  
コード例 #3
0
ファイル: forms.py プロジェクト: duoduo3369/oj_test
    def save(self, commit=True, update=False,
             description_meta_item_relation_combination_id=None,description_meta_id=None,):

        description_meta_item_relation_combination_objects = []
        
        for item_relation_id in self.cleaned_data['item_relations']:
            obj_dmitrc = DescriptionMetaItemRelationCombination(description_meta_id = description_meta_id,
                                                                item_relation_id = item_relation_id,
                                                                )

            description_meta_item_relation_combination_objects.append(obj_dmitrc)
                       
        session = Session()
        session.add_all(description_meta_item_relation_combination_objects)
        session.commit()
        session.close()

        return description_meta_id  
コード例 #4
0
ファイル: forms.py プロジェクト: duoduo3369/oj_test
 def save(self, commit=True, update=False,description_type_id=None,description_id=None):
     
     description_detail_object_list = []
     for obj in self.description_detail_info_list:
         content = self.cleaned_data[obj.title_field_name]
         description_detail = DescriptionDetail(description_type_id = description_type_id,
                                                description_id = description_id,
                                                item_relation_id = obj.relation_id,
                                                items_id = obj.item_id,
                                                relation_show_order = obj.relation_show_order,
                                                show_order = obj.item_show_order,
                                                content = content,                                                   
                                                )
         description_detail_object_list.append(description_detail)
         
     session = Session()
     session.add_all(description_detail_object_list)
     session.commit()
     session.close()    
     
     return description_id