1 from portal.portalpage import PortalPage
2 from plugins.wizard import Wizard
3 from plugins.form import CreateForm
4 from plugins.raw.raw import Raw # XXX
6 from myslice.viewutils import the_user
8 from django.template.loader import render_to_string
9 from django.template import RequestContext
13 WIZARD_TITLE = 'User registration'
14 STEP1_TITLE = 'Enter your details'
15 STEP2_TITLE = 'Select your institution'
16 STEP3_TITLE = 'Authentication'
17 STEP4_TITLE = 'Request a slice (optional)'
18 STEP5_TITLE = 'Waiting for validation'
19 STEP6_TITLE = 'Account validated'
21 STEP0 = render_to_string('account_validated.html', context_instance=RequestContext(request))
28 STEP5 = render_to_string('account_validated.html', context_instance=RequestContext(request))
30 p = PortalPage(request)
32 # This is redundant with the Wizard title
33 p << "<h3>User registration</h3>"
39 # If the user already exists (is logged), let's display a summary of his account details
40 # Otherwise propose a form to fill in
42 # Fill a disabled form with user info
43 # Please logout to register another user
44 sons.append(Raw(page=p, title=STEP1_TITLE, togglable=False, html=STEP0))
47 # XXX This should become local:user
48 # We could pass a list of fields also, instead of retrieving them from metadata
49 # Otherwise we need some heuristics to display nice forms
51 'name' : 'First name',
52 'field' : 'firstname',
54 'validate_rx' : '^[a-zA-Z -]+$',
55 'validate_err': 'Your first name must be comprised of letters only',
56 'description' : 'Enter your first name',
61 'validate_rx' : '^[a-zA-Z -]+$',
62 'validate_err': 'Your last name must be comprised of letters only',
63 'description' : 'Enter your last name',
68 'description' : 'Enter your email address',
73 'description' : 'Enter your password',
75 'name' : 'Confirm password',
76 'field' : 'password2',
78 'description' : 'Enter your password again',
80 sons.append(CreateForm(page = p, title = STEP1_TITLE, togglable = False, fields = field_list))
83 # If the user already exists (is logged), let's display a summary of its institution
84 # Otherwise propose a form to fill in (we should base our selection on the email)
86 # Fill a disabled form with institution
87 # Please logout to register another user
88 sons.append(Raw(page=p, title=STEP2_TITLE, togglable=False, html="User created"))
91 sons.append(CreateForm(page = p, title = STEP2_TITLE, togglable = False, object = 'slice')) #institution'))
94 # Please should your prefered authentication method
95 # This step should allow the user to either choose the user or managed mode in MySlice
96 sons.append(Raw(page = p, title = STEP3_TITLE, togglable = False, html = STEP2_HTML))
98 # Step 4: Request a slice (optional)
99 sons.append(CreateForm(page = p, title = STEP4_TITLE, togglable = False, object = 'slice'))
101 # Step 5: Your request is waiting for validation
103 sons.append(Raw(page = p, title = STEP5_TITLE, togglable = False, html = STEP4))
105 # Step 6: Account validation = welcome for newly validated users
110 sons.append(Raw(page = p, title = STEP6_TITLE, togglable = False, html = STEP5))
114 title = WIZARD_TITLE,
117 start_step = start_step,
120 p << wizard.render(request) # in portal page if possible