2015-11-12 21:11:48 +01:00
|
|
|
# -*- python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# Debian Member Portfolio Service views
|
|
|
|
#
|
2023-06-03 17:56:08 +02:00
|
|
|
# Copyright © 2015-2023 Jan Dittberner <jan@dittberner.info>
|
2015-11-12 21:11:48 +01:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
|
|
|
|
# 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 <https://www.gnu.org/licenses/>.
|
|
|
|
#
|
2015-11-11 00:49:12 +01:00
|
|
|
import json
|
|
|
|
import logging
|
|
|
|
|
2023-06-03 17:56:08 +02:00
|
|
|
from config import LANGUAGES
|
2015-11-10 22:31:14 +01:00
|
|
|
from debianmemberportfolio import app, babel
|
2023-06-03 17:56:08 +02:00
|
|
|
from flask import abort, g, make_response, render_template, request
|
|
|
|
|
2017-08-20 21:10:27 +02:00
|
|
|
# noinspection PyPep8Naming
|
2017-09-10 10:43:56 +02:00
|
|
|
from flask_babel import lazy_gettext as N_
|
2023-06-03 17:56:08 +02:00
|
|
|
|
2015-11-11 00:49:12 +01:00
|
|
|
from .forms import DeveloperData, DeveloperDataRequest
|
|
|
|
from .model import dddatabuilder
|
2015-11-12 21:11:48 +01:00
|
|
|
from .model.urlbuilder import build_urls
|
2015-11-11 00:49:12 +01:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
2015-11-10 22:31:14 +01:00
|
|
|
|
2015-11-12 21:11:48 +01:00
|
|
|
#: This dictionary defines groups of labeled portfolio items.
|
|
|
|
_LABELS = {
|
2023-06-03 17:56:08 +02:00
|
|
|
"overview": {
|
|
|
|
"label": N_("Overview"),
|
|
|
|
"ddpo": N_("Debian Member's Package Overview"),
|
|
|
|
"alladdresses": N_(
|
|
|
|
"""Debian Member's Package Overview
|
|
|
|
... showing all email addresses"""
|
|
|
|
),
|
2015-11-12 21:11:48 +01:00
|
|
|
},
|
2023-06-03 17:56:08 +02:00
|
|
|
"bugs": {
|
|
|
|
"label": N_("Bugs"),
|
|
|
|
"received": N_(
|
|
|
|
"""bugs received
|
2015-11-12 21:11:48 +01:00
|
|
|
(note: co-maintainers not listed, see \
|
|
|
|
<a href="https://bugs.debian.org/cgi-bin/bugreport.cgi?\
|
2023-06-03 17:56:08 +02:00
|
|
|
bug=430986">#430986</a>)"""
|
|
|
|
),
|
|
|
|
"reported": N_("bugs reported"),
|
|
|
|
"usertags": N_("user tags"),
|
|
|
|
"wnpp": N_('<a href="https://wiki.debian.org/WNPP">WNPP</a>'),
|
|
|
|
"correspondent": N_("correspondent for bugs"),
|
|
|
|
"graph": N_("one year open bug history graph"),
|
2015-11-12 21:11:48 +01:00
|
|
|
},
|
2023-06-03 17:56:08 +02:00
|
|
|
"build": {
|
|
|
|
"label": N_("Build"),
|
|
|
|
"buildd": N_("buildd.d.o"),
|
|
|
|
"igloo": N_("igloo"),
|
2015-11-12 21:11:48 +01:00
|
|
|
},
|
2023-06-03 17:56:08 +02:00
|
|
|
"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"),
|
|
|
|
"janitor": N_("Debian Janitor"),
|
2015-11-12 21:11:48 +01:00
|
|
|
},
|
2023-06-03 17:56:08 +02:00
|
|
|
"lists": {
|
|
|
|
"label": N_("Mailing Lists"),
|
|
|
|
"dolists": N_("lists.d.o"),
|
|
|
|
"adolists": N_("lists.a.d.o"),
|
2015-11-12 21:11:48 +01:00
|
|
|
},
|
2023-06-03 17:56:08 +02:00
|
|
|
"files": {
|
|
|
|
"label": N_("Files"),
|
|
|
|
"people": N_("people.d.o"),
|
|
|
|
"oldpeople": N_("oldpeople"),
|
2015-11-12 21:11:48 +01:00
|
|
|
},
|
2023-06-03 17:56:08 +02:00
|
|
|
"membership": {
|
|
|
|
"label": N_("Membership"),
|
|
|
|
"nm": N_("NM"),
|
|
|
|
"dbfinger": N_("DB information via finger"),
|
|
|
|
"db": N_("DB information via HTTP"),
|
|
|
|
"salsa": N_("Salsa"),
|
|
|
|
"wiki": N_("Wiki"),
|
|
|
|
"forum": N_("Forum"),
|
2015-11-12 21:11:48 +01:00
|
|
|
},
|
2023-06-03 17:56:08 +02:00
|
|
|
"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_("OpenPGP public key via finger"),
|
|
|
|
"gpgweb": N_("OpenPGP public key via HTTP"),
|
|
|
|
"nm": N_("NM, AM participation"),
|
|
|
|
"contrib": N_("Contribution information"),
|
|
|
|
"repology": N_("Repology information"),
|
2015-11-12 21:11:48 +01:00
|
|
|
},
|
2023-06-03 17:56:08 +02:00
|
|
|
"ssh": {
|
|
|
|
"label": N_("Information reachable via ssh (for Debian Members)"),
|
|
|
|
"owndndoms": N_("owned debian.net domains"),
|
|
|
|
"miainfo": N_(
|
|
|
|
'<a href="https://wiki.debian.org/qa.debian.org/'
|
|
|
|
'MIATeam">MIA</a> database information'
|
|
|
|
),
|
|
|
|
"groupinfo": N_("Group membership information"),
|
2015-11-12 21:11:48 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
#: list of field name tuples for Debian Maintainers
|
2023-06-03 17:56:08 +02:00
|
|
|
DM_TUPLES = (("name", "name"), ("openpgpfp", "openpgpfp"), ("nonddemail", "email"))
|
2015-11-12 21:11:48 +01:00
|
|
|
|
|
|
|
#: list of field name tuples for Debian Developers
|
2023-06-03 17:56:08 +02:00
|
|
|
DD_TUPLES = (("username", "username"), ("salsausername", "username"))
|
2015-11-12 21:11:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
def _get_label(section, url=None):
|
|
|
|
if section in _LABELS:
|
|
|
|
if url:
|
|
|
|
if url in _LABELS[section]:
|
|
|
|
return _LABELS[section][url]
|
2023-06-03 17:56:08 +02:00
|
|
|
elif "label" in _LABELS[section]:
|
|
|
|
return _LABELS[section]["label"]
|
2015-11-12 21:11:48 +01:00
|
|
|
if url:
|
|
|
|
return "%s.%s" % (section, url)
|
|
|
|
return section
|
|
|
|
|
2015-11-10 22:31:14 +01:00
|
|
|
|
|
|
|
@babel.localeselector
|
|
|
|
def get_locale():
|
|
|
|
return request.accept_languages.best_match(LANGUAGES.keys())
|
|
|
|
|
|
|
|
|
|
|
|
@app.before_request
|
|
|
|
def before_request():
|
|
|
|
g.locale = get_locale()
|
|
|
|
|
|
|
|
|
2023-06-03 17:56:08 +02:00
|
|
|
@app.route("/")
|
2015-11-10 22:31:14 +01:00
|
|
|
def index():
|
|
|
|
form = DeveloperData()
|
2023-06-03 17:56:08 +02:00
|
|
|
return render_template("showform.html", form=form)
|
2015-11-10 22:31:14 +01:00
|
|
|
|
|
|
|
|
2023-06-03 17:56:08 +02:00
|
|
|
@app.route("/result")
|
2015-11-10 22:31:14 +01:00
|
|
|
def urllist():
|
|
|
|
form = DeveloperData(request.values)
|
|
|
|
if form.validate():
|
2023-06-03 17:56:08 +02:00
|
|
|
fields = dddatabuilder.build_data(form.data["email"])
|
2017-09-12 21:58:46 +02:00
|
|
|
|
|
|
|
form_data = form.data.copy()
|
2015-11-12 21:11:48 +01:00
|
|
|
|
2023-06-03 17:56:08 +02:00
|
|
|
if fields["type"] in (dddatabuilder.TYPE_DD, dddatabuilder.TYPE_DM):
|
2015-11-12 21:11:48 +01:00
|
|
|
for dmtuple in DM_TUPLES:
|
2017-09-12 21:58:46 +02:00
|
|
|
if not form_data[dmtuple[0]]:
|
|
|
|
form_data[dmtuple[0]] = fields[dmtuple[1]]
|
2023-06-03 17:56:08 +02:00
|
|
|
if fields["type"] == dddatabuilder.TYPE_DD:
|
2015-11-12 21:11:48 +01:00
|
|
|
for ddtuple in DD_TUPLES:
|
2017-09-12 21:58:46 +02:00
|
|
|
if not form_data[ddtuple[0]]:
|
|
|
|
form_data[ddtuple[0]] = fields[ddtuple[1]]
|
2023-06-03 17:56:08 +02:00
|
|
|
if not form_data["wikihomepage"] and form_data["name"]:
|
|
|
|
log.debug("generate wikihomepage from name")
|
|
|
|
form_data["wikihomepage"] = "".join(
|
|
|
|
[part.capitalize() for part in form_data["name"].split()]
|
|
|
|
)
|
2015-11-12 21:11:48 +01:00
|
|
|
|
2017-09-12 21:58:46 +02:00
|
|
|
data = build_urls(form_data)
|
2015-11-12 21:11:48 +01:00
|
|
|
|
2023-06-03 17:56:08 +02:00
|
|
|
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"
|
2015-11-12 21:11:48 +01:00
|
|
|
return response
|
|
|
|
|
|
|
|
for entry in data:
|
2023-06-03 17:56:08 +02:00
|
|
|
if entry[0] in ("url", "error"):
|
2015-11-12 21:11:48 +01:00
|
|
|
entry.append(_get_label(entry[1], entry[2].name))
|
2023-06-03 17:56:08 +02:00
|
|
|
elif entry[0] == "section":
|
2015-11-12 21:11:48 +01:00
|
|
|
entry.append(_get_label(entry[1]))
|
|
|
|
|
2023-06-03 17:56:08 +02:00
|
|
|
return render_template("showurls.html", urldata=data)
|
|
|
|
return render_template("showform.html", form=form)
|
2015-11-10 22:31:14 +01:00
|
|
|
|
|
|
|
|
2023-06-03 17:56:08 +02:00
|
|
|
@app.route("/htmlformhelper.js")
|
2015-11-10 22:31:14 +01:00
|
|
|
def formhelper_js():
|
2023-06-03 17:56:08 +02:00
|
|
|
response = make_response(render_template("showformscript.js"))
|
|
|
|
response.headers["Content-Type"] = "text/javascript; charset=utf-8"
|
2015-11-10 22:31:14 +01:00
|
|
|
return response
|
|
|
|
|
|
|
|
|
2023-06-03 17:56:08 +02:00
|
|
|
@app.route("/showformscripts/fetchdddata/")
|
2015-11-10 22:31:14 +01:00
|
|
|
def fetchdddata():
|
2015-11-11 00:49:12 +01:00
|
|
|
form = DeveloperDataRequest(request.values)
|
|
|
|
if form.validate():
|
2023-06-03 17:56:08 +02:00
|
|
|
fields = dddatabuilder.build_data(form.data["email"])
|
2015-11-11 00:49:12 +01:00
|
|
|
log.debug(fields)
|
|
|
|
response = make_response(json.dumps(fields))
|
2023-06-03 17:56:08 +02:00
|
|
|
response.headers["Content-Type"] = "application/json"
|
2015-11-11 00:49:12 +01:00
|
|
|
return response
|
2023-06-03 17:56:08 +02:00
|
|
|
abort(400, "\n".join(["%s: %s" % (key, form.errors[key]) for key in form.errors]))
|