Esempio n. 1
0
def keydate_migration(issues):
    changes = []
    for i in issues:
        keydate = parsePubDate(i.publication_date)
        if keydate:
            with transaction.commit_on_success():
                c = migrate_reserve(
                    i, 'issue', 'to autofill keydates from publication dates')
                if c:
                    ir = c.issuerevisions.all()[0]
                    ir.key_date = keydate
                    ir.save()
                    changes.append((c, True))
                else:
                    print("%s is reserved" % i)
        if len(changes) > 25:
            with transaction.commit_on_success():
                do_auto_approve(changes,
                                'publication date to keydate conversion')
            changes = []
    with transaction.commit_on_success():
        do_auto_approve(changes, 'publication date to keydate conversion')
Esempio n. 2
0
def move_issues(issues, series, reserve_text, approve_text):
    changes = []
    for issue in issues:
        if issue.reserved is False:
            changeset = migrate_reserve(issue, 'issue', reserve_text)
            if changeset:
                issue_revision = changeset.issuerevisions.get()
                if issue_revision.series.publisher != series.publisher:
                    if issue_revision.brand:
                        new_brand = series.publisher.active_brands()\
                            .filter(name=issue_revision.brand.name)
                        if new_brand.count() == 1:
                            issue_revision.brand = new_brand[0]
                        else:
                            issue_revision.brand = None
                    if issue_revision.indicia_publisher:
                        name = issue_revision.indicia_publisher.name
                        new_indicia_publisher = \
                            series.publisher.active_indicia_publishers() \
                                  .filter(name=name)
                        if new_indicia_publisher.count() == 1:
                            issue_revision.indicia_publisher = \
                                new_indicia_publisher[0]
                        else:
                            issue_revision.indicia_publisher = None
                            issue_revision.no_indicia_publisher = False
                issue_revision.series = series
                issue_revision.save()
                changes.append((changeset, True))
            else:
                print "Issue %s could not be reserved" % issue
        else:
            print "Issue %s is reserved" % issue

        if len(changes) > 100:
            do_auto_approve(changes, approve_text)
            changes = []
    if len(changes):
        do_auto_approve(changes, approve_text)
def keydate_migration(issues):
    changes = []
    for i in issues:
        keydate = parsePubDate(i.publication_date)
        if keydate:
            with transaction.commit_on_success():
                c = migrate_reserve(i, 'issue',
                        'to autofill keydates from publication dates')
                if c:
                    ir = c.issuerevisions.all()[0]
                    ir.key_date = keydate
                    ir.save()
                    changes.append((c, True))
                else:
                    print "%s is reserved" % i
        if len(changes) > 25:
            with transaction.commit_on_success():
                do_auto_approve(changes,
                                'publication date to keydate conversion')
            changes = []
    with transaction.commit_on_success():
        do_auto_approve(changes,
                        'publication date to keydate conversion')