Fixes and experiments.
[wolnelektury.git] / src / experiments / templates / experiments / main_switch.html
index 0ff0d88..7638e1f 100644 (file)
@@ -1,24 +1,31 @@
-{% extends "base/base.html" %}
+{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base.html,base/base.html" %}
 
+{% block breadcrumbs %}
+  <span>Eksperymenty</span>
+{% endblock %}
 
+{% block main %}
 {% block body %}
-  <img src="https://upload.wikimedia.org/wikipedia/commons/c/c8/MH1Asimulator.JPG" style="width:100">
+  <img src="https://upload.wikimedia.org/wikipedia/commons/c/c8/MH1Asimulator.JPG" style="width:100%">
 
-  {% for exp in experiments %}
-    <div class="experiment" data-slug="{{ exp.config.slug }}">
-      {{ exp.config.name }}
-      {% for cohort in exp.config.cohorts %}
-        <button
-            {% if exp.value == cohort.value %}
-            disabled class="active"
-            {% endif %}
-            data-value="{{ cohort.value }}">{{ cohort.name }}</button>
-      {% endfor %}
+  {% for exp in request.EXPERIMENTS.values %}
+    {% if exp.switchable or request.user.is_staff %}
+    <div class="experiment nice-controls" data-slug="{{ exp.slug }}">
+      <span>
+        {{ exp.name }}
+      </span>
+      <button
+          {% if exp.value %}
+          disabled class="active"
+          {% endif %}
+          data-value="on">włączony</button>
+      <button
+          {% if not exp.value %}
+          disabled class="active"
+          {% endif %}
+          data-value="off">wyłączony</button>
     </div>
-
-    <script>
-    </script>
-
+    {% endif %}
   {% endfor %}
 {% endblock %}
 
@@ -37,8 +44,9 @@
   </style>
   <script>
    $(".experiment button").click(function() {
-       document.cookie = 'EXPERIMENT_' + $(this).parent().data('slug') + '=' + $(this).data('value') + '; path=/';
+       document.cookie = 'EXPERIMENT_' + $(this).parent().data('slug') + '=' + $(this).data('value') + '; path=/; max-age=31536000';
        window.location.reload(true);
    });
   </script>
 {% endblock %}
+{% endblock %}