Ignore:
Timestamp:
19 Jun 2012, 06:48:17 (13 years ago)
Author:
Henrik Bettermann
Message:

Add public_name filed to IUserAccount. This attribute can be used in students and applicants to hide the real name in histories and on slips.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/authentication.py

    r8344 r8756  
    2222from zope.component import getUtility, getUtilitiesFor
    2323from zope.interface import Interface
     24from zope.schema import getFields
    2425from zope.securitypolicy.interfaces import (
    2526    IPrincipalRoleMap, IPrincipalRoleManager)
     
    3435from waeup.kofa.interfaces import (ILocalRoleSetEvent,
    3536    IUserAccount, IAuthPluginUtility, IPasswordValidator,
    36     IKofaPrincipal, IKofaPrincipalInfo)
     37    IKofaPrincipal, IKofaPrincipalInfo, IKofaPluggable)
    3738
    3839def setup_authentication(pau):
     
    150151
    151152    def __init__(self, name, password, title=None, description=None,
    152                  email=None, phone=None, roles = []):
     153                 email=None, phone=None, public_name=None, roles = []):
    153154        self.name = name
    154155        if title is None:
     
    158159        self.email = email
    159160        self.phone = phone
     161        self.public_name = public_name
    160162        self.setPassword(password)
    161163        self.setSiteRolesForPrincipal(roles)
     
    356358                obj, local_role, user_name, granted=False))
    357359    return
     360
     361class UsersPlugin(grok.GlobalUtility):
     362    """A plugin that updates users.
     363    """
     364
     365    grok.implements(IKofaPluggable)
     366    grok.name('users')
     367
     368    deprecated_attributes = []
     369
     370    def setup(self, site, name, logger):
     371        return
     372
     373    def update(self, site, name, logger):
     374        users = site['users']
     375        items = getFields(IUserAccount).items()
     376        for user in users.values():
     377            # Add new attributes
     378            for i in items:
     379                if not hasattr(user,i[0]):
     380                    setattr(user,i[0],i[1].missing_value)
     381                    logger.info(
     382                        'UsersPlugin: %s attribute %s added.' % (
     383                        user.name,i[0]))
     384            # Remove deprecated attributes
     385            for i in self.deprecated_attributes:
     386                try:
     387                    delattr(user,i)
     388                    logger.info(
     389                        'UsersPlugin: %s attribute %s deleted.' % (
     390                        user.name,i))
     391                except AttributeError:
     392                    pass
     393        return
  • main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py

    r8685 r8756  
    423423        required = False,)
    424424
     425    public_name = schema.TextLine(
     426        title = _(u'Public Name'),
     427        description = u'This name appears on student pages.',
     428        required = False,)
     429
    425430    description = schema.Text(
    426431        title = _(u'Description/Notice'),
  • main/waeup.kofa/trunk/src/waeup/kofa/students/authentication.py

    r8350 r8756  
    4040    grok.implements(IUserAccount)
    4141
     42    public_name = None
     43
    4244    @property
    4345    def name(self):
Note: See TracChangeset for help on using the changeset viewer.