From e5a866dd64423a18d38d70f31171ef574d35fcd3 Mon Sep 17 00:00:00 2001
From: James Valleroy
Date: Sun, 24 Jul 2022 15:51:14 -0400
Subject: [PATCH] help: Add "How can I help?" section to Contribute page
This doesn't use the how-can-i-help package, but it is a similar
implementation that fetches the same data from udd.debian.org.
There are sections for the following issues:
- Packages that will be removed from Debian testing
- Packages that are not in Debian testing
- Good first issues for beginners
- Issues for which the package maintainer has requested help
The overall "How can I help?" section is collapsed by default.
Test:
- View the page in stable and testing container.
- Run help functional tests.
Closes: #536
Signed-off-by: James Valleroy
[sunil: Minor indentation fix]
Signed-off-by: Sunil Mohan Adapa
Reviewed-by: Sunil Mohan Adapa
---
.../help/templates/help_contribute.html | 72 +++++++++++++++++++
plinth/modules/help/views.py | 52 +++++++++++++-
2 files changed, 122 insertions(+), 2 deletions(-)
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 "Show issues" %}
+
+
+
+
{% trans "Packages that will be removed from Debian testing" %}
+
+ {% for issue in testing_autorm %}
+ -
+ {% for package in issue.packages %}
+ {{ package }} {% endfor %}
+ ({% trans "source package:" %}
+
+ {{ issue.source }}):
+ {% for bug in issue.bugs %}
+
+ #{{ bug }}
+ {% endfor %}
+
+ {% endfor %}
+
+
+
{% trans "Packages that are not in Debian testing" %}
+
+ {% for issue in no_testing %}
+ -
+ {{ issue.package }}
+ ({% trans "source package:" %}
+
+ {{ issue.source }})
+
+ {% endfor %}
+
+
+
{% trans "Good first issues for beginners" %}
+
+ {% for issue in gift %}
+ -
+ {{ issue.package }}:
+
+ #{{ issue.bug }}
+ {{ issue.title }}
+
+ {% endfor %}
+
+
+
{% trans "Issues for which the package maintainer has requested help" %}
+
+ {% for issue in help %}
+ -
+ {{ issue.package }}:
+
+ #{{ issue.bug }}
+ {{ issue.title }}
+
+ {% endfor %}
+
+
+
{% 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):