コード例 #1
0
ファイル: routes.py プロジェクト: atrakh/SupportService
def index():
    theme = request.args.get("theme")
    if theme:
        updateTheme(theme)
    
    showWidgets = ldclient.get().variation('show-widgets', current_user.get_ld_user(), False)
    
    if showWidgets:
        display_widgets = True
    else:
        display_widgets = False
        
    '''
    showWidgets = ld_client.variation("switch-feature", {'key': '*****@*****.**'}, False)
    if showWidgets == 'Red':
        display_widgets = 'Red'
    elif showWidgets == 'Blue':
        display_widgets = 'Blue'
    elif showWidgets == 'Green':
        display_widgets = 'Green'
    ''' 
    all_flags = json.dumps(ldclient.get().all_flags(current_user.get_ld_user()))

    beta_features = ldclient.get().variation('dark-theme', current_user.get_ld_user(), False)
    
    set_theme = '{0}/index.html'.format(current_user.set_path)

    LD_FRONTEND_KEY = current_app.config["LD_FRONTEND_KEY"]

    return render_template(set_theme, title='Home',
    display_widgets=display_widgets, all_flags=all_flags, show_beta=beta_features, LD_FRONTEND_KEY=LD_FRONTEND_KEY)
コード例 #2
0
def profile():
    bootstrap = current_app.ldclient.all_flags_state(current_user.get_ld_user())

    user = User.query.filter_by(id=current_user.id).first()
    return render_template(
        "default/profile.html", user=user, all_flags=bootstrap.to_json_string()
    )
コード例 #3
0
ファイル: routes.py プロジェクト: BrianJayChung/SS_deploy
def settings():
    bootstrap = current_app.ldclient.all_flags_state(
        current_user.get_ld_user())
    plans = Plan.query.all()
    return render_template("default/settings.html",
                           plans=plans,
                           all_flags=bootstrap.to_json_string())
コード例 #4
0
def dashboard():
    theme = request.args.get("theme")
    if theme:
        updateTheme(theme)

    beta_features = current_app.ldclient.variation('dark-theme', current_user.get_ld_user(), False)

    set_theme = '{0}/index.html'.format(current_user.set_path)

    return render_template(set_theme, title='Home', show_beta=beta_features)
コード例 #5
0
def operational():
    theme = request.args.get("theme")
    if theme:
        updateTheme(theme)

    set_theme = "{0}/operation.html".format(current_user.set_path)

    bootstrap = current_app.ldclient.all_flags_state(current_user.get_ld_user())

    return render_template(
        set_theme, title="Operational", all_flags=bootstrap.to_json_string()
    )
コード例 #6
0
def people():
    bootstrap = current_app.ldclient.all_flags_state(current_user.get_ld_user())
    page = request.args.get("page", 1, type=int)
    users = User.query.order_by(User.id).paginate(page, 15, False)
    next_url = url_for("core.people", page=users.next_num) if users.has_next else None
    prev_url = url_for("core.people", page=users.prev_num) if users.has_prev else None
    return render_template(
        "default/people.html",
        users=users.items,
        next_url=next_url,
        prev_url=prev_url,
        all_flags=bootstrap.to_json_string(),
    )
コード例 #7
0
def dataexport():

    theme = request.args.get("theme")

    if theme:
        updateTheme(theme)

    user = current_user.get_ld_user()
    session["ld_user"] = user

    set_theme = "{0}/dataexport.html".format(current_user.set_path)

    return render_template(set_theme, title="dataexport")
