12134.2.18
by William Grant
Fix copyright years. |
1 |
# Copyright 2011 Canonical Ltd. This software is licensed under the
|
12134.2.5
by William Grant
Use a custom widget on +activate-ppa to show the URL that a name will give. |
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
3 |
||
4 |
"""Widgets related to `IArchive`."""
|
|
5 |
||
6 |
__metaclass__ = type |
|
7 |
__all__ = [ |
|
8 |
'PPANameWidget', |
|
9 |
]
|
|
10 |
||
11 |
import urlparse |
|
12 |
||
13 |
from canonical.config import config |
|
12293.1.3
by Curtis Hovey
Migrated all the canonical.widgets to app.widgets. |
14 |
from lp.app.widgets.textwidgets import URIComponentWidget |
12134.2.12
by William Grant
Factor common bits of ProductNameWidget and PPANameWidget into URIComponentWidget. |
15 |
|
16 |
||
17 |
class PPANameWidget(URIComponentWidget): |
|
12134.2.5
by William Grant
Use a custom widget on +activate-ppa to show the URL that a name will give. |
18 |
"""A text input widget that looks like a URL path component entry."""
|
19 |
||
20 |
@property
|
|
21 |
def base_url(self): |
|
22 |
field = self.context |
|
23 |
owner = field.context |
|
24 |
if owner.private: |
|
25 |
root = config.personalpackagearchive.private_base_url |
|
26 |
else: |
|
27 |
root = config.personalpackagearchive.base_url |
|
12134.2.12
by William Grant
Factor common bits of ProductNameWidget and PPANameWidget into URIComponentWidget. |
28 |
return urlparse.urljoin(root, owner.name) + '/' |