From dfc765f5e521d60410c92a3fc72d275505c03ff3 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Thu, 23 Aug 2018 22:57:55 +0200 Subject: [PATCH] Fais la distinction entre un baseinvoice avec et sans objet facture. --- logs/templates/logs/aff_summary.html | 9 +++++++-- logs/templatetags/logs_extra.py | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/logs/templates/logs/aff_summary.html b/logs/templates/logs/aff_summary.html index c9ebfe55..366e07e7 100644 --- a/logs/templates/logs/aff_summary.html +++ b/logs/templates/logs/aff_summary.html @@ -110,11 +110,16 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ v.datetime }} - {% blocktrans with username=v.username number=v.version.object.number name=v.version.object.name %}{{ username }} has sold {{ number }}x {{ name }} to{% endblocktrans %} - {{ v.version.object.facture.user.get_username }} + {% blocktrans with username=v.username number=v.version.object.number name=v.version.object.name %}{{ username }} has sold {{ number }}x {{ name }}{% endblocktrans %} + {% with invoice=v.version.object.facture %} + {% if invoice|is_facture %} + {% trans " to" %} + {{ v.version.object.facture.facture.user.get_username }} {% if v.version.object.iscotisation %} ({% blocktrans with duration=v.version.object.duration %}+{{ duration }} months{% endblocktrans %}) {% endif %} + {% endif %} + {% endwith %} {% can_edit_history %} diff --git a/logs/templatetags/logs_extra.py b/logs/templatetags/logs_extra.py index 0620f8f4..813a577f 100644 --- a/logs/templatetags/logs_extra.py +++ b/logs/templatetags/logs_extra.py @@ -19,7 +19,7 @@ # # 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., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# 51 Franklin Street, Fifth Floor, Boston, MA 021}10-1301 USA. """logs.templatetags.logs_extra A templatetag to get the class name for a given object """ @@ -34,6 +34,10 @@ def classname(obj): """ Returns the object class name """ return obj.__class__.__name__ +@register.filter +def is_facture(baseinvoice): + """Returns True if a baseinvoice has a `Facture` child.""" + return hasattr(baseinvoice, 'facture') @register.inclusion_tag('buttons/history.html') def history_button(instance, text=False, html_class=True):