Ejemplo n.º 1
0
def any_added_brand_group_rev2(brand_group_add_values, any_adding_changeset):
    # Change a few.  No need to hold on to these as
    # anything that needs to test that something has the
    # right values for a brand group shoudl use rev1
    brand_group_add_values['name'] = ['Other Brand Group']
    brand_group_add_values['year_began'] = 1940
    brand_group_add_values['year_ended_uncertain'] = False
    bgr = BrandGroupRevision(changeset=any_adding_changeset,
                             **brand_group_add_values)
    bgr.save()
    return bgr
Ejemplo n.º 2
0
def any_added_brand_group_rev2(brand_group_add_values, any_adding_changeset):
    # Change a few.  No need to hold on to these as
    # anything that needs to test that something has the
    # right values for a brand group shoudl use rev1
    brand_group_add_values['name'] = ['Other Brand Group']
    brand_group_add_values['year_began'] = 1940
    brand_group_add_values['year_ended_uncertain'] = False
    bgr = BrandGroupRevision(changeset=any_adding_changeset,
                             **brand_group_add_values)
    bgr.save()
    return bgr
Ejemplo n.º 3
0
def main():
    if settings.DEBUG:
        raise ValueError('This script requires that debug be set to false!')

    brands = Brand.objects.filter(group=None, deleted=False)

    ANON_USER = User.objects.get(username=settings.ANON_USER_NAME)

    # create corresponding brand_group for each brand
    for brand in brands:
        # create BrandGroup
        changeset = Changeset(indexer=ANON_USER, approver=ANON_USER,
          state=states.REVIEWING, change_type=CTYPES['brand_group'])
        changeset.save()
        changeset.comments.create(commenter=ANON_USER,
            text='This is an automatically generated change '
                'for the creation of a brand group for a brand.',
            old_state=states.REVIEWING, new_state=states.REVIEWING)

        revision = BrandGroupRevision(changeset=changeset,
            name=brand.name,
            year_began=brand.year_began,
            year_began_uncertain=brand.year_began_uncertain,
            year_ended=brand.year_ended,
            year_ended_uncertain=brand.year_ended_uncertain,
            url=brand.url, notes=brand.notes, parent=brand.parent,
            # no keywords are copied, seemingly, only few and emblem specific
            keywords='')
        revision.save()
        changeset.approve(notes='Automatically approved.')
        brand_group = changeset.brandgrouprevisions.get().brand_group

        # assign BrandGroup to Brand
        changeset = Changeset(indexer=ANON_USER,
            approver=ANON_USER, state=states.REVIEWING, change_type=CTYPES['brand'])
        changeset.save()
        changeset.comments.create(commenter=ANON_USER,
            text='This is an automatically generated change for the '
                'assignment of a brand to its created brand group.',
            old_state=states.REVIEWING, new_state=states.REVIEWING)
        brand_revision = BrandRevision.objects.clone_revision(brand=brand,
            changeset=changeset)
        brand_revision.group.add(brand_group)
        brand_revision.save()
        changeset.approve(notes='Automatically approved.')

        # create BrandUse
        changeset = Changeset(indexer=ANON_USER, approver=ANON_USER,
                                state=states.REVIEWING, change_type=CTYPES['brand_use'])
        changeset.save()
        changeset.comments.create(commenter=ANON_USER,
            text='This is an automatically generated change '
                'for the creation of a brand use for a brand.',
            old_state=states.REVIEWING, new_state=states.REVIEWING)
        use = BrandUseRevision(changeset=changeset, emblem=brand,
            publisher=brand.parent,
            year_began=brand.year_began,
            year_began_uncertain=brand.year_began_uncertain,
            year_ended=brand.year_ended,
            year_ended_uncertain=brand.year_ended_uncertain)
        use.save()
        changeset.approve(notes='Automatically approved.')
        in_use = changeset.branduserevisions.get().brand_use
        in_use.save()
Ejemplo n.º 4
0
def any_added_brand_group_rev1(brand_group_add_values, any_adding_changeset):
    bgr = BrandGroupRevision(changeset=any_adding_changeset,
                             **brand_group_add_values)
    bgr.save()
    return bgr
Ejemplo n.º 5
0
def any_added_brand_group_rev1(brand_group_add_values, any_adding_changeset):
    bgr = BrandGroupRevision(changeset=any_adding_changeset,
                             **brand_group_add_values)
    bgr.save()
    return bgr