mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-20 06:08:35 +02:00
New widget to display current features to sponsor.
WIP
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
{% load i18n %}
|
||||
|
||||
<!-- Current features to sponsor -->
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{% trans "Features looking for sponsoring" %}</h3>
|
||||
</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>
|
||||
{% empty %}
|
||||
<div class="alert alert-info">{% trans "FIXME" %}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from dateutil import parser
|
||||
import feedparser
|
||||
import requests
|
||||
|
||||
from django.views import generic
|
||||
|
||||
@@ -9,6 +10,8 @@ from django.contrib.auth import mixins as auth_mixins
|
||||
|
||||
from .. import signals
|
||||
|
||||
MODOBOA_WEBSITE_URL = "https://modoboa.org/"
|
||||
|
||||
|
||||
class DashboardView(auth_mixins.AccessMixin, generic.TemplateView):
|
||||
"""Dashboard view."""
|
||||
@@ -32,14 +35,26 @@ class DashboardView(auth_mixins.AccessMixin, generic.TemplateView):
|
||||
lang = "fr"
|
||||
else:
|
||||
lang = "en"
|
||||
context.update({"selection": "dashboard"})
|
||||
|
||||
posts = feedparser.parse(
|
||||
"https://modoboa.org/{}/weblog/feeds/".format(lang))
|
||||
"{}{}/weblog/feeds/".format(MODOBOA_WEBSITE_URL, lang))
|
||||
entries = []
|
||||
for entry in posts["entries"][:5]:
|
||||
entry["published"] = parser.parse(entry["published"])
|
||||
entries.append(entry)
|
||||
context["widgets"]["left"].append("core/_latest_news_widget.html")
|
||||
context.update({"news": entries})
|
||||
|
||||
url = "{}{}/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.update({"features": features})
|
||||
|
||||
# Extra widgets
|
||||
result = signals.extra_admin_dashboard_widgets.send(
|
||||
sender=self.__class__, user=self.request.user)
|
||||
@@ -49,4 +64,5 @@ class DashboardView(auth_mixins.AccessMixin, generic.TemplateView):
|
||||
widget["template"])
|
||||
# FIXME: can raise conflicts...
|
||||
context.update(widget["context"])
|
||||
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user