Skip to content

Commit

Permalink
Yes/No filter (#36)
Browse files Browse the repository at this point in the history
* Boolean tag

* Several other pages

* Yes/No filter
  • Loading branch information
berk76 authored May 7, 2024
1 parent 99ab801 commit 5ff1cdc
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion svjis/articles/templates/admin_user.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "base-with-aside-menu-content.html" %}

{% load article_filters %}
{% load i18n %}

{% block content %}
Expand Down Expand Up @@ -67,7 +68,7 @@ <h1 class="page-title" id="tbl-desc">{% trans 'User' %}</h1>
<td class="list"><a href="{% url 'admin_user_owns' pk=obj.pk %}"><img src="/static/gfx/house.png" border="0" title="{% trans 'Units' %}" alt="{% trans 'Units' %}"></a></td>
<td class="list">{{ obj.last_name }}</td>
<td class="list">{{ obj.first_name }}</td>
<td class="list">{{ obj.is_active }}</td>
<td class="list">{{ obj.is_active | yes_no }}</td>
<td class="list"><a href="mailto:{{ obj.email }}">{{ obj.email }}</a></td>
<td class="list">{{ obj.last_login | date:"d.m.Y H:i"}}</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion svjis/articles/templates/fault.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h1 class="page-title" {% if obj.closed %}style="text-decoration: line-through;
</tr>
<tr>
<th class="list" scope="row">{% trans 'Closed' %}</th>
<td class="list">{{ obj.closed }}</td>
<td class="list">{{ obj.closed | yes_no }}</td>
</tr>
<tr>
<th class="list" scope="row">{% trans 'Entrance' %}</th>
Expand Down
2 changes: 1 addition & 1 deletion svjis/articles/templates/redaction_article.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1 class="page-title" id="tbl-desc">{{ header }}</h1>
<td class="list">{{ obj.menu.description }}</td>
<td class="list">{{ obj.author.first_name }}&nbsp;{{ obj.author.last_name }}</td>
<td class="list">{{ obj.created_date|date:"d.m.Y" }}</td>
<td class="list">{{ obj.published }}</td>
<td class="list">{{ obj.published | yes_no }}</td>
</tr>
{% endfor %}
{% endif %}
Expand Down
3 changes: 2 additions & 1 deletion svjis/articles/templates/redaction_menu.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "base-with-aside-menu-content.html" %}

{% load i18n %}
{% load article_filters %}

{% block content %}

Expand All @@ -24,7 +25,7 @@ <h1 class="page-title" id="tbl-desc">{% trans 'Menu' %}</h1>
<td class="list" {% if obj.level > 1 %}style="background-color:#f1948a;"{% endif %}>{% with ''|center:obj.level as range %}{% for _ in range %}&nbsp;&nbsp;&nbsp;{% endfor %}{% endwith %}{{ obj.item.description }}</td>
<td class="list">{{ obj.item.parent.description }}</td>
<td class="list"{% if obj.level > 1 %}style="background-color:#f1948a;"{% endif %}>{{ obj.level }}</td>
<td class="list">{{ obj.item.hide }}</td>
<td class="list">{{ obj.item.hide | yes_no }}</td>
<td class="list">{{ obj.articles }}</td>
<td class="list"><a href="{% url 'redaction_menu_edit' pk=obj.item.pk %}"><img src="/static/gfx/pencil.png" border="0" title="{% trans 'Edit' %}" alt="{% trans 'Edit' %}"></a></td>
<td class="list">
Expand Down
3 changes: 2 additions & 1 deletion svjis/articles/templates/redaction_news.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "base-with-aside-menu-content.html" %}

{% load i18n %}
{% load article_filters %}

{% block content %}

Expand All @@ -22,7 +23,7 @@ <h1 class="page-title" id="tbl-desc">{{ header }}</h1>
<tr>
<td class="list">{{ obj.created_date | date:"d.m.Y H:i" }}</td>
<td class="list">{{ obj.author.first_name }}&nbsp;{{ obj.author.last_name }}</td>
<td class="list">{{ obj.published }}</td>
<td class="list">{{ obj.published | yes_no }}</td>
<td class="list">{{ obj.body | safe }}</td>
<td class="list"><a href="{% url 'redaction_news_edit' pk=obj.id %}"><img src="/static/gfx/pencil.png" border="0" title="{% trans 'Edit' %}" alt="{% trans 'Edit' %}"></a></td>
<td class="list"><a onclick="if (!confirm('{% trans 'Do you want to delete this news' %}?')) return false;" href="{% url 'redaction_news_delete' pk=obj.id %}"><img src="/static/gfx/delete.png" border="0" title="{% trans 'Delete' %}" alt="{% trans 'Delete' %}"></a></td>
Expand Down
3 changes: 2 additions & 1 deletion svjis/articles/templates/redaction_survey.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "base-with-aside-menu-content.html" %}

{% load i18n %}
{% load article_filters %}

{% block content %}

Expand Down Expand Up @@ -32,7 +33,7 @@ <h1 class="page-title" id="tbl-desc">{{ header }}</h1>
<td class="list">{{ obj.starting_date|date:"d.m.Y" }}</td>
<td class="list">{{ obj.ending_date|date:"d.m.Y" }}</td>
<td class="list">{{ obj.author.first_name }}&nbsp;{{ obj.author.last_name }}</td>
<td class="list">{{ obj.published }}</td>
<td class="list">{{ obj.published | yes_no }}</td>
</tr>
{% endfor %}
{% endif %}
Expand Down
7 changes: 7 additions & 0 deletions svjis/articles/templatetags/article_filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django import template
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as gt
from django.template.defaultfilters import stringfilter
from django.conf import settings
import markdown as md
Expand Down Expand Up @@ -35,6 +36,12 @@ def inject_pictures(text, assets):
return mark_safe(text)


@register.filter()
def yes_no(bool_value):
result = gt("Yes") if bool_value else gt("No")
return mark_safe(result)


# settings value
@register.simple_tag
def settings_value(name):
Expand Down

0 comments on commit 5ff1cdc

Please sign in to comment.