Commits

Thomas Waldmann committed ee71ed6

change user.aliasname to user.display_name

aliasname is a bit misleading now that name itself can be a list.
but in moin 1.x, aliasname was always used for display purposes only,
so display_name is a better name for it (see also displayName in LDAP)

changed 1.9 importer to rename the key accordingly.

Comments (0)

Files changed (8)

MoinMoin/apps/frontend/views.py

     class UserSettingsPersonalForm(Form):
         name = 'usersettings_personal' # "name" is duplicate
         name = String.using(label=L_('Name')).with_properties(placeholder=L_("The login name you want to use")).validated_by(Present())
-        aliasname = String.using(label=L_('Alias-Name'), optional=True).with_properties(placeholder=L_("Your alias name (informational)"))
+        display_name = String.using(label=L_('Display-Name'), optional=True).with_properties(placeholder=L_("Your display name (informational)"))
         openid = String.using(label=L_('OpenID'), optional=True).with_properties(placeholder=L_("Your OpenID address")).validated_by(URLValidator())
         #timezones_keys = sorted(Locale('en').time_zones.keys())
         timezones_keys = [unicode(tz) for tz in pytz.common_timezones]

MoinMoin/auth/ldap_login.py

     "Can't contact LDAP server" - more recent debian installations have tls
     support in libldap2 (see dependency on gnutls) and also in python-ldap.
 
-    TODO: allow more configuration (alias name, ...) by using callables as parameters
+    TODO: allow more configuration (display name, ...) by using callables as parameters
 """
 
 from MoinMoin import log
         # some attribute names we use to extract information from LDAP:
         givenname_attribute=None, # ('givenName') ldap attribute we get the first name from
         surname_attribute=None, # ('sn') ldap attribute we get the family name from
-        aliasname_attribute=None, # ('displayName') ldap attribute we get the aliasname from
+        displayname_attribute=None, # ('displayName') ldap attribute we get the display_name from
         email_attribute=None, # ('mail') ldap attribute we get the email address from
         email_callback=None, # called to make up email address
         name_callback=None, # called to use a Wiki name different from the login name
 
         self.givenname_attribute = givenname_attribute
         self.surname_attribute = surname_attribute
-        self.aliasname_attribute = aliasname_attribute
+        self.displayname_attribute = displayname_attribute
         self.email_attribute = email_attribute
         self.email_callback = email_callback
         self.name_callback = name_callback
                 logging.debug("Searching {0!r}".format(filterstr))
                 attrs = [getattr(self, attr) for attr in [
                                          'email_attribute',
-                                         'aliasname_attribute',
+                                         'displayname_attribute',
                                          'surname_attribute',
                                          'givenname_attribute',
                                          ] if getattr(self, attr) is not None]
                 else:
                     email = self.email_callback(ldap_dict)
 
-                aliasname = ''
+                display_name = ''
                 try:
-                    aliasname = ldap_dict[self.aliasname_attribute][0]
+                    display_name = ldap_dict[self.displayname_attribute][0]
                 except (KeyError, IndexError):
                     pass
-                if not aliasname:
+                if not display_name:
                     sn = ldap_dict.get(self.surname_attribute, [''])[0]
                     gn = ldap_dict.get(self.givenname_attribute, [''])[0]
                     if sn and gn:
-                        aliasname = "{0}, {1}".format(sn, gn)
+                        display_name = "{0}, {1}".format(sn, gn)
                     elif sn:
-                        aliasname = sn
-                aliasname = aliasname.decode(coding)
+                        display_name = sn
+                display_name = display_name.decode(coding)
 
                 if self.name_callback:
                     username = self.name_callback(ldap_dict)
                 else:
                     u = user.User(auth_username=username, auth_method=self.name, auth_attribs=('name', 'password', 'mailto_author', ))
                 u.name = username
-                u.aliasname = aliasname
-                logging.debug("creating user object with name {0!r} email {1!r} alias {2!r}".format(username, email, aliasname))
+                u.display_name = display_name
+                logging.debug("creating user object with name {0!r} email {1!r} display name {2!r}".format(username, email, display_name))
 
             except ldap.INVALID_CREDENTIALS as err:
                 logging.debug("invalid credentials (wrong password?) for dn {0!r} (username: {1!r})".format(dn, username))

MoinMoin/config/default.py

     ('user_defaults',
       dict(
         name=u'anonymous',
-        aliasname=None,
+        display_name=None,
         email=None,
         openid=None,
         css_url=None,

MoinMoin/script/account/create.py

     option_list = (
         Option('--name', '-n', required=True, dest='name', type=unicode,
                help="Set the wiki user name to NAME."),
-        Option('--alias', '-a', required=False, dest="aliasname", type=unicode,
-               help="Set the wiki user alias name to ALIAS (e.g. the real name if NAME is cryptic)."),
+        Option('--display_name', '-d', required=False, dest="display_name", type=unicode,
+               help="Set the wiki user's display name to DISPLAY_NAME (e.g. in case the NAME is cryptic)."),
         Option('--email', '-e', required=True, dest='email', type=unicode,
                help="Set the user's email address to EMAIL."),
         Option('--openid', '-o', required=False, dest='openid', type=unicode,
                help="Set the user's password to PASSWORD."),
     )
 
-    def run(self, name, aliasname, email, openid, password):
+    def run(self, name, display_name, email, openid, password):
         flaskg.unprotected_storage = app.unprotected_storage
         msg = user.create_user(username=name,
                                password=password,

MoinMoin/script/migration/moin19/import19.py

         # rename last_saved to MTIME, int MTIME should be enough:
         metadata[MTIME] = int(float(metadata.get('last_saved', '0')))
 
+        # rename aliasname to display_name:
+        metadata['display_name'] = metadata.get('aliasname')
+
         # rename subscribed_pages to subscribed_items
         metadata['subscribed_items'] = metadata.get('subscribed_pages', [])
 
                                  for interwiki, bookmark in metadata.get('bookmarks', {}).items()]
 
         # stuff we want to get rid of:
-        kill = ['real_language', # crap (use 'language')
+        kill = ['aliasname', # renamed to display_name
+                'real_language', # crap (use 'language')
                 'wikiname_add_spaces', # crap magic (you get it like it is)
                 'recoverpass_key', # user can recover again if needed
                 'editor_default', # not used any more
 
         # finally, remove some empty values (that have empty defaults anyway or
         # make no sense when empty):
-        empty_kill = ['aliasname', 'bookmarks', 'enc_password',
+        empty_kill = ['aliasname', 'display_name', 'bookmarks', 'enc_password',
                       'language', 'css_url', 'email', ] # XXX check subscribed_items, quicklinks
         for key in empty_kill:
             if key in metadata and metadata[key] in [u'', tuple(), {}, [], ]:

MoinMoin/templates/layout.html

 	        <img id="moin-avatar" src="{{ avatar }}" />
 	    {%- endif %}
             {% if user.name -%}
-                {% set wiki_href, aliasname, title, exists = theme_supp.userhome() %}
+                {% set wiki_href, display_name, title, exists = theme_supp.userhome() %}
                 <a href="{{ wiki_href }}" {% if not exists %}class="moin-nonexistent"{% endif %} rel="nofollow" title="{{ title }}">
-                    {{ aliasname }}
+                    {{ display_name }}
                 </a>
                 {% if 'frontend.usersettings' not in cfg.endpoints_excluded -%}
                     <span class="sep"> | </span>

MoinMoin/templates/usersettings.html

   {{ forms.render_errors(form) }}
   <dl>
     {{ forms.render_field(gen, form['name'], 'text') }}
-    {{ forms.render_field(gen, form['aliasname'], 'text') }}
+    {{ forms.render_field(gen, form['display_name'], 'text') }}
     {{ forms.render_field(gen, form['openid'], 'url') }}
     {{ forms.render_select(gen, form['timezone']) }}
     {{ forms.render_select(gen, form['locale']) }}

MoinMoin/themes/__init__.py

         Assemble arguments used to build user homepage link
 
         :rtype: tuple
-        :returns: arguments of user homepage link in tuple (wiki_href, aliasname, title, exists)
+        :returns: arguments of user homepage link in tuple (wiki_href, display_name, title, exists)
         """
         user = self.user
         name = user.name
-        aliasname = user.aliasname
-        if not aliasname:
-            aliasname = name
-
+        display_name = user.display_name or name
         wikiname, itemname = getInterwikiHome(name)
-        title = "{0} @ {1}".format(aliasname, wikiname)
+        title = "{0} @ {1}".format(display_name, wikiname)
         # link to (interwiki) user homepage
         if is_local_wiki(wikiname):
             exists = self.storage.has_item(itemname)
             # We cannot check if wiki pages exists in remote wikis
             exists = True
         wiki_href = url_for_item(itemname, wiki_name=wikiname)
-        return wiki_href, aliasname, title, exists
+        return wiki_href, display_name, title, exists
 
     def split_navilink(self, text):
         """
         u = user.User(userid)
         name = u.name
         text = name
-        aliasname = u.aliasname
-        if not aliasname:
-            aliasname = name
+        display_name = u.display_name or name
         if title:
             # we already have some address info
-            title = "{0} @ {1}".format(aliasname, title)
+            title = "{0} @ {1}".format(display_name, title)
         else:
-            title = aliasname
+            title = display_name
         if u.mailto_author and u.email:
             email = u.email
             css = 'editor mail'