Allow to set the locale on navbar links

This commit is contained in:
Rodolphe Breard 2018-02-04 20:40:41 +01:00
parent 28e0743b3c
commit 397d0bf62d
3 changed files with 31 additions and 1 deletions

View file

@ -0,0 +1,29 @@
# Generated by Django 2.0.1 on 2018-02-04 19:35
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('navbar', '0002_elementseparator'),
]
operations = [
migrations.AddField(
model_name='element',
name='add_locale',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='element',
name='parent',
field=models.ForeignKey(blank=True, limit_choices_to={'parent': None}, null=True, on_delete=django.db.models.deletion.CASCADE, to='navbar.Element'),
),
migrations.AlterField(
model_name='elementseparator',
name='parent',
field=models.ForeignKey(limit_choices_to={'parent': None}, on_delete=django.db.models.deletion.CASCADE, to='navbar.Element'),
),
]

View file

@ -14,6 +14,7 @@ class Element(models.Model):
) )
link = models.CharField(max_length=512, blank=True) link = models.CharField(max_length=512, blank=True)
new_window = models.BooleanField(default=False) new_window = models.BooleanField(default=False)
add_locale = models.BooleanField(default=False)
icon = models.FilePathField( icon = models.FilePathField(
path=os.path.join(settings.BASE_DIR, 'navbar/static/icons'), path=os.path.join(settings.BASE_DIR, 'navbar/static/icons'),
match=".png", match=".png",

View file

@ -22,7 +22,7 @@
{% if c.is_separator %} {% if c.is_separator %}
<hr /> <hr />
{% else %} {% else %}
<a class="dropdown-item" href="{{ c.link }}"{% if c.new_window %} target="_blank"{% endif %}{% if c.description.full_name or c.description.description %} data-toggle="tooltip" data-placement="right" data-html="true" title="{% if c.description.full_name %}<b>{{ c.description.full_name }}</b>{% endif %}{% if c.description.full_name and c.description.description %}<hr />{% endif %}{{ c.description.description }}"{% endif %}> <a class="dropdown-item" href="{% if c.add_locale %}/{{ current_lang_code }}{% endif %}{{ c.link }}"{% if c.new_window %} target="_blank"{% endif %}{% if c.description.full_name or c.description.description %} data-toggle="tooltip" data-placement="right" data-html="true" title="{% if c.description.full_name %}<b>{{ c.description.full_name }}</b>{% endif %}{% if c.description.full_name and c.description.description %}<hr />{% endif %}{{ c.description.description }}"{% endif %}>
<img src="{% static c.icon_path %}" alt="" /> {{ c }} <img src="{% static c.icon_path %}" alt="" /> {{ c }}
</a> </a>
{% endif %} {% endif %}