Commit 6d1bb983 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Custom template tag for months since a specific date

parent 1194251f
......@@ -6,4 +6,10 @@
{% if data %}
{{ data }}
{% endif %}
<form action="{% url astakos.im.views.billing %}">{% csrf_token %}
{% for m in user.date_joined|months_since %}
{{ m|date:"M Y" }}
{% endfor %}
</form>
{% endblock %}
......@@ -32,6 +32,8 @@
# or implied, of GRNET S.A.
from django import template
from datetime import datetime
from dateutil.relativedelta import relativedelta
register = template.Library()
......@@ -62,3 +64,12 @@ def split(object_list, user):
return d
except:
return {'own': object_list, 'other': ()}
@register.filter
def months_since(start_date, end_date=datetime.now()):
delta = relativedelta(months=+1)
d = start_date
while d < end_date:
d += delta
yield d
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment