New widget to display current features.

see #1070
This commit is contained in:
Antoine Nguyen
2017-03-10 09:56:31 +01:00
parent a0d8f26277
commit 336f5ddb54
5 changed files with 33 additions and 12 deletions
+1 -1
View File
@@ -320,7 +320,7 @@ def add_widgets_to_admin_dashboard(sender, user, **kwargs):
"domains": models.Domain.objects.get_for_admin(user)}
template = "admin/_per_domain_statistics_widget.html"
return [{
"column": "right",
"column": "left",
"template": template,
"context": context
}]
@@ -1,4 +1,4 @@
{% load i18n %}
{% load core_tags i18n %}
<!-- Current features to sponsor -->
<div class="panel panel-primary">
@@ -7,13 +7,20 @@
</div>
<div class="panel-body">
{% for feature in features %}
<h4>{{ feature.name }}</h4>
<span class="label label-info">{% trans "Current:" %} {{ feature.current }}</span>
<span class="label label-success">{% trans "Goal:" %} {{ feature.goal }}</span>
<p>{{ feature.description }}</p>
<a href="{{ feature.full_url }}" class="btn btn-primary">{% trans "More" %}</a>
<h4>{{ feature.name }}
<span class="pull-right">
<span class="label label-success">
{{ feature.current|currencyfmt }} / {{ feature.goal|currencyfmt }}</span>
</span>
</h4>
<p class="slogan">{{ feature.slogan|safe }}</p>
<div class="text-center">
<a href="{{ feature.full_url }}" class="btn btn-primary" target="_blank">
{% trans "More" %}</a>
</div>
{% if not forloop.last %}<hr>{% endif %}
{% empty %}
<div class="alert alert-info">{% trans "FIXME" %}</div>
<div class="alert alert-info">{% trans "Nothing to sponsor yet." %}</div>
{% endfor %}
</div>
</div>
+11 -1
View File
@@ -1,3 +1,4 @@
# coding: utf-8
"""Custom tags for Core application."""
import os
@@ -10,7 +11,7 @@ from django.core.urlresolvers import reverse
from django.template.loader import render_to_string
from django.utils import timezone
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
from django.utils.translation import get_language, ugettext as _
from django.contrib.sessions.models import Session
@@ -255,3 +256,12 @@ def display_messages(msgs):
});
</script>
""" % (level, text, timeout))
@register.filter
def currencyfmt(amount):
"""Simple temp. filter to replace babel."""
lang = get_language()
if lang == "fr":
return u"{} €".format(amount)
return u"€{}".format(amount)
+2 -3
View File
@@ -46,13 +46,12 @@ class DashboardView(auth_mixins.AccessMixin, generic.TemplateView):
context["widgets"]["left"].append("core/_latest_news_widget.html")
context.update({"news": entries})
url = "{}{}/projects/?featured=true".format(
url = "{}{}/api/projects/?featured=true".format(
MODOBOA_WEBSITE_URL, lang)
response = requests.get(url)
features = []
if response.status_code == 200:
features = response.json()
context["widgets"]["left"].append("core/_current_features.html")
context["widgets"]["right"].append("core/_current_features.html")
context.update({"features": features})
# Extra widgets
+5
View File
@@ -284,4 +284,9 @@ html body div.navbar div.container-fluid div#navigate-navbar-collapse.collapse u
/* Wizard */
#wizard .carousel-inner {
overflow: visible;
}
/* Dashboard */
.slogan {
padding-top: 15px;
}