Sphene Community Tools

Community

Copyright © 2007 by Herbert Poul
You are not logged in.
Login
Register

Change Language:



AddThis Social Bookmark Button

A Django site.
Profile for eXt

Name eXt
Email Address Reveal this emailaddress
AvatarUsers avatar
Posts42
Board Signature
moto-notes.com - a toolbox of useful applications that are somehow connected with automotive
  • Tongue
    Board >> General
    Hi!

    For information: I've just changed name of the emoticon which was misspelled: "tounge.gif" to "tongue.gif". So after svn up this: :-P should work.
    moto-notes.com - a toolbox of useful applications that are somehow connected with automotive
  • Re: Username instead of first and second name
    Board >> General >> Feature Discussions
    Ok. It is now commited.
    great, seems to work perfectly .. this installation is now updated too :)

    thanks :)

    Cool. One more thing - I've just commited a dynamic help_text for user displayname. It depends on the setting for fallback sequence. I've added updated polish translations too.
    moto-notes.com - a toolbox of useful applications that are somehow connected with automotive
  • Re: Username instead of first and second name
    Board >> General >> Feature Discussions
    The patch is attached. Let me know if I can commit it.
    looks good to me :)
    Ok. It is now commited.
    moto-notes.com - a toolbox of useful applications that are somehow connected with automotive
  • Re: Username instead of first and second name
    Board >> General >> Feature Discussions
    well .. i guess you are right .. how about get_user_displayname ?
    Done

    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.
    keep the filename .. it is never referenced directly, just through the inclusion tag (afaik) .. so it's name shouldn't be a problem imo.

    Done

    ok .. so . community_user_displayname_fallback ? :)
    (i hate naming .. i'm sure it can't be done right in the end anyway :) )

    Done

    i would prefer to keep the old names .. something like:

    def get_user_displayname( .. ):
        ...
        return ...
    
    get_fullusername = get_user_displayname
    


    Done

    (i love python for this syntax :) )


    this way we can be (quite) sure that nothing is broken afterwards :)

    I hope so :)


    The patch is attached. Let me know if I can commit it.
    moto-notes.com - a toolbox of useful applications that are somehow connected with automotive
  • Re: Username instead of first and second name
    Board >> General >> Feature Discussions
    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 ?
    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.

    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..

    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.

    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 :)

    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 ---
    moto-notes.com - a toolbox of useful applications that are somehow connected with automotive
  • Re: Username instead of first and second name
    Board >> General >> Feature Discussions
    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 ?
    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?
    moto-notes.com - a toolbox of useful applications that are somehow connected with automotive
  • Re: Username instead of first and second name
    Board >> General >> Feature Discussions
    one small problem/misunderstanding i didn't catch earlier.. wouldn't it be better to have a setting (community_displayname_filled_with_username_or_fullname) to affect only the fallback, instead of the initial value of the profile form ?

    (if the user wants the default behavior there is no need to store the username or first/last name as display name) - what do you think about moving this check right into the get_fullusername() method ?
    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...
    moto-notes.com - a toolbox of useful applications that are somehow connected with automotive
  • Re: Username instead of first and second name
    Board >> General >> Feature Discussions
    i have looked through the patch .. seems fine :) please commit it, and i'll try it out on this server ;)

    thanks,
    herbert
    Commited.
    moto-notes.com - a toolbox of useful applications that are somehow connected with automotive
  • Re: Username instead of first and second name
    Board >> General >> Feature Discussions
    looks very good.. :)
    just one thing ... do you know of the changelog attribute ? it's a SCT specific "feature" to the model so that on 'syncdb' new columns would get added..
    Thats really cool and useful feature. Something like django-evolution. In fact I've experienced existence of this feature some time ago but I didn't know that this is SCT specific thing and that changelog attribute is resposible for that.

    the CommunityUserProfile already has a changelog attribute.. so simply add something like:

      ( '2008-04-10 00', 'alter', 'ADD displayname varchar(250)' ),
      ( '2008-04-10 01', 'update', "SET displayname = ''" ),
      ( '2008-04-10 02', 'alter', 'ALTER displayname SET NOT NULL' ),
    


    this way everyone updating from SVN and running syncdb would see the changes .. and postgresql users get updated automatically :)

    I've added the lines from above to CommunityUserProfile changelog. So if you'll give me a green light I'll commit the changes to the trunk. The "final" patch is attached.
    moto-notes.com - a toolbox of useful applications that are somehow connected with automotive
  • Re: Username instead of first and second name
    Board >> General >> Feature Discussions
    Ok. Here is a complete patch that has all the functionality we were talking about. I won't commit that unless you verify it.

    The cache cleaning code is now:
    def clear_posts_render_cache(instance):
        for group in Group.objects.all():
            allowed_categories = get_all_viewable_categories( group, instance.user )
            post_list = Post.objects.filter( category__id__in = allowed_categories,
                                             author = instance.user )
            for post in post_list:
                post.clear_render_cache()
    
    dispatcher.connect(clear_posts_render_cache,
                       sender = CommunityUserProfile,
                       signal = signals.post_save)
    


    everything works well for me.
    moto-notes.com - a toolbox of useful applications that are somehow connected with automotive


Powered by Sphene Community Tools