class InfoPageAdmin(TranslationAdmin):
- list_display = ('title', 'slug')
+ list_display = ('title', 'slug', 'published', 'findable')
admin.site.register(InfoPage, InfoPageAdmin)
--- /dev/null
+# Generated by Django 4.0.8 on 2024-03-12 08:50
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('infopages', '0004_alter_infopage_options_alter_infopage_left_column_and_more'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='infopage',
+ name='findable',
+ field=models.BooleanField(default=True, verbose_name='wyszukiwalna'),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='infopage',
+ name='published',
+ field=models.BooleanField(default=True, help_text='Nieopublikowane strony są widoczne tylko dla administratorów.', verbose_name='opublikowana'),
+ preserve_default=False,
+ ),
+ ]
slug = models.SlugField('slug', max_length=120, unique=True, db_index=True)
title = models.CharField('tytuł', max_length=120, blank=True)
+ published = models.BooleanField(
+ 'opublikowana',
+ help_text='Nieopublikowane strony są widoczne tylko dla administratorów.'
+ )
+ findable = models.BooleanField('wyszukiwalna')
left_column = models.TextField('lewa kolumna', blank=True)
right_column = models.TextField('prawa kolumna', blank=True)
{% block main %}
- <div class="l-article__title">
- <h1>{{ page.title }}</h1>
+ {% if not page.published %}
+ <div class="l-container">
+ <strong>(Strona nie opublikowana, podgląd tylko dla zespołu.)</strong>
</div>
- <article class="l-article">
- <div class="l-article__cols">
- <div class="left-column">
- {{ left_column }}
- </div>
- <div class="right-column">
- {{ right_column }}
- </div>
+
+ {% endif %}
+
+ <div class="l-article__title">
+ <h1>{{ page.title }}</h1>
+ </div>
+ <article class="l-article">
+ <div class="l-article__cols">
+ <div class="left-column">
+ {{ left_column }}
</div>
- </article>
+ <div class="right-column">
+ {{ right_column }}
+ </div>
+ </div>
+ </article>
{% endblock %}
def infopage(request, slug):
- page = get_object_or_404(InfoPage, slug=slug)
+ if request.user.is_staff:
+ page = get_object_or_404(InfoPage, slug=slug)
+ else:
+ page = get_object_or_404(InfoPage, slug=slug, published=True)
rc = RequestContext(request)
try:
])
if len(data) < limit:
infos = infopages.models.InfoPage.objects.filter(
+ published=True,
+ findable=True,
title_pl__iregex='\m' + prefix).only('title', 'id', 'slug')
data.extend([
{