Commit bf3e6b03a3c2d2b8044955f061d2cc019c7782f2
1 parent
66d407a0
Fix error while changing document type for subdocuments.
Showing
1 changed file
with
7 additions
and
4 deletions
collector/storage/views.py
... | ... | @@ -1149,6 +1149,11 @@ class DraftListView(ListView): |
1149 | 1149 | |
1150 | 1150 | |
1151 | 1151 | def change_doc_type(doc, target_type): |
1152 | + | |
1153 | + seq = doc.sequence | |
1154 | + doc.sequence = 1000000 | |
1155 | + doc.save() | |
1156 | + | |
1152 | 1157 | new_doc = target_type.objects.create(name=doc.name, |
1153 | 1158 | source_id=doc.source_id, |
1154 | 1159 | lang=doc.lang, |
... | ... | @@ -1174,9 +1179,9 @@ def change_doc_type(doc, target_type): |
1174 | 1179 | processing_status=doc.processing_status, |
1175 | 1180 | new=doc.new, |
1176 | 1181 | unk_coverage=doc.unk_coverage, |
1177 | - sequence=1000000, | |
1182 | + sequence=seq, | |
1178 | 1183 | parent=doc.parent) |
1179 | - seq = doc.sequence | |
1184 | + | |
1180 | 1185 | new_doc.keywords.add(*doc.keywords.all()) |
1181 | 1186 | subdocs = Document.objects.filter(parent=doc) |
1182 | 1187 | for subdoc in subdocs: |
... | ... | @@ -1196,8 +1201,6 @@ def change_doc_type(doc, target_type): |
1196 | 1201 | a.save() |
1197 | 1202 | |
1198 | 1203 | doc.delete() |
1199 | - new_doc.sequence = seq | |
1200 | - new_doc.save() | |
1201 | 1204 | |
1202 | 1205 | return new_doc |
1203 | 1206 | |
... | ... |