Copy the ClassicalWork and DancePiece data to use the new through models.
2502
def forwards(apps, schema_editor):
    
    Event = apps.get_model('spectator_events', 'Event')
    ClassicalWorkSelection = apps.get_model(
                                'spectator_events', 'ClassicalWorkSelection')
    DancePieceSelection = apps.get_model(
                                'spectator_events', 'DancePieceSelection')

    for event in Event.objects.all():

        for work in event.classicalworks.all():
            selection = ClassicalWorkSelection(
                            classical_work=work,
                            event=event)
            selection.save()

        for piece in event.dancepieces.all():
            selection = DancePieceSelection(
                            dance_piece=piece,
                            event=event)
            selection.save()
165669
def expand_effect_repertoire(self, repertoire, new_purview=None):
        
        return self.expand_repertoire(Direction.EFFECT, repertoire,
                                      new_purview)
1157282
def copy(self):
        
        chart = Chart.__new__(Chart)
        chart.date = self.date
        chart.pos = self.pos
        chart.hsys = self.hsys
        chart.objects = self.objects.copy()
        chart.houses = self.houses.copy()
        chart.angles = self.angles.copy()
        return chart
493926
def replace_model(refwcs, newcoeffs):
    
    print('WARNING:')
    print('    Replacing existing distortion model with one')
    print('    not necessarily matched to the observation!')
    # create linear version of WCS to be updated by new model
    wcslin = stwcs.distortion.utils.undistortWCS(refwcs)
    outwcs = refwcs.deepcopy()
    outwcs.wcs.cd = wcslin.wcs.cd
    outwcs.wcs.set()
    outwcs.setOrient()
    outwcs.setPscale()
    # add new model to updated WCS object
    add_model(outwcs,newcoeffs)
    # Update CD matrix with new model
    apply_model(outwcs)

    # replace original input WCS with newly updated WCS
    refwcs = outwcs.deepcopy()
192068
def copy_dataset_files(self, ds, incver=False, cb=None, **kwargs):
        
        from ambry.orm import File

        tables = [File]

        return self._copy_dataset_copy(ds, tables, incver, cb, **kwargs)
821374
def copy(self):
        
        o = SimLibrary()
        o.procedures = dict(self.procedures)
        o.non_returning = set(self.non_returning)
        o.prototypes = dict(self.prototypes)
        o.default_ccs = dict(self.default_ccs)
        o.names = list(self.names)
        return o
873027
def move_user_data(primary, secondary):
    '''
        
    '''
    # Update all submission authorships of the secondary to the primary
    submissions = Submission.objects.filter(authors__id=secondary.pk)
    for subm in submissions:
        if subm.submitter == secondary:
            subm.submitter = primary
        subm.authors.remove(secondary)
        subm.authors.add(primary)
        subm.save()
    # Transfer course registrations
    try:
        for course in secondary.profile.courses.all():
            primary.profile.courses.add(course)
            primary.profile.save()
    except UserProfile.DoesNotExist:
        # That's a database consistency problem, but he will go away anyway
        pass
1356182
def redim(cls, dataset, dimensions):
        
        new_dataset = dataset.data.copy()
        for name, new_dim in dimensions.items():
            if name == new_dataset.name():
                new_dataset.rename(new_dim.name)
            for coord in new_dataset.dim_coords:
                if name == coord.name():
                    coord.rename(new_dim.name)
        return new_dataset
565232
def data_transform *args, &block
      if (data = call_model_sp2db_method __method__, *args, &block).present?
        data
      else
        super *args, &block
      end
    end
752717
def clone(self, _, scene):
        
        # Assume that the application creates a new set of Frames and so we need to match up the
        # data from the old object to the new (using the name).
        if self._name is not None:
            for effect in scene.effects:
                if isinstance(effect, Frame):
                    if effect._name == self._name:
                        effect.data = self.data
                        for layout in self._layouts:
                            layout.update_widgets(new_frame=effect)
1237557
def addrecords(self, new):
        
        data = spreadsheet.addrecords(self,new)
        data = data.view(tabarray)
        data.coloring = self.coloring
        return data
1046183
def copy(self):
        """"""
        p = Project()
        p.name = self.name
        p.path = self.path
        p._plugin = self._plugin
        p.stage = self.stage.copy()
        p.stage.project = p

        for sprite in self.sprites:
            s = sprite.copy()
            s.project = p
            p.sprites.append(s)

        for actor in self.actors:
            if isinstance(actor, Sprite):
                p.actors.append(p.get_sprite(actor.name))
            else:
                a = actor.copy()
                if isinstance(a, Watcher):
                    if isinstance(a.target, Project):
                        a.target = p
                    elif isinstance(a.target, Stage):
                        a.target = p.stage
                    else:
                        a.target = p.get_sprite(a.target.name)
                p.actors.append(a)

        p.variables = dict((n, v.copy()) for (n, v) in self.variables.items())
        p.lists = dict((n, l.copy()) for (n, l) in self.lists.items())
        p.thumbnail = self.thumbnail
        p.tempo = self.tempo
        p.notes = self.notes
        p.author = self.author
        return p
1090624
def clone(cls, model, use_json=True, use_lp=False):
        
        model.update()
        interface = sys.modules[cls.__module__]

        if use_lp:
            warnings.warn("Cloning with LP formats can change variable and constraint ID's.")
            new_model = cls.from_lp(model.to_lp())
            new_model.configuration = interface.Configuration.clone(model.configuration, problem=new_model)
            return new_model

        if use_json:
            new_model = cls.from_json(model.to_json())
            new_model.configuration = interface.Configuration.clone(model.configuration, problem=new_model)
            return new_model

        new_model = cls()
        for variable in model.variables:
            new_variable = interface.Variable.clone(variable)
            new_model._add_variable(new_variable)
        for constraint in model.constraints:
            new_constraint = interface.Constraint.clone(constraint, model=new_model)
            new_model._add_constraint(new_constraint)
        if model.objective is not None:
            new_model.objective = interface.Objective.clone(model.objective, model=new_model)
        new_model.configuration = interface.Configuration.clone(model.configuration, problem=new_model)
        return new_model
877963
def export(self, view_datas):
        """"""
        view_datas_copy = \
            [self.copy_and_finalize_view_data(vd) for vd in view_datas]
        if len(self.exporters) > 0:
            for e in self.exporters:
                try:
                    e.export(view_datas_copy)
                except AttributeError:
                    pass
632049
def copy(self, contents=True):
        ''''''
        cp = connection(collection=self._db_coll, baseiri=self._baseiri)
        if contents: cp.add_many(self._relationships)
        return cp
827524
def copy(newname)
            raise "Not all necessary api methods are defined to process this action!" unless api_methods[:copy]
            entry = self.class.find_one(name)
            if entry
                self.class.in_transaction(true) do |token|
                    entryid = self.class.make_call(api_methods[:handle],name,token)
                    self.class.make_call(api_methods[:copy],entryid,newname,token)
                end
            end
        end
229109
def clone(self, **override_vars):
        """"""
        c = Context(self.vars, self.data)
        c.executed_actions = set(self.executed_actions)
        c.vars.update(override_vars)
        return c