euscanwww: Improved email template

Now the code is quite cryptic but it's to remove useless blank lines
in the final output.

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-09-03 15:09:12 +02:00
parent 2019b245e8
commit 80ca711565
2 changed files with 25 additions and 42 deletions

View File

@ -304,6 +304,8 @@ def process_emails(profiles, only_if_vlogs=False):
if only_if_vlogs and not vlogs.count(): if only_if_vlogs and not vlogs.count():
continue continue
vlogs = vlogs.order_by("-datetime")
infos = get_user_fav_infos(user) infos = get_user_fav_infos(user)
infos["user"] = user infos["user"] = user
infos["vlogs"] = vlogs infos["vlogs"] = vlogs

View File

@ -1,50 +1,31 @@
{% load djeuscan_helpers %} {% load djeuscan_helpers %}{% load sub %}Hello {{ user }},
{% load sub %}
Hello {{ user }},
{% if vlogs %}euscan news: {% if vlogs %}euscan news:
{% for vlog in vlogs %} * {{ vlog.package|ljust:"35" }} {{ vlog.version }} {% if vlog.vtype and not vlog.vtype|is_stable %}({{ vlog.vtype }}){% endif %}
{% for vlog in vlogs %} {% endfor %}
* {{ vlog }} {% if vlog.vtype and not vlog.vtype|is_stable %}({{ vlog.vtype }}){% endif %} - {{ vlog.datetime }} {% endfor %}
{% endif %} {% endif %}
Summary: Summary:
{% with categories|length as num_categories %}{% if num_categories %} {% with categories|length as num_categories %}{% if num_categories %}
Watching {{ num_categories }} categor{{ num_categories|pluralize:"y,ies"}} Watching {{ num_categories }} categor{{ num_categories|pluralize:"y,ies"}}: {{ categories_upstream }} upstream version{{ categories_upstream|pluralize:"s"}}
{{ categories_upstream }} new upstream version{{ categories_upstream|pluralize:"s"}} {% if categories_upstream %}Hot categories:
{% if categories_upstream %} {% for c in categories|slice:":3" %} * {{ c.category }} ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }})
Hot categories: {% endfor %}
{% for c in categories|slice:":3" %} {% endif %}{% endif %}{% endwith %}{% with herds|length as num_herds %}{% if num_herds %}
* {{ c.category }} ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }}){% endfor %} Watching {{ num_herds }} herd{{ num_herds|pluralize:"s"}}: {{ herds_upstream }} upstream version{{ herds_upstream|pluralize:"s"}}
{% if herds_upstream %}Hot herds:
{% for c in herds|slice:":3" %} * {{ c.herds__herd }} ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }})
{% endfor %}
{% endif %}{% endif %}{% endwith %}{% with maintainers|length as num_maintainers %}{% if num_maintainers %}
Watching {{ num_maintainers }} maintainer{{ num_maintainers|pluralize:"s"}}: {{ maintainers_upstream }} upstream version{{ maintainers_upstream|pluralize:"s"}}
{% if maintainers_upstream %}Hot maintainers:
{% for c in maintainers|slice:":3" %} * {{ c.maintainers__name }} ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }})
{% endfor %}
{% endif %}{% endif %}{% endwith %}{% with packages|length as num_packages %}{% if num_packages %}
Watching {{ num_packages }} package{{ num_packages|pluralize:"s"}}: {{ packages_upstream }} upstream version{{ packages_upstream|pluralize:"s"}}
{% if packages_upstream %}Hot packages:
{% for c in packages|slice:":3" %} * {{ c }} ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }})
{% endfor %}
{% endif %}{% endif %}{% endwith %} {% endif %}{% endif %}{% endwith %}
{% with herds|length as num_herds %}{% if num_herds %}
Watching {{ num_herds }} herd{{ num_herds|pluralize:"s"}}
{{ herds_upstream }} new upstream version{{ herds_upstream|pluralize:"s"}}
{% if herds_upstream %}
Hot herds:
{% for c in herds|slice:":3" %}
* {{ c.herds__herd }} ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }}){% endfor %}
{% endif %}{% endif %}{% endwith %}
{% with maintainers|length as num_maintainers %}{% if num_maintainers %}
Watching {{ num_maintainers }} maintainer{{ num_maintainers|pluralize:"s"}}
{{ maintainers_upstream }} new upstream version{{ maintainers_upstream|pluralize:"s"}}
{% if maintainers_upstream %}
Hot maintainers:
{% for c in maintainers|slice:":3" %}
* {{ c.maintainers__name }} ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }}){% endfor %}
{% endif %}{% endif %}{% endwith %}
{% with packages|length as num_packages %}{% if num_packages %}
Watching {{ num_packages }} package{{ num_packages|pluralize:"s"}}
{{ packages_upstream }} new upstream version{{ packages_upstream|pluralize:"s"}}
{% if packages_upstream %}
Hot packages:
{% for c in packages|slice:":3" %}
* {{ c }} ({{ c.n_versions|sub:c.n_packaged|sub:c.n_overlay }}){% endfor %}
{% endif %}{% endif %}{% endwith %}
-- --
This email was sent by euscan This email was sent by euscan, please do not reply.