diff --git a/plinth/modules/help/templates/help_contribute.html b/plinth/modules/help/templates/help_contribute.html index 0560d1e31..add270602 100644 --- a/plinth/modules/help/templates/help_contribute.html +++ b/plinth/modules/help/templates/help_contribute.html @@ -42,4 +42,76 @@ {% trans 'Learn more...' %}

+ +

{% trans "How can I help?" %}

+

+ {% blocktrans trimmed %} + Below is a list of opportunities for contributing to Debian. It + has been filtered to only show packages that are installed on + this system. + {% endblocktrans %} +

+

+ + +

+

{% trans "Packages that will be removed from Debian testing" %}

+ + +

{% trans "Packages that are not in Debian testing" %}

+ + +

{% trans "Good first issues for beginners" %}

+ + +

{% trans "Issues for which the package maintainer has requested help" %}

+ +
+

{% endblock %} diff --git a/plinth/modules/help/views.py b/plinth/modules/help/views.py index 2ddef7f9f..c98656665 100644 --- a/plinth/modules/help/views.py +++ b/plinth/modules/help/views.py @@ -3,16 +3,20 @@ Help app for FreedomBox. """ +import gzip +import json import mimetypes import os import pathlib +import apt from django.core.files.base import File from django.http import Http404, HttpResponse, HttpResponseRedirect from django.template.response import TemplateResponse from django.urls import reverse from django.utils.translation import get_language_from_request from django.utils.translation import gettext as _ +import requests from plinth import __version__, actions, cfg from plinth.modules.upgrades.views import (get_os_release, @@ -27,8 +31,52 @@ def index(request): def contribute(request): """Serve the contribute page""" - return TemplateResponse(request, 'help_contribute.html', - {'title': _('Contribute')}) + response = requests.get('https://udd.debian.org/how-can-i-help.json.gz') + data = gzip.decompress(response.content) + issues = json.loads(data) + + # Split issues according to type and filter for installed packages. + testing_autorm = [] + no_testing = [] + gift = [] + help_needed = [] + cache = apt.Cache() + for issue in issues: + if issue['type'] == 'testing-autorm': + for package in issue['packages']: + try: + if cache[package].is_installed: + testing_autorm.append(issue) + break + except KeyError: + pass + elif issue['type'] == 'no-testing': + try: + if cache[issue['package']].is_installed: + no_testing.append(issue) + except KeyError: + pass + elif issue['type'] == 'gift': + try: + if cache[issue['package']].is_installed: + gift.append(issue) + except KeyError: + pass + elif issue['type'] == 'help': + try: + if cache[issue['package']].is_installed: + help_needed.append(issue) + except KeyError: + pass + + return TemplateResponse( + request, 'help_contribute.html', { + 'title': _('Contribute'), + 'testing_autorm': testing_autorm, + 'no_testing': no_testing, + 'gift': gift, + 'help': help_needed, + }) def feedback(request):