def handle(self, dry_run=False, verbose=False, fresh_start=False, testing=False, *args, **options): self.verbose = verbose if fresh_start: confirm_fresh_start = raw_input( "Are you sure you want to delete all Roles and start over? You can't do this" " if accounting is already set up. Type 'yes' to continue.") if confirm_fresh_start == 'yes': self.flush_roles() for role in self.BOOTSTRAP_PRIVILEGES + self.BOOTSTRAP_PLANS: self.ensure_role(role, dry_run=dry_run) for (plan_role_slug, privs) in self.BOOTSTRAP_GRANTS.items(): for priv_role_slug in privs: ensure_grant(plan_role_slug, priv_role_slug, dry_run=dry_run, verbose=self.verbose) for old_priv in self.OLD_PRIVILEGES: remove_grant(old_priv, dry_run=dry_run) if not dry_run: Role.objects.filter(slug=old_priv).delete()
def handle(self, *privs, **kwargs): dry_run = kwargs.get('dry_run', False) verbose = kwargs.get('verbose') noinput = kwargs.get('noinput') all_plan_slugs = ( set(map(lambda s: s.role.slug, SoftwarePlanVersion.objects.all())) - set(MAX_PRIVILEGES) - # no privileges should be in software plan roles, this is just a safeguard set( map(lambda plan_slug: plan_slug.strip(), kwargs.get('skip', []).split(',')))) if not dry_run and not noinput and not _confirm( 'Are you sure you want to grant {} to {}?'.format( ', '.join(privs), ', '.join(all_plan_slugs), )): print 'Aborting' return if not all(map(lambda priv: priv in MAX_PRIVILEGES, privs)): print 'Not all specified privileges are valid: {}'.format( ', '.join(privs)) return for plan_role_slug in all_plan_slugs: for priv in privs: ensure_grant(plan_role_slug, priv, dry_run=dry_run, verbose=verbose)
def handle(self, *privs, **kwargs): dry_run = kwargs.get('dry_run', False) verbose = kwargs.get('verbose') noinput = kwargs.get('noinput') all_plan_slugs = ( set(map(lambda s: s.role.slug, SoftwarePlanVersion.objects.all())) - set(MAX_PRIVILEGES) - # no privileges should be in software plan roles, this is just a safeguard set(map(lambda plan_slug: plan_slug.strip(), kwargs.get('skip', []).split(','))) ) if not dry_run and not noinput and not _confirm('Are you sure you want to grant {} to {}?'.format( ', '.join(privs), ', '.join(all_plan_slugs), )): print 'Aborting' return if not all(map(lambda priv: priv in MAX_PRIVILEGES, privs)): print 'Not all specified privileges are valid: {}'.format(', '.join(privs)) return for plan_role_slug in all_plan_slugs: for priv in privs: ensure_grant(plan_role_slug, priv, dry_run=dry_run, verbose=verbose)
def handle(self, dry_run=False, verbose=False, fresh_start=False, testing=False, *args, **options): self.verbose = verbose if fresh_start: confirm_fresh_start = raw_input("Are you sure you want to delete all Roles and start over? You can't do this" " if accounting is already set up. Type 'yes' to continue.") if confirm_fresh_start == 'yes': self.flush_roles() for role in self.BOOTSTRAP_PRIVILEGES + self.BOOTSTRAP_PLANS: self.ensure_role(role, dry_run=dry_run) for (plan_role_slug, privs) in self.BOOTSTRAP_GRANTS.items(): for priv_role_slug in privs: ensure_grant(plan_role_slug, priv_role_slug, dry_run=dry_run, verbose=self.verbose) for old_priv in self.OLD_PRIVILEGES: remove_grant(old_priv, dry_run=dry_run) if not dry_run: Role.objects.filter(slug=old_priv).delete()