2017-09-27 13:40:28 +00:00
|
|
|
# -*- mode: python; coding: utf-8 -*-
|
2020-11-23 16:06:37 +00:00
|
|
|
# Re2o est un logiciel d'administration développé initiallement au Rézo Metz. Il
|
2017-01-15 23:01:18 +00:00
|
|
|
# se veut agnostique au réseau considéré, de manière à être installable en
|
|
|
|
# quelques clics.
|
|
|
|
#
|
|
|
|
# Copyright © 2017 Gabriel Détraz
|
2019-09-29 14:02:28 +00:00
|
|
|
# Copyright © 2017 Lara Kermarec
|
2017-01-15 23:01:18 +00:00
|
|
|
# Copyright © 2017 Augustin Lemesle
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
2018-08-23 20:57:55 +00:00
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 021}10-1301 USA.
|
2018-04-14 15:30:14 +00:00
|
|
|
"""logs.templatetags.logs_extra
|
|
|
|
A templatetag to get the class name for a given object
|
|
|
|
"""
|
2017-01-15 23:01:18 +00:00
|
|
|
|
2016-10-31 16:27:27 +00:00
|
|
|
from django import template
|
|
|
|
|
|
|
|
register = template.Library()
|
|
|
|
|
2018-04-13 20:37:04 +00:00
|
|
|
|
2016-10-31 16:27:27 +00:00
|
|
|
@register.filter
|
|
|
|
def classname(obj):
|
2018-04-14 15:30:14 +00:00
|
|
|
""" Returns the object class name """
|
2016-10-31 16:27:27 +00:00
|
|
|
return obj.__class__.__name__
|
2018-07-19 10:30:15 +00:00
|
|
|
|
2019-11-04 16:55:03 +00:00
|
|
|
|
2018-08-23 20:57:55 +00:00
|
|
|
@register.filter
|
|
|
|
def is_facture(baseinvoice):
|
|
|
|
"""Returns True if a baseinvoice has a `Facture` child."""
|
2019-11-04 16:55:03 +00:00
|
|
|
return hasattr(baseinvoice, "facture")
|
|
|
|
|
2018-07-19 10:30:15 +00:00
|
|
|
|
2019-11-04 16:55:03 +00:00
|
|
|
@register.inclusion_tag("buttons/history.html")
|
2020-04-25 10:31:18 +00:00
|
|
|
def history_button(instance, text=False, html_class=True):
|
2018-07-20 17:54:03 +00:00
|
|
|
"""Creates the correct history button for an instance.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
instance: The instance of which you want to get history buttons.
|
|
|
|
text: Flag stating if a 'History' text should be displayed.
|
|
|
|
html_class: Flag stating if the link should have the html classes
|
|
|
|
allowing it to be displayed as a button.
|
|
|
|
|
|
|
|
"""
|
2018-07-19 10:30:15 +00:00
|
|
|
return {
|
2019-11-04 16:55:03 +00:00
|
|
|
"application": instance._meta.app_label,
|
|
|
|
"name": instance._meta.model_name,
|
|
|
|
"id": instance.id,
|
|
|
|
"text": text,
|
|
|
|
"class": html_class,
|
2018-07-19 10:30:15 +00:00
|
|
|
}
|