コード例 #8
0
ファイル: routes.py プロジェクト: BrianJayChung/SS_deploy
def index():
    """
    Controller for Public home page.
    Includes a server side experiment for trial duration. The duration
    can either be 14 days or 30 days. We show a different variation to
    each user randomly. Then we track the registration rate as our
    conversion event.
    """
    current_app.logger.info(current_app.config)
    if current_user.is_authenticated:
        return redirect(url_for("core.dashboard"))

    user = current_user.get_ld_user()
    req_headers = request.user_agent
    current_app.logger.error(req_headers)
    user['custom']['browser'] = req_headers.browser
    session["ld_user"] = user

    flag_name = "trial-duration"
    trial_duration = current_app.ldclient.variation_detail(
        flag_name, user, "15")

    start_time = time.time()

    if current_app.ldclient.variation('artificial-delay', user, False):
        artifical_delay(trial_duration.value)

    # Calculate the server processing time based on flag evaluation
    end_time = time.time() - start_time
    data_export = {
        "flag": flag_name,
        "variation": trial_duration.variation_index,
        "time": end_time,
    }
    current_app.ldclient.track("trial-rendering", user, data_export)

    session["trial_duration"] = trial_duration.value
    bootstrap = current_app.ldclient.all_flags_state(user)
    user_template = json.dumps(user)
    broken_release = current_app.ldclient.variation("accessibility-styling",
                                                    user, False)
    register_color = current_app.ldclient.variation(
        "registration-button-color", user, "#28A745")

    return render_template("home.html",
                           all_flags=bootstrap.to_json_string(),
                           register_color=register_color,
                           broken_release=broken_release,
                           user_template=user_template,
                           trial_duration=trial_duration.value)
コード例 #9
0
def environments():
    webhook = current_app.ldclient.variation('environments-webhook', current_user.get_ld_user(), False)
    url = url_parse(request.url)
    subdomain = url.host.split('.')[0]

    if subdomain == 'admin' and webhook:
        try:
            ld = LaunchDarklyApi(os.environ.get('LD_API_KEY'))
            project = ld.get_project(PROJECT_NAME)
            project_pick = pickle.dumps(project)
            current_app.redis_client.set(PROJECT_NAME, project_pick)
            return jsonify({'response': 200})
        except Exception as e:
            current_app.logger.error(e)
            abort(500)
    else:
        abort(403)
コード例 #10
0
ファイル: routes.py プロジェクト: BrianJayChung/SS_deploy
def dashboard():
    theme = request.args.get("theme")
    user = current_user.get_ld_user()
    user['agent'] = request.headers.get('User-Agent')

    if theme:
        updateTheme(theme)

    dark_theme = current_app.ldclient.variation("dark-theme", user, False)

    user_template = json.dumps(user)
    bootstrap = current_app.ldclient.all_flags_state(user)

    set_theme = "{0}/index.html".format(current_user.set_path)

    return render_template(
        set_theme,
        title="Home",
        dark_theme=dark_theme,
        user_template=user_template,
        all_flags=bootstrap.to_json_string(),
    )
コード例 #11
0
def experiments():
    theme = request.args.get("theme")
    if theme:
        updateTheme(theme)

    set_theme = "{0}/exp.html".format(current_user.set_path)

    user = current_user.get_ld_user()
    random_user = current_user.get_random_ld_user()

    user_template = json.dumps(user)
    bootstrap = current_app.ldclient.all_flags_state(user)

    show_nps = current_app.ldclient.variation("show-nps-survery", random_user, False)

    return render_template(
        set_theme,
        title="Experiments",
        show_nps=show_nps,
        random_user=random_user,
        user_template=user_template,
        all_flags=bootstrap.to_json_string(),
    )
コード例 #12
0
def index():
    """
    Controller for Public home page.
    Includes a server side experiment for trial duration. The duration
    can either be 14 days or 30 days. We show a different variation to
    each user randomly. Then we track the registration rate as our
    conversion event.
    """
    current_app.logger.info(current_app.config)
    if current_user.is_authenticated:
        return redirect(url_for('core.dashboard'))

    user = current_user.get_ld_user()
    session['ld_user'] = user

    flag_name = 'trial-duration'
    trial_duration = current_app.ldclient.variation_detail(
        flag_name,
        user,
        False)

    start_time = time.time()

    artifical_delay(trial_duration.value)

    # Calculate the server processing time based on flag evaluation
    end_time = time.time() - start_time
    data_export = {
        'flag': flag_name,
        'variation': trial_duration.variation_index,
        'time': end_time,
    }
    current_app.ldclient.track('trial-rendering', user, data_export)

    session['trial_duration'] = trial_duration.value

    return render_template('home.html', trial_duration=trial_duration.value)