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 create_chroot(cls, user, copr, mock_chroot, buildroot_pkgs=None, repos=None, comps=None, comps_name=None, with_opts="", without_opts="", delete_after=None, delete_notify=None): """ :type user: models.User :type mock_chroot: models.MockChroot """ if buildroot_pkgs is None: buildroot_pkgs = "" if repos is None: repos = "" UsersLogic.raise_if_cant_update_copr( user, copr, "Only owners and admins may update their projects.") chroot = models.CoprChroot(copr=copr, mock_chroot=mock_chroot) cls._update_chroot(buildroot_pkgs, repos, comps, comps_name, chroot, with_opts, without_opts, delete_after, delete_notify) return chroot
def remove_copr_chroot(cls, user, copr_chroot): """ :param models.CoprChroot chroot: """ UsersLogic.raise_if_cant_update_copr( user, copr_chroot.copr, "Only owners and admins may update their projects.") db.session.delete(copr_chroot)
def remove_comps(cls, user, copr_chroot): UsersLogic.raise_if_cant_update_copr( user, copr_chroot.copr, "Only owners and admins may update their projects.") copr_chroot.comps_name = None copr_chroot.comps_zlib = None ActionsLogic.send_update_comps(copr_chroot) db.session.add(copr_chroot)
def update_chroot(cls, user, copr_chroot, buildroot_pkgs, comps=None, comps_name=None): """ :type user: models.User :type copr_chroot: models.CoprChroot """ UsersLogic.raise_if_cant_update_copr( user, copr_chroot.copr, "Only owners and admins may update their projects.") cls._update_chroot(buildroot_pkgs, comps, comps_name, copr_chroot) db.session.add(copr_chroot) return copr_chroot
def create_chroot(cls, user, copr, mock_chroot, buildroot_pkgs=None, comps=None, comps_name=None): """ :type user: models.User :type mock_chroot: models.MockChroot """ if buildroot_pkgs is None: buildroot_pkgs = "" UsersLogic.raise_if_cant_update_copr( user, copr, "Only owners and admins may update their projects.") chroot = models.CoprChroot(copr=copr, mock_chroot=mock_chroot) cls._update_chroot(buildroot_pkgs, comps, comps_name, chroot) return chroot
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 for mock_chroot in new_chroots: if mock_chroot not in current_chroots: db.session.add( models.CoprChroot(copr=copr, mock_chroot=mock_chroot)) # delete no more present to_remove = [] for mock_chroot in current_chroots: if mock_chroot not in new_chroots: # 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)