fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
031b8be
)
Fixes and experiments.
author
Radek Czajka
<rczajka@rczajka.pl>
Tue, 23 May 2023 10:24:23 +0000
(12:24 +0200)
committer
Radek Czajka
<rczajka@rczajka.pl>
Tue, 23 May 2023 10:24:23 +0000
(12:24 +0200)
src/catalogue/views.py
patch
|
blob
|
history
src/experiments/base.py
patch
|
blob
|
history
src/experiments/experiments.py
patch
|
blob
|
history
src/experiments/templates/experiments/main_switch.html
patch
|
blob
|
history
src/wolnelektury/settings/custom.py
patch
|
blob
|
history
src/wolnelektury/templates/2022/main_page.html
patch
|
blob
|
history
src/wolnelektury/views.py
patch
|
blob
|
history
diff --git
a/src/catalogue/views.py
b/src/catalogue/views.py
index
16b66f0
..
2b188e6
100644
(file)
--- a/
src/catalogue/views.py
+++ b/
src/catalogue/views.py
@@
-109,13
+109,14
@@
def object_list(request, objects, fragments=None, related_tags=None, tags=None,
Tag.objects.usage_for_queryset(
objects, counts=True
).exclude(category='set').exclude(pk__in=tag_ids))
Tag.objects.usage_for_queryset(
objects, counts=True
).exclude(category='set').exclude(pk__in=tag_ids))
- related_tag_lists.append(
- Tag.objects.usage_for_queryset(
- objects, counts=True
- ).filter(
- user=request.user
- ).exclude(name='').exclude(pk__in=tag_ids)
- )
+ if request.user.is_authenticated:
+ related_tag_lists.append(
+ Tag.objects.usage_for_queryset(
+ objects, counts=True
+ ).filter(
+ user=request.user
+ ).exclude(name='').exclude(pk__in=tag_ids)
+ )
if not (extra and extra.get('theme_is_set')):
if fragments is None:
if list_type == 'gallery':
if not (extra and extra.get('theme_is_set')):
if fragments is None:
if list_type == 'gallery':
diff --git
a/src/experiments/base.py
b/src/experiments/base.py
index
726f451
..
92b1bc1
100644
(file)
--- a/
src/experiments/base.py
+++ b/
src/experiments/base.py
@@
-7,6
+7,7
@@
class Experiment:
name = 'experiment'
explicit = False
size = 0
name = 'experiment'
explicit = False
size = 0
+ switchable = True
def qualify(self, request):
return True
def qualify(self, request):
return True
@@
-27,12
+28,13
@@
class Experiment:
if self.qualify(request) is False:
return None, False
if self.qualify(request) is False:
return None, False
- cookie_value = request.COOKIES.get(f'EXPERIMENT_{slug}')
- if cookie_value is not None:
- if cookie_value == 'on':
- return True, True
- elif cookie_value == 'off':
- return False, True
+ if self.switchable or request.user.is_staff:
+ cookie_value = request.COOKIES.get(f'EXPERIMENT_{slug}')
+ if cookie_value is not None:
+ if cookie_value == 'on':
+ return True, True
+ elif cookie_value == 'off':
+ return False, True
number = int(
hashlib.md5(
number = int(
hashlib.md5(
diff --git
a/src/experiments/experiments.py
b/src/experiments/experiments.py
index
df1b23a
..
15c103f
100644
(file)
--- a/
src/experiments/experiments.py
+++ b/
src/experiments/experiments.py
@@
-14,6
+14,14
@@
class NewLayout(Experiment):
return False
return False
+class Sowka(Experiment):
+ slug = 'sowka'
+ name = 'Pan Sówka'
+ size = settings.EXPERIMENTS_SOWKA
+ switchable = False
+
+
experiments = [
NewLayout,
experiments = [
NewLayout,
+ Sowka,
]
]
diff --git
a/src/experiments/templates/experiments/main_switch.html
b/src/experiments/templates/experiments/main_switch.html
index
c02ca48
..
7638e1f
100644
(file)
--- a/
src/experiments/templates/experiments/main_switch.html
+++ b/
src/experiments/templates/experiments/main_switch.html
@@
-9,6
+9,7
@@
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c8/MH1Asimulator.JPG" style="width:100%">
{% for exp in request.EXPERIMENTS.values %}
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c8/MH1Asimulator.JPG" style="width:100%">
{% 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 }}
<div class="experiment nice-controls" data-slug="{{ exp.slug }}">
<span>
{{ exp.name }}
@@
-24,6
+25,7
@@
{% endif %}
data-value="off">wyłączony</button>
</div>
{% endif %}
data-value="off">wyłączony</button>
</div>
+ {% endif %}
{% endfor %}
{% endblock %}
{% endfor %}
{% endblock %}
diff --git
a/src/wolnelektury/settings/custom.py
b/src/wolnelektury/settings/custom.py
index
fa1b8d2
..
07c1bfe
100644
(file)
--- a/
src/wolnelektury/settings/custom.py
+++ b/
src/wolnelektury/settings/custom.py
@@
-67,5
+67,6
@@
CIVICRM_ACTIVITIES = {
}
EXPERIMENTS_LAYOUT = 0
}
EXPERIMENTS_LAYOUT = 0
+EXPERIMENTS_SOWKA = 0
WIDGETS = {}
WIDGETS = {}
diff --git
a/src/wolnelektury/templates/2022/main_page.html
b/src/wolnelektury/templates/2022/main_page.html
index
5517123
..
ca9d958
100644
(file)
--- a/
src/wolnelektury/templates/2022/main_page.html
+++ b/
src/wolnelektury/templates/2022/main_page.html
@@
-141,8
+141,9
@@
<main class="l-main">
{% if widget %}
<main class="l-main">
{% if widget %}
+ <div class="l-change-pop show"><p>{{ widget.description }}</p></div>
<section class="l-section">
<section class="l-section">
- <iframe src="{{ widget}}" style="width: 100%; height: 600px; border: none;"></iframe>
+ <iframe src="{{ widget
.url
}}" style="width: 100%; height: 600px; border: none;"></iframe>
</section>
{% endif %}
</section>
{% endif %}
diff --git
a/src/wolnelektury/views.py
b/src/wolnelektury/views.py
index
49110e9
..
9f099bd
100644
(file)
--- a/
src/wolnelektury/views.py
+++ b/
src/wolnelektury/views.py
@@
-32,12
+32,16
@@
def main_page_2022(request):
ctx['recommended_collection'] = Collection.objects.filter(listed=True, role='recommend').order_by('?').first()
ctx['ambassadors'] = club.models.Ambassador.objects.all().order_by('?')
ctx['widget'] = settings.WIDGETS.get(request.GET.get('w'))
ctx['recommended_collection'] = Collection.objects.filter(listed=True, role='recommend').order_by('?').first()
ctx['ambassadors'] = club.models.Ambassador.objects.all().order_by('?')
ctx['widget'] = settings.WIDGETS.get(request.GET.get('w'))
+ if not ctx['widget'] and request.EXPERIMENTS['sowka'].value:
+ ctx['widget'] = settings.WIDGETS['pan-sowka']
return render(request, '2022/main_page.html', ctx)
@never_cache
def main_page(request):
if request.GET.get('w') in settings.WIDGETS:
request.EXPERIMENTS['layout'].override(True)
return render(request, '2022/main_page.html', ctx)
@never_cache
def main_page(request):
if request.GET.get('w') in settings.WIDGETS:
request.EXPERIMENTS['layout'].override(True)
+ if request.EXPERIMENTS['sowka'].value:
+ request.EXPERIMENTS['layout'].override(True)
if request.EXPERIMENTS['layout'].value:
return main_page_2022(request)
if request.EXPERIMENTS['layout'].value:
return main_page_2022(request)