Beispiel #1
0
def _call_save_fn_and_clear_cache(toggle_slug, changed_entries, currently_enabled, static_toggle):
    for entry in changed_entries:
        enabled = entry in currently_enabled
        namespace, entry = parse_toggle(entry)
        if namespace == NAMESPACE_DOMAIN:
            domain = entry
            if static_toggle.save_fn is not None:
                static_toggle.save_fn(domain, enabled)
        else:
            # these are sent down with no namespace
            assert ':' not in entry, entry
            username = entry
Beispiel #2
0
def _call_save_fn_and_clear_cache(toggle_slug, changed_entries,
                                  currently_enabled, static_toggle):
    for entry in changed_entries:
        enabled = entry in currently_enabled
        namespace, entry = parse_toggle(entry)
        if namespace == NAMESPACE_DOMAIN:
            domain = entry
            if static_toggle.save_fn is not None:
                static_toggle.save_fn(domain, enabled)
        else:
            # these are sent down with no namespace
            assert ':' not in entry, entry
            username = entry
Beispiel #3
0
def _call_save_fn_and_clear_cache(static_toggle, previously_enabled,
                                  currently_enabled):
    changed_entries = previously_enabled ^ currently_enabled  # ^ means XOR
    for entry in changed_entries:
        enabled = entry in currently_enabled
        namespace, entry = parse_toggle(entry)
        if namespace == NAMESPACE_DOMAIN:
            domain = entry
            if static_toggle.save_fn is not None:
                static_toggle.save_fn(domain, enabled)
        elif namespace != NAMESPACE_EMAIL_DOMAIN:
            # these are sent down with no namespace
            assert ':' not in entry, entry
            username = entry
Beispiel #4
0
    def call_save_fn_and_clear_cache(self, toggle_slug, changed_entries,
                                     currently_enabled):
        for entry in changed_entries:
            enabled = entry in currently_enabled
            namespace, entry = parse_toggle(entry)
            if namespace == NAMESPACE_DOMAIN:
                domain = entry
                if self.static_toggle.save_fn is not None:
                    self.static_toggle.save_fn(domain, enabled)
                toggle_js_domain_cachebuster.clear(domain)
            else:
                # these are sent down with no namespace
                assert ':' not in entry, entry
                username = entry
                toggle_js_user_cachebuster.clear(username)

            clear_toggle_cache(toggle_slug, entry, namespace=namespace)
Beispiel #5
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)
            namespace, item = parse_toggle(item)

    to_toggle.save()
    from_toggle.delete()