manager: mention on home page if a page is in menu (#51477)
gitea-wip/combo/pipeline/head Build started... Details
gitea/combo/pipeline/head Build started... Details

This commit is contained in:
Lauréline Guérin 2021-03-01 15:12:11 +01:00
parent 0fd79d4c0a
commit a53f37499a
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
3 changed files with 28 additions and 1 deletions

View File

@ -426,6 +426,14 @@ class Page(models.Model):
def is_visible(self, user=None, ignore_superuser=False):
return element_is_visible(self, user=user, ignore_superuser=ignore_superuser)
def extra_labels(self):
extra_labels = []
if not self.exclude_from_navigation:
extra_labels.append(_('navigation'))
if self.redirect_url:
extra_labels.append(_('redirection'))
return extra_labels
def get_cells(self):
return CellBase.get_cells(page=self)

View File

@ -34,7 +34,7 @@ Use drag and drop with the ⣿ handles to reorder and change hierarchy of pages.
<span class="group1">
<a href="{% url 'combo-manager-page-view' pk=page.id %}">
{{ page.title }}
{% if page.redirect_url %} <small>({% trans "redirection" %})</small>{% endif %}
{% for label in page.extra_labels %}{% if forloop.first %}<small>({% endif %}{{ label }}{% if forloop.last %})</small>{% else %}, {% endif %}{% endfor %}
</a>
</span>
{% if not page.public %}

View File

@ -99,6 +99,25 @@ def test_pages_redirection(app, admin_user):
assert '(redirection)' in resp
def test_pages_in_menu(app, admin_user):
page = Page.objects.create(title='One', slug='one')
app = login(app)
resp = app.get('/manage/')
assert '(navigation)' not in resp
page.exclude_from_navigation = False
page.save()
resp = app.get('/manage/')
assert '(navigation)' in resp
# mix
page.redirect_url = 'http://www.example.net'
page.save()
resp = app.get('/manage/')
assert '(navigation, redirection)' in resp
def test_add_page(app, admin_user):
app = login(app)
resp = app.get('/manage/', status=200)