2009-01-21 16:11:39 +01:00
|
|
|
# -*- python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# DDPortfolio service DdportfolioController
|
2012-01-07 01:13:53 +01:00
|
|
|
# Copyright © 2009, 2010, 2011, 2012 Jan Dittberner <jan@dittberner.info>
|
2009-01-21 16:11:39 +01:00
|
|
|
#
|
|
|
|
# This file is part of DDPortfolio service.
|
|
|
|
#
|
|
|
|
# DDPortfolio 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.
|
|
|
|
#
|
|
|
|
# DDPortfolio 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
|
|
|
|
# <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
2009-01-20 22:39:05 +01:00
|
|
|
import logging
|
2009-01-21 01:11:01 +01:00
|
|
|
import simplejson
|
2009-01-20 22:39:05 +01:00
|
|
|
|
2012-01-07 01:23:59 +01:00
|
|
|
from pylons import request, response, tmpl_context as c
|
2010-04-18 21:14:04 +02:00
|
|
|
from pylons.i18n import N_, _
|
|
|
|
import formencode.api
|
|
|
|
import formencode.validators
|
2010-04-17 12:48:31 +02:00
|
|
|
|
|
|
|
from ddportfolioservice.lib.base import BaseController, render
|
|
|
|
from ddportfolioservice.model.form import DDDataRequest, DeveloperData
|
|
|
|
from ddportfolioservice.model.urlbuilder import build_urls
|
2009-02-17 23:30:03 +01:00
|
|
|
from ddportfolioservice.model import dddatabuilder
|
2009-01-20 22:39:05 +01:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2012-01-07 01:46:57 +01:00
|
|
|
|
2009-01-20 22:39:05 +01:00
|
|
|
class DdportfolioController(BaseController):
|
2009-01-22 17:34:46 +01:00
|
|
|
_LABELS = {
|
2012-01-07 01:46:57 +01:00
|
|
|
'overview': {
|
|
|
|
'label': N_('Overview'),
|
|
|
|
'ddpo': N_("Debian Member's Package Overview"),
|
|
|
|
'alladdresses': N_("""Debian Member's Package Overview
|
2009-01-22 17:34:46 +01:00
|
|
|
... showing all email addresses"""),
|
|
|
|
},
|
2012-01-07 01:46:57 +01:00
|
|
|
'bugs': {
|
|
|
|
'label': N_('Bugs'),
|
|
|
|
'received': N_('''bugs received
|
2009-01-22 17:34:46 +01:00
|
|
|
(note: co-maintainers not listed, see \
|
|
|
|
<a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?\
|
|
|
|
bug=430986">#430986</a>)'''),
|
2012-01-07 01:46:57 +01:00
|
|
|
'reported': N_('bugs reported'),
|
|
|
|
'usertags': N_('user tags'),
|
|
|
|
'searchall': N_('all messages (i.e., full text search for \
|
2009-01-22 17:34:46 +01:00
|
|
|
developer name on all bug logs)'),
|
2012-01-07 01:46:57 +01:00
|
|
|
'wnpp': N_('<a href="http://wiki.debian.org/WNPP">WNPP</a>'),
|
|
|
|
'correspondent': N_('correspondent for bugs'),
|
|
|
|
'graph': N_('one year open bug history graph'),
|
2009-01-22 17:34:46 +01:00
|
|
|
},
|
2012-01-07 01:46:57 +01:00
|
|
|
'build': {
|
|
|
|
'label': N_('Build'),
|
|
|
|
'buildd': N_('buildd.d.o'),
|
|
|
|
'igloo': N_('igloo'),
|
2009-01-22 17:34:46 +01:00
|
|
|
},
|
2012-01-07 01:46:57 +01:00
|
|
|
'qa': {
|
|
|
|
'label': N_('Quality Assurance'),
|
2012-07-02 02:26:28 +02:00
|
|
|
'dmd': N_('maintainer dashboard'),
|
2012-01-07 01:46:57 +01:00
|
|
|
'lintian': N_('lintian reports'),
|
|
|
|
'lintianfull': N_('full lintian reports (i.e. including \
|
2009-01-22 17:34:46 +01:00
|
|
|
"info"-level messages)'),
|
2012-01-07 01:46:57 +01:00
|
|
|
'piuparts': N_('piuparts'),
|
|
|
|
'patchtracker': N_('Debian patch tracking system'),
|
2012-12-07 02:31:00 +01:00
|
|
|
'duck': N_('Debian Url ChecKer'),
|
2009-01-22 17:34:46 +01:00
|
|
|
},
|
2012-01-07 01:46:57 +01:00
|
|
|
'lists': {
|
|
|
|
'label': N_('Mailing Lists'),
|
|
|
|
'dolists': N_('lists.d.o'),
|
|
|
|
'adolists': N_('lists.a.d.o'),
|
|
|
|
'gmane': N_('gmane'),
|
2009-01-22 17:34:46 +01:00
|
|
|
},
|
2012-01-07 01:46:57 +01:00
|
|
|
'files': {
|
|
|
|
'label': N_('Files'),
|
|
|
|
'people': N_('people.d.o'),
|
|
|
|
'oldpeople': N_('oldpeople'),
|
|
|
|
'alioth': N_('Alioth'),
|
2009-01-22 17:34:46 +01:00
|
|
|
},
|
2012-01-07 01:46:57 +01:00
|
|
|
'membership': {
|
|
|
|
'label': N_('Membership'),
|
|
|
|
'nm': N_('NM'),
|
|
|
|
'dbfinger': N_('DB information via finger'),
|
|
|
|
'db': N_('DB information via HTTP'),
|
|
|
|
'alioth': N_('Alioth'),
|
|
|
|
'wiki': N_('Wiki'),
|
|
|
|
'forum': N_('Forum'),
|
2009-01-22 17:34:46 +01:00
|
|
|
},
|
2012-01-07 01:46:57 +01:00
|
|
|
'miscellaneous': {
|
|
|
|
'label': N_('Miscellaneous'),
|
|
|
|
'debtags': N_('debtags'),
|
|
|
|
'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'),
|
2012-03-13 08:56:00 +01:00
|
|
|
'nm': N_('NM, AM participation'),
|
2009-01-22 17:34:46 +01:00
|
|
|
},
|
2012-01-07 01:46:57 +01:00
|
|
|
'ssh': {
|
|
|
|
'label': N_('Information reachable via ssh (for Debian Members)'),
|
|
|
|
'owndndoms': N_('owned debian.net domains'),
|
|
|
|
'miainfo': N_('<a href="http://wiki.debian.org/qa.debian.org/'
|
|
|
|
'MIATeam">MIA</a> database information'),
|
|
|
|
'groupinfo': N_('Group membership information'),
|
2010-06-04 00:24:15 +02:00
|
|
|
},
|
2012-01-07 01:46:57 +01:00
|
|
|
'ubuntu': {
|
|
|
|
'label': N_('Ubuntu'),
|
|
|
|
'ubuntudiff': N_('Available patches from Ubuntu'),
|
2009-01-22 17:34:46 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
def _get_label(self, section, url=None):
|
|
|
|
if section in self._LABELS:
|
|
|
|
if url:
|
|
|
|
if url in self._LABELS[section]:
|
|
|
|
return self._LABELS[section][url]
|
|
|
|
elif 'label' in self._LABELS[section]:
|
|
|
|
return self._LABELS[section]['label']
|
|
|
|
if url:
|
|
|
|
return "%s.%s" % (section, url)
|
|
|
|
return section
|
|
|
|
|
2009-01-20 22:39:05 +01:00
|
|
|
def index(self):
|
2012-01-07 01:46:57 +01:00
|
|
|
"""
|
|
|
|
Render the input form.
|
|
|
|
"""
|
2009-01-20 23:15:11 +01:00
|
|
|
return render('/showform.mako')
|
2009-01-21 00:11:19 +01:00
|
|
|
|
2009-01-22 17:34:46 +01:00
|
|
|
def urllist(self):
|
|
|
|
"""Handle the actual data."""
|
2009-02-17 23:30:03 +01:00
|
|
|
schema = DDDataRequest()
|
2009-01-21 00:11:19 +01:00
|
|
|
try:
|
2009-01-21 22:46:59 +01:00
|
|
|
formencode.api.set_stdtranslation(
|
|
|
|
domain="FormEncode",
|
|
|
|
languages=[lang[0:2] for lang in request.languages])
|
2009-01-21 00:11:19 +01:00
|
|
|
form_result = schema.to_python(request.params)
|
|
|
|
except formencode.validators.Invalid, error:
|
2012-01-07 01:46:57 +01:00
|
|
|
c.messages = {'errors': error.unpack_errors()}
|
2009-01-21 00:11:19 +01:00
|
|
|
return render('/showform.mako')
|
2009-02-17 23:30:03 +01:00
|
|
|
fields = dddatabuilder.build_data(form_result['email'])
|
|
|
|
rp = request.params.copy()
|
2010-06-11 21:42:30 +02:00
|
|
|
|
|
|
|
DM_TUPLES = (('name', 'name'),
|
|
|
|
('gpgfp', 'gpgfp'),
|
|
|
|
('nonddemail', 'email'))
|
|
|
|
DD_TUPLES = (('username', 'username'),
|
|
|
|
('aliothusername', 'username'))
|
|
|
|
|
|
|
|
if fields['type'] in (dddatabuilder.TYPE_DD, dddatabuilder.TYPE_DM):
|
|
|
|
for tuple in DM_TUPLES:
|
|
|
|
if not tuple[0] in rp or not rp[tuple[0]]:
|
|
|
|
rp[tuple[0]] = fields[tuple[1]]
|
|
|
|
if fields['type'] == dddatabuilder.TYPE_DD:
|
|
|
|
for tuple in DD_TUPLES:
|
2009-02-17 23:30:03 +01:00
|
|
|
if not tuple[0] in rp or not rp[tuple[0]]:
|
|
|
|
rp[tuple[0]] = fields[tuple[1]]
|
|
|
|
|
|
|
|
schema = DeveloperData()
|
|
|
|
try:
|
|
|
|
formencode.api.set_stdtranslation(
|
|
|
|
domain="FormEncode",
|
|
|
|
languages=[lang[0:2] for lang in request.languages])
|
|
|
|
form_result = schema.to_python(rp)
|
|
|
|
except formencode.validators.Invalid, error:
|
2012-01-07 01:46:57 +01:00
|
|
|
c.messages = {'errors': error.unpack_errors()}
|
2009-02-17 23:30:03 +01:00
|
|
|
return render('/showform.mako')
|
2010-06-03 22:58:34 +02:00
|
|
|
if form_result['wikihomepage'] is None:
|
|
|
|
log.debug('generate wikihomepage from name')
|
|
|
|
form_result['wikihomepage'] = "".join(
|
|
|
|
[part.capitalize() for part in form_result['name'].split()])
|
2010-06-03 21:49:34 +02:00
|
|
|
data = build_urls(form_result)
|
2010-06-03 22:58:34 +02:00
|
|
|
if form_result['mode'] == 'json':
|
2009-02-17 23:30:03 +01:00
|
|
|
response.headers['Content-Type'] = 'text/javascript'
|
2009-01-22 17:34:46 +01:00
|
|
|
return simplejson.dumps(
|
|
|
|
dict([("%s.%s" % \
|
2010-06-04 00:24:15 +02:00
|
|
|
(entry[1], entry[2].name), entry[3]) \
|
2009-01-22 17:34:46 +01:00
|
|
|
for entry in data if entry[0] == 'url']))
|
|
|
|
for entry in data:
|
|
|
|
if entry[0] in ('url', 'error'):
|
2010-06-04 00:24:15 +02:00
|
|
|
entry.append(_(self._get_label(entry[1], entry[2].name)))
|
2009-01-22 17:34:46 +01:00
|
|
|
elif entry[0] == 'section':
|
|
|
|
entry.append(_(self._get_label(entry[1])))
|
2009-01-21 01:11:01 +01:00
|
|
|
c.urldata = data
|
|
|
|
return render('/showurls.mako')
|