Esempio n. 1
0
def cli(ctx, dname, site, delete_code, no_prompt):
    """
    Deletes a single site if both <domain> and <site> are specified, or ALL sites under a domain if only the <domain>
    is specified.
    """
    assert isinstance(ctx, Context)

    # Get the domain
    dname = domain_parse(dname)
    domain = Domain.get(dname)
    if not domain:
        click.secho('No such domain: {dn}'.format(dn=domain.name),
                    fg='red',
                    bold=True,
                    err=True)
        return

    domain_sites = {site.name.lower(): site for site in domain.sites}

    # Single site?
    if site:
        if site.lower() not in domain_sites:
            click.secho('No such site "{sn}" under the domain {dn}'.format(
                sn=site, dn=domain.name))
        site = domain_sites[site.lower()]

        delete_single(site, domain, delete_code, no_prompt)
        return

    # Delete the entire domain
    delete_all(domain, delete_code, no_prompt)
Esempio n. 2
0
def cli(ctx, dname, site, delete_code, no_prompt):
    """
    Deletes a single site if both <domain> and <site> are specified, or ALL sites under a domain if only the <domain>
    is specified.
    """
    assert isinstance(ctx, Context)

    # Get the domain
    dname = domain_parse(dname)
    domain = Domain.get(dname)
    if not domain:
        click.secho('No such domain: {dn}'.format(dn=domain.name), fg='red', bold=True, err=True)
        return

    domain_sites = {site.name.lower(): site for site in domain.sites}

    # Single site?
    if site:
        if site.lower() not in domain_sites:
            click.secho('No such site "{sn}" under the domain {dn}'.format(sn=site, dn=domain.name))
        site = domain_sites[site.lower()]

        delete_single(site, domain, delete_code, no_prompt)
        return

    # Delete the entire domain
    delete_all(domain, delete_code, no_prompt)