Exemplo n.º 1
0
 def setUpClass(cls):
     super(TestFormsExpressionSpecWithFilterEsVersion, cls).setUpClass()
     # enable toggle to 100%
     db_toggle = Toggle(slug=ICDS_UCR_ELASTICSEARCH_DOC_LOADING.slug)
     setattr(db_toggle, DynamicallyPredictablyRandomToggle.RANDOMNESS_KEY, 1)
     db_toggle.save()
     assert ICDS_UCR_ELASTICSEARCH_DOC_LOADING.enabled(uuid.uuid4().hex, NAMESPACE_OTHER)
    def handle(self, *args, **options):
        dry_run = options.get('dry_run', False)

        if dry_run:
            print("\n-------- DRY RUN --------\n")

        slug = CALLCENTER.slug
        try:
            toggle = Toggle.get(slug)
        except ResourceNotFound:
            toggle = Toggle(slug=slug)
        print("Current domains in toggle: {}".format(toggle.enabled_users))

        domains = get_call_center_domains()
        print("Active call center domains: {}".format(domains))

        items = [namespaced_item(domain, NAMESPACE_DOMAIN) for domain in domains]
        missing = set(items) - set(toggle.enabled_users)
        print("Domains missing from toggle: {}".format(missing))

        toggle.enabled_users = items

        if not dry_run:
            toggle.save()

            for item in items:
                update_toggle_cache(slug, item, True)
    def handle(self, *args, **options):
        dry_run = options.get('dry_run', False)

        if dry_run:
            print("\n-------- DRY RUN --------\n")

        slug = CALLCENTER.slug
        try:
            toggle = Toggle.get(slug)
        except ResourceNotFound:
            toggle = Toggle(slug=slug)
        print("Current domains in toggle: {}".format(toggle.enabled_users))

        domains = get_call_center_domains()
        print("Active call center domains: {}".format(domains))

        items = [
            namespaced_item(domain, NAMESPACE_DOMAIN) for domain in domains
        ]
        missing = set(items) - set(toggle.enabled_users)
        print("Domains missing from toggle: {}".format(missing))

        toggle.enabled_users = items

        if not dry_run:
            toggle.save()

            for item in items:
                update_toggle_cache(slug, item, True)
def _migrate_linked_apps_toggle(apps, schema_editor):
    try:
        linked_apps_toggle = Toggle.get('linked_apps')
    except ResourceNotFound:
        pass
    else:
        try:
            Toggle.get(LINKED_DOMAINS.slug)
        except ResourceNotFound:
            linked_domains_toggle = Toggle(
                slug=LINKED_DOMAINS.slug,
                enabled_users=linked_apps_toggle.enabled_users)
            linked_domains_toggle.save()
def _migrate_linked_apps_toggle(apps, schema_editor):
    try:
        linked_apps_toggle = Toggle.get('linked_apps')
    except ResourceNotFound:
        pass
    else:
        try:
            Toggle.get(LINKED_DOMAINS.slug)
        except ResourceNotFound:
            linked_domains_toggle = Toggle(
                slug=LINKED_DOMAINS.slug, enabled_users=linked_apps_toggle.enabled_users
            )
            linked_domains_toggle.save()
Exemplo n.º 6
0
def enable_vellum_beta(request):
    slug = "vellum_beta"
    try:
        toggle = Toggle.get(slug)
    except ResourceNotFound:
        toggle = Toggle(slug=slug)

    changed_entries = []
    if request.user.username not in toggle.enabled_users:
        changed_entries.append(request.user.username)
        toggle.enabled_users.append(request.user.username)
        toggle.save()
        _call_save_fn_and_clear_cache(slug, changed_entries, toggle.enabled_users, _find_static_toggle(slug))

    return HttpResponse(json.dumps({'success': True}), content_type="application/json")
Exemplo n.º 7
0
def toggle_app_manager_v2(request):
    slug = "app_manager_v2"
    on_or_off = request.POST.get('on_or_off', 'on')
    try:
        toggle = Toggle.get(slug)
    except ResourceNotFound:
        toggle = Toggle(slug=slug)

    enable = on_or_off == "on"
    enabled = request.user.username in toggle.enabled_users
    if enable != enabled:
        changed_entries = [request.user.username]
        if enable:
            toggle.enabled_users.append(request.user.username)
        else:
            toggle.enabled_users.remove(request.user.username)
        toggle.save()
        _call_save_fn_and_clear_cache(slug, changed_entries, toggle.enabled_users, find_static_toggle(slug))

    return HttpResponse(json.dumps({'success': True}), content_type="application/json")
Exemplo n.º 8
0
def toggle_app_manager_v2(request):
    slug = "app_manager_v2"
    on_or_off = request.POST.get('on_or_off', 'on')
    try:
        toggle = Toggle.get(slug)
    except ResourceNotFound:
        toggle = Toggle(slug=slug)

    enable = on_or_off == "on"
    enabled = request.user.username in toggle.enabled_users
    if enable != enabled:
        changed_entries = [request.user.username]
        if enable:
            toggle.enabled_users.append(request.user.username)
        else:
            toggle.enabled_users.remove(request.user.username)
        toggle.save()
        _call_save_fn_and_clear_cache(slug, changed_entries, toggle.enabled_users, _find_static_toggle(slug))

    return HttpResponse(json.dumps({'success': True}), content_type="application/json")
Exemplo n.º 9
0
def move_toggles(from_toggle_id, to_toggle_id):
    """
    Moves all enabled items from one toggle to another.
    """
    try:
        from_toggle = Toggle.get(from_toggle_id)
    except ResourceNotFound:
        # if no source found this is a noop
        return
    try:
        to_toggle = Toggle.get(to_toggle_id)
    except ResourceNotFound:
        to_toggle = Toggle(slug=to_toggle_id, enabled_users=[])

    for item in from_toggle.enabled_users:
        if item not in to_toggle.enabled_users:
            to_toggle.enabled_users.append(item)
            update_toggle_cache(to_toggle_id, item, True)

    to_toggle.save()
    from_toggle.delete()