def update_from_names(cls, user, copr, names): UsersLogic.raise_if_cant_update_copr( user, copr, "Only owners and admins may update their projects.") current_chroots = copr.mock_chroots new_chroots = cls.mock_chroots_from_names(names) # add non-existing run_createrepo = False for mock_chroot in new_chroots: if mock_chroot not in current_chroots: db.session.add( models.CoprChroot(copr=copr, mock_chroot=mock_chroot)) run_createrepo = True if run_createrepo: ActionsLogic.send_createrepo(copr) # delete no more present to_remove = [] for mock_chroot in current_chroots: if mock_chroot in new_chroots: continue if not mock_chroot.is_active: continue # can't delete here, it would change current_chroots and break # iteration to_remove.append(mock_chroot) for mc in to_remove: copr.mock_chroots.remove(mc)
def on_auto_createrepo_change(target_copr, value_acr, old_value_acr, initiator): """ Emit createrepo action when auto_createrepo re-enabled""" if old_value_acr == NEVER_SET: # created new copr, not interesting return if not old_value_acr and value_acr: # re-enabled ActionsLogic.send_createrepo(target_copr)
def on_auto_createrepo_change(target_copr, value_acr, old_value_acr, initiator): """ Emit createrepo action when auto_createrepo re-enabled""" if old_value_acr == NEVER_SET: # created new copr, not interesting return if not old_value_acr and value_acr: # re-enabled ActionsLogic.send_createrepo( target_copr.user.name, target_copr.name, chroots=[chroot.name for chroot in target_copr.active_chroots] )
def new_from_names(cls, copr, names): for mock_chroot in cls.mock_chroots_from_names(names): db.session.add( models.CoprChroot(copr=copr, mock_chroot=mock_chroot)) ActionsLogic.send_createrepo(copr)