The Debian Member Portfolio Service
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
7.3 KiB

# -*- python -*-
# -*- coding: utf-8 -*-
# Debian Member Portfolio Service views
# Copyright © 2015-2020 Jan Dittberner <>
# This file is part of the Debian Member Portfolio Service.
# Debian Member Portfolio Service is free software: you can redistribute it
# and/or modify it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
# Debian Member Portfolio Service is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <>.
import json
import logging
from debianmemberportfolio import app, babel
from flask import g, make_response, request, render_template, abort
# noinspection PyPep8Naming
from flask_babel import lazy_gettext as N_
from config import LANGUAGES
from .forms import DeveloperData, DeveloperDataRequest
from .model import dddatabuilder
from .model.urlbuilder import build_urls
log = logging.getLogger(__name__)
#: This dictionary defines groups of labeled portfolio items.
'overview': {
'label': N_('Overview'),
'ddpo': N_("Debian Member's Package Overview"),
'alladdresses': N_("""Debian Member's Package Overview
... showing all email addresses"""),
'bugs': {
'label': N_('Bugs'),
'received': N_('''bugs received
(note: co-maintainers not listed, see \
<a href="\
'reported': N_('bugs reported'),
'usertags': N_('user tags'),
'searchall': N_('all messages (i.e., full text search for \
developer name on all bug logs)'),
'wnpp': N_('<a href="">WNPP</a>'),
'correspondent': N_('correspondent for bugs'),
'graph': N_('one year open bug history graph'),
'build': {
'label': N_('Build'),
'buildd': N_('buildd.d.o'),
'igloo': N_('igloo'),
'qa': {
'label': N_('Quality Assurance'),
'dmd': N_('maintainer dashboard'),
'lintian': N_('lintian reports'),
'lintianfull': N_('full lintian reports (i.e. including \
"info"-level messages)'),
'piuparts': N_('piuparts'),
'patchtracker': N_('Debian patch tracking system'),
'duck': N_('Debian Url ChecKer'),
'janitor': N_('Debian Janitor'),
'lists': {
'label': N_('Mailing Lists'),
'dolists': N_('lists.d.o'),
'adolists': N_('lists.a.d.o'),
'files': {
'label': N_('Files'),
'people': N_('people.d.o'),
'oldpeople': N_('oldpeople'),
'membership': {
'label': N_('Membership'),
'nm': N_('NM'),
'dbfinger': N_('DB information via finger'),
'db': N_('DB information via HTTP'),
'webid': N_('FOAF profile'),
'salsa': N_('Salsa'),
'wiki': N_('Wiki'),
'forum': N_('Forum'),
'miscellaneous': {
'label': N_('Miscellaneous'),
'debtags': N_('debtags'),
'planetname': N_('Planet Debian (name)'),
'planetuser': N_('Planet Debian (username)'),
'links': N_('links'),
'website': N_('Debian website'),
'search': N_('Debian search'),
'gpgfinger': N_('GPG public key via finger'),
'gpgweb': N_('GPG public key via HTTP'),
'nm': N_('NM, AM participation'),
'contrib': N_('Contribution information'),
'repology': N_('Repology information'),
'ssh': {
'label': N_('Information reachable via ssh (for Debian Members)'),
'owndndoms': N_('owned domains'),
'miainfo': N_('<a href="'
'MIATeam">MIA</a> database information'),
'groupinfo': N_('Group membership information'),
'ubuntu': {
'label': N_('Ubuntu'),
'ubuntudiff': N_('Available patches from Ubuntu'),
#: list of field name tuples for Debian Maintainers
DM_TUPLES = (('name', 'name'),
('gpgfp', 'gpgfp'),
('nonddemail', 'email'))
#: list of field name tuples for Debian Developers
DD_TUPLES = (('username', 'username'),
('salsausername', 'username'))
def _get_label(section, url=None):
if section in _LABELS:
if url:
if url in _LABELS[section]:
return _LABELS[section][url]
elif 'label' in _LABELS[section]:
return _LABELS[section]['label']
if url:
return "%s.%s" % (section, url)
return section
def get_locale():
return request.accept_languages.best_match(LANGUAGES.keys())
def before_request():
g.locale = get_locale()
def index():
form = DeveloperData()
return render_template('showform.html', form=form)
def urllist():
form = DeveloperData(request.values)
if form.validate():
fields = dddatabuilder.build_data(['email'])
form_data =
if fields['type'] in (dddatabuilder.TYPE_DD, dddatabuilder.TYPE_DM):
for dmtuple in DM_TUPLES:
if not form_data[dmtuple[0]]:
form_data[dmtuple[0]] = fields[dmtuple[1]]
if fields['type'] == dddatabuilder.TYPE_DD:
for ddtuple in DD_TUPLES:
if not form_data[ddtuple[0]]:
form_data[ddtuple[0]] = fields[ddtuple[1]]
if not form_data['wikihomepage']:
log.debug('generate wikihomepage from name')
form_data['wikihomepage'] = "".join([
part.capitalize() for part in form_data['name'].split()
data = build_urls(form_data)
if form_data['mode'] == 'json':
response = make_response(json.dumps(dict(
[("{}.{}".format(entry[1], entry[2].name), entry[3])
for entry in data if entry[0] == 'url'])))
response.headers['Content-Type'] = 'application/json'
return response
for entry in data:
if entry[0] in ('url', 'error'):
entry.append(_get_label(entry[1], entry[2].name))
elif entry[0] == 'section':
return render_template('showurls.html', urldata=data)
return render_template('showform.html', form=form)
def formhelper_js():
response = make_response(render_template('showformscript.js'))
response.headers['Content-Type'] = 'text/javascript; charset=utf-8'
return response
def fetchdddata():
form = DeveloperDataRequest(request.values)
if form.validate():
fields = dddatabuilder.build_data(['email'])
response = make_response(json.dumps(fields))
response.headers['Content-Type'] = 'application/json'
return response
"\n".join(["%s: %s" % (key, form.errors[key]) for key in form.errors])