Skip to content

Commit c508d40

Browse files
committed
Apply patch from Henrik Levkowetz to support old ids as input
- Legacy-Id: 3922
1 parent b6f0fa8 commit c508d40

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

redesign/importing/import-docs.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727

2828
from workflows.models import State as StateOld
2929

30-
import_docs_from = document_name_to_import = None
30+
import_docs_from = document_name_to_import = document_id_to_import = None
3131
if len(sys.argv) > 1:
32-
try:
32+
if re.search("^\d+$", sys.argv[1]):
33+
document_id_to_import = sys.argv[1]
34+
elif re.search("^\d\d\d\d-\d\d-\d\d$", sys.argv[1]):
3335
import_docs_from = datetime.datetime.strptime(sys.argv[1], "%Y-%m-%d")
34-
except:
36+
else:
3537
document_name_to_import = sys.argv[1]
3638

3739
dont_save_queries()
@@ -789,6 +791,8 @@ def import_from_idinternal(d, idinternal):
789791
else:
790792
all_drafts = all_drafts.filter(filename=document_name_to_import)
791793

794+
if document_id_to_import:
795+
all_drafts = all_drafts.filter(pk=document_id_to_import)
792796

793797
for index, o in enumerate(all_drafts.iterator()):
794798
print "importing", o.id_document_tag, o.filename, index, "ballot %s" % o.idinternal.ballot_id if o.idinternal and o.idinternal.ballot_id else ""

0 commit comments

Comments
 (0)