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':
name = 'experiment'
explicit = False
size = 0
+ switchable = True
def qualify(self, request):
return True
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(
return False
+class Sowka(Experiment):
+ slug = 'sowka'
+ name = 'Pan Sówka'
+ size = settings.EXPERIMENTS_SOWKA
+ switchable = False
+
+
experiments = [
NewLayout,
+ Sowka,
]
<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 }}
{% endif %}
data-value="off">wyłączony</button>
</div>
+ {% endif %}
{% endfor %}
{% endblock %}
}
EXPERIMENTS_LAYOUT = 0
+EXPERIMENTS_SOWKA = 0
WIDGETS = {}
<main class="l-main">
{% if widget %}
+ <div class="l-change-pop show"><p>{{ widget.description }}</p></div>
<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 %}
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)
+ if request.EXPERIMENTS['sowka'].value:
+ request.EXPERIMENTS['layout'].override(True)
if request.EXPERIMENTS['layout'].value:
return main_page_2022(request)