mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-11-04 09:12:11 +01:00 
			
		
		
		
	Pretty print feature
Prints the money of each user perfectly
This commit is contained in:
		
							
								
								
									
										0
									
								
								apps/note/templatetags/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								apps/note/templatetags/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										12
									
								
								apps/note/templatetags/pretty_money.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								apps/note/templatetags/pretty_money.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
from django import template
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def pretty_money(value):
 | 
			
		||||
    if value%100 == 0:
 | 
			
		||||
        return str(value//100) + '€'
 | 
			
		||||
    else:
 | 
			
		||||
        return str(value//100) + '€ ' + str(value%100)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
register = template.Library()
 | 
			
		||||
register.filter('pretty_money', pretty_money)
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
{% extends "base.html" %}
 | 
			
		||||
{% load i18n static %}
 | 
			
		||||
{% load i18n static pretty_money %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
    <h3>Compte n° {{ object.pk }}</h3>
 | 
			
		||||
@@ -20,7 +20,7 @@
 | 
			
		||||
        <dt class="col-6 col-md-3">{% trans 'address'|capfirst %}</dt>
 | 
			
		||||
        <dd class="col-6 col-md-3">{{ object.address }}</dd>
 | 
			
		||||
        <dt class="col-6 col-md-3">{% trans 'balance'|capfirst %}</dt>
 | 
			
		||||
        <dd class="col-6 col-md-3">{{ object.user.note.balance }}</dd>
 | 
			
		||||
        <dd class="col-6 col-md-3">{{ object.user.note.balance | pretty_money }}</dd>
 | 
			
		||||
    </dl>
 | 
			
		||||
 | 
			
		||||
    <a href="{% url "password_change" %}">{% trans 'Change password' %}</a>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user