|
a/opensourceprojects/controllers.py |
|
b/opensourceprojects/controllers.py |
|
... |
|
... |
7 |
from allura import model as M
|
7 |
from allura import model as M
|
8 |
from allura.lib import plugin
|
8 |
from allura.lib import plugin
|
9 |
|
9 |
|
10 |
from tg import expose, session, flash, redirect, validate, config
|
10 |
from tg import expose, session, flash, redirect, validate, config
|
11 |
from tg.decorators import with_trailing_slash, without_trailing_slash
|
11 |
from tg.decorators import with_trailing_slash, without_trailing_slash
|
|
|
12 |
|
|
|
13 |
try:
|
12 |
from pylons import c, g, request, response
|
14 |
from pylons import c, g, request, response
|
|
|
15 |
except ImportError:
|
|
|
16 |
# in Allura 1.0 c,g cannot be imported directly
|
|
|
17 |
from pylons import tmpl_context as c, app_globals as g
|
13 |
|
18 |
|
14 |
import ew as ew_core
|
19 |
import ew as ew_core
|
15 |
import ew.jinja2_ew as ew
|
20 |
import ew.jinja2_ew as ew
|
16 |
from allura.lib import validators as V
|
21 |
from allura.lib import validators as V
|
17 |
from formencode import validators as fev
|
22 |
from formencode import validators as fev
|
|
... |
|
... |
21 |
from hashlib import sha256
|
26 |
from hashlib import sha256
|
22 |
import logging
|
27 |
import logging
|
23 |
|
28 |
|
24 |
log = logging.getLogger(__name__)
|
29 |
log = logging.getLogger(__name__)
|
25 |
|
30 |
|
|
|
31 |
try:
|
|
|
32 |
username_re_validator = h.re_path_portion
|
|
|
33 |
except:
|
|
|
34 |
# Since Allura 1.0
|
|
|
35 |
username_re_validator = h.re_project_name
|
|
|
36 |
|
26 |
class OSPRegistrationForm(forms.ForgeForm):
|
37 |
class OSPRegistrationForm(forms.ForgeForm):
|
27 |
template = 'jinja:opensourceprojects:templates/widgets/forge_form.html'
|
38 |
template = 'jinja:opensourceprojects:templates/widgets/forge_form.html'
|
28 |
class fields(ew_core.NameList):
|
39 |
class fields(ew_core.NameList):
|
29 |
display_name = ew.TextField(
|
40 |
display_name = ew.TextField(
|
30 |
label='Display Name',
|
41 |
label='Display Name',
|
|
... |
|
... |
32 |
attrs={'placeholder':'Display Name', 'class':'displayname'},
|
43 |
attrs={'placeholder':'Display Name', 'class':'displayname'},
|
33 |
show_label=False
|
44 |
show_label=False
|
34 |
)
|
45 |
)
|
35 |
username = ew.TextField(
|
46 |
username = ew.TextField(
|
36 |
label='Desired Username',
|
47 |
label='Desired Username',
|
37 |
validator=fev.Regex(h.re_path_portion, not_empty=True),
|
48 |
validator=fev.Regex(username_re_validator, not_empty=True),
|
38 |
attrs={'placeholder':'Username', 'class':'username'},
|
49 |
attrs={'placeholder':'Username', 'class':'username'},
|
39 |
show_label=False
|
50 |
show_label=False
|
40 |
)
|
51 |
)
|
41 |
username.validator._messages['invalid'] = (
|
52 |
username.validator._messages['invalid'] = (
|
42 |
'Usernames can include letters, numbers, and dashes, but must start with a letter' )
|
53 |
'Usernames can include letters, numbers, and dashes, but must start with a letter' )
|