def getLoginRedirect(self): """ Redirect after login """ plone_utils = getToolByName(self, 'plone_utils') if self.jobTitles is None or len(self.jobTitles) == 0: plone_utils.addPortalMessage(_(u'Thanks for registering, now complete your registration by filling Professional Information.'), 'info') return self.absolute_url() + '/edit?fieldset=Professional%20Information' else: plone_utils.addPortalMessage(_(u'You are now logged in. Welcome!'), 'info') return self.absolute_url() + '/view'
def getLoginRedirect(self): """ Redirect after login """ plone_utils = getToolByName(self, 'plone_utils') if self.jobTitles is None or len(self.jobTitles) == 0: plone_utils.addPortalMessage( _(u'Thanks for registering, now complete your registration by filling Professional Information.' ), 'info') return self.absolute_url( ) + '/edit?fieldset=Professional%20Information' else: plone_utils.addPortalMessage(_(u'You are now logged in. Welcome!'), 'info') return self.absolute_url() + '/view'
def addMember(self, id, password, roles=('JournalAuthor', ), domains='', properties=None, REQUEST=None): '''Creates a PortalMember and returns it. The properties argument can be a mapping with additional member properties. Raises an exception if the given id already exists, the password does not comply with the policy in effect, or the authenticated user is not allowed to grant one of the roles listed (where Member is a special role that can always be granted); these conditions should be detected before the fact so that a cleaner message can be printed. ''' portal_registration = getToolByName(self, 'portal_registration') # XXX: this method violates the rules for tools/utilities: # it depends on a non-utility tool if not portal_registration.isMemberIdAllowed(id): raise ValueError( _(u'The login name you selected is already in ' u'use or is not valid. Please choose another.')) failMessage = portal_registration.testPasswordValidity(password) if failMessage is not None: raise ValueError(failMessage) if properties is not None: failMessage = portal_registration.testPropertiesValidity( properties) if failMessage is not None: raise ValueError(failMessage) # Limit the granted roles. # Anyone is always allowed to grant the 'Member' role. ##_limitGrantedRoles(roles, self, ('Member',)) newid = self.invokeFactory('gcPerson', id, password=password) member = getattr(self, newid) member.setPassword(password) # deal with name fullname = properties.get('fullname') firstName = fullname.split()[0] lastName = ' '.join(fullname.split()[1:]) # Make sure this archetype is initialized data = {} schema = member.Schema() for f in schema._fields.values(): if not f.required: continue if f.__name__ in ["password", "id"]: # Do not set password or member id continue # Autofill member field values if f.vocabulary: value = f.vocabulary[0][0] if f.__name__ in [ 'email', ]: value = properties.get(f.__name__) if f.__name__ == 'firstName': value = firstName if f.__name__ == 'lastName': value = lastName data[f.__name__] = value member.update(**data) member.at_post_create_script() return member
# gcommons from gcommons.Users import UsersMessageFactory as _ from gcommons.Users.interfaces import IgcPerson from gcommons.Users.interfaces import IgcPersonModifiedEvent from gcommons.Users.config import PROJECTNAME from gcommons.Users.config import PASSWORD_KEY logger = logging.getLogger('gcommons.Users.content.gcPerson') gcPersonSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema(( # # Schemata: Basic Information # atapi.StringField(name='firstName', widget=atapi.StringWidget( label=_(u"First Name"), i18n_domain='gcommons.Users', ), required=True, schemata="Basic Information", searchable=True), atapi.StringField(name='middleName', widget=atapi.StringWidget( label=_(u"Middle Name"), i18n_domain='gcommons.Users', ), required=False, schemata="Basic Information", searchable=True), atapi.StringField(name='lastName', widget=atapi.StringWidget(
def addMember(self, id, password, roles=('JournalAuthor',), domains='', properties=None, REQUEST=None): '''Creates a PortalMember and returns it. The properties argument can be a mapping with additional member properties. Raises an exception if the given id already exists, the password does not comply with the policy in effect, or the authenticated user is not allowed to grant one of the roles listed (where Member is a special role that can always be granted); these conditions should be detected before the fact so that a cleaner message can be printed. ''' portal_registration = getToolByName(self, 'portal_registration') # XXX: this method violates the rules for tools/utilities: # it depends on a non-utility tool if not portal_registration.isMemberIdAllowed(id): raise ValueError(_(u'The login name you selected is already in ' u'use or is not valid. Please choose another.')) failMessage = portal_registration.testPasswordValidity(password) if failMessage is not None: raise ValueError(failMessage) if properties is not None: failMessage = portal_registration.testPropertiesValidity(properties) if failMessage is not None: raise ValueError(failMessage) # Limit the granted roles. # Anyone is always allowed to grant the 'Member' role. ##_limitGrantedRoles(roles, self, ('Member',)) newid = self.invokeFactory('gcPerson', id, password=password) member = getattr(self, newid) member.setPassword(password) # deal with name fullname = properties.get('fullname') firstName = fullname.split()[0] lastName = ' '.join(fullname.split()[1:]) # Make sure this archetype is initialized data = {} schema = member.Schema() for f in schema._fields.values(): if not f.required: continue if f.__name__ in [ "password", "id" ]: # Do not set password or member id continue # Autofill member field values if f.vocabulary: value = f.vocabulary[0][0] if f.__name__ in ['email',]: value = properties.get(f.__name__) if f.__name__ == 'firstName': value = firstName if f.__name__ == 'lastName': value = lastName data[f.__name__] = value member.update(**data) member.at_post_create_script() return member
from gcommons.Users.interfaces import IgcPersonModifiedEvent from gcommons.Users.config import PROJECTNAME from gcommons.Users.config import PASSWORD_KEY logger = logging.getLogger("gcommons.Users.content.gcPerson") gcPersonSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema( ( # # Schemata: Basic Information # atapi.StringField( name="firstName", widget=atapi.StringWidget(label=_(u"First Name"), i18n_domain="gcommons.Users"), required=True, schemata="Basic Information", searchable=True, ), atapi.StringField( name="middleName", widget=atapi.StringWidget(label=_(u"Middle Name"), i18n_domain="gcommons.Users"), required=False, schemata="Basic Information", searchable=True, ), atapi.StringField( name="lastName", widget=atapi.StringWidget(label=_(u"Last Name"), i18n_domain="gcommons.Users"), required=True,