Skip to content

Commit

Permalink
pulling these back from main
Browse files Browse the repository at this point in the history
  • Loading branch information
jkachel committed Apr 1, 2024
1 parent 08a8896 commit 3380595
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
21 changes: 1 addition & 20 deletions main/features.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
"""MIT Open feature flags"""

import hashlib
import json
import logging

import hashlib
import json
import logging
Expand All @@ -23,14 +19,6 @@
User = get_user_model()
durable_cache = caches["durable"]

from authentication.backends.ol_open_id_connect import OlOpenIdConnectAuth

log = logging.getLogger()


User = get_user_model()
durable_cache = caches["durable"]


class Features(StrEnum):
"""Enum for feature flags"""
Expand Down Expand Up @@ -132,13 +120,6 @@ def get_all_feature_flags(opt_unique_id: Optional[str] = None):

return flag_data

[
durable_cache.set(generate_cache_key(k, unique_id, person_properties), v)
for k, v in flag_data.items()
]

return flag_data


def is_enabled(
name: str,
Expand All @@ -159,7 +140,7 @@ def is_enabled(
efforts.
Returns:
bool: True if the feature flag is enablede
bool: True if the feature flag is enabled
"""
unique_id = opt_unique_id or default_unique_id()
person_properties = _get_person_properties(unique_id)
Expand Down
14 changes: 0 additions & 14 deletions main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
main views
"""

import logging

from django.conf import settings
from django.http import (
HttpResponseBadRequest,
HttpResponseForbidden,
Expand All @@ -18,16 +15,11 @@
from main.features import get_all_feature_flags, is_enabled
from main.permissions import is_admin_user

log = logging.getLogger(__name__)


def index(request, **kwargs): # pylint: disable=unused-argument # noqa: ARG001
"""Render the example app"""

user = request.user
all_flags = get_all_feature_flags(user.username if user.is_authenticated else None)

# Should we limit these to just relevant front-end flags?

js_settings = {
"user": {
Expand All @@ -39,12 +31,6 @@ def index(request, **kwargs): # pylint: disable=unused-argument # noqa: ARG001
and (is_admin_user(request) or is_learning_path_editor(request)),
"is_article_editor": is_admin_user(request),
},
"posthog": {
"api_key": settings.POSTHOG_PROJECT_API_KEY,
"enabled": settings.POSTHOG_ENABLED,
"timeout": settings.POSTHOG_TIMEOUT_MS,
"bootstrap_flags": all_flags,
},
}

return render(request, "index.html", context={"js_settings": js_settings})
Expand Down

0 comments on commit 3380595

Please sign in to comment.