Posted by eXt |
|
You mean something like:
def get_fullusername(value): """ returns the full username of the given user - if defined (No HTML, just text) """ if not value: return _(u"Anonymous") profile = value.communityuserprofile_set.all() if profile and profile0.displayname: return profile0.displayname if (not value.first_name or not value.last_name) or\ get_sph_setting( 'community_displayname_filled_with_username' ) == True: return value.username return "%s %s" % (value.first_name, value.last_name) The setting 'community_displayname_filled_with_username' == True would cause the username to take precedence over the fullname (if there is no displayname). It is ok for me. But there is one more thing: _display_username.html template... |
|
Posted by Herbert Poul |
|
well .. kind of :)
i meant using a setting just for changing what is displayed (get_username, _display_username.html).. and never set an initial value for the 'display name'.. i think if the user clicks 'edit display' and hits 'save' without actually modifying anything .. nothing should change.. and currently it would save back the username (or whatever is configured) back into the profile which could change the output of the user's name .. do you see my problem ? Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by eXt |
|
Yes. I didn't write it above but I assumed that the initial value will be removed. The code snippet is an answer to you proposition - "changing what is displayed" instad of using initial formfield's value.
The problem is how to change the template. IMHO there should be a tag which will return the output from get_fullusername (in this situation get_fullusername should be called in a different way.. get_sph_username or something). So to summarize, I'm going to: 1. remove the initial value 2. change get_fullusername in a way I showed above 3. change the name of sph_setting (you can see it changed in the code above) 4. create a tag to return username and call it from _display_username template 5. ? change get_fullusername function name to get_sph_username What do you think? |
|
Posted by Herbert Poul |
|
i guess get_fullusername is generally a weird name .. i didn't come up with a better one though :( (since.. it's not actually the 'username' the method returns..)
maybe get_sph_displayname ? but yes.. it would make sense to put it into a template tag, so the code is only in one place... and we could make it consistent so _display_username.html does no longer display a '(username)' after the 'firstname lastname' ... i guess it is of no use any longer.. ad 2.) how about a more generic name for the setting.. like: community_displayname_default - beeing currently either 'fullname' (default) or 'username' --- or 'fallback' instead of 'default' or something similar .. it's not really that important :) Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by eXt |
|
I used 'get_sph_displayname' but at the moment I'm not sure if it was the best choice, because it is a displayname of what? Maybe something like get_userdisplayname would be better.
I made some changes in this area. I didn't remove _display_username.html (probally it should be renamed?). For details see the attached patch.
I used community_displayname_fallback (the same problem as above - displayname of what?). One more thing. I've changed names of some methods in the community package. It influences the board and other apps. I searched through the files in all the apps but as I don't use anything but board I can't verify whether wiki or blog is not broken after that. --- Ostatnio edytowane 2008-04-11 08:00:47 przez Jakub Wiśniowski --- |
|
Posted by Herbert Poul |
|
well .. i guess you are right .. how about get_user_displayname ?
keep the filename .. it is never referenced directly, just through the inclusion tag (afaik) .. so it's name shouldn't be a problem imo.
ok .. so . community_user_displayname_fallback ? :) (i hate naming .. i'm sure it can't be done right in the end anyway :) )
i would prefer to keep the old names .. something like: def get_user_displayname( .. ): ... return ... get_fullusername = get_user_displayname (i love python for this syntax :) ) this way we can be (quite) sure that nothing is broken afterwards :) Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by eXt |
|
Done
Done
Done
Done
I hope so :) The patch is attached. Let me know if I can commit it. |
|
Posted by Herbert Poul |
|
looks good to me :) Hey, we have Signatures !!! Great, isn't it ? ;) |
|
Posted by eXt |
|
Ok. It is now commited.
|
|
Posted by Herbert Poul |
|
great, seems to work perfectly .. this installation is now updated too :)
thanks :) Hey, we have Signatures !!! Great, isn't it ? ;) |