Sphene Community Tools

Community

Copyright © 2007-2018 by Herbert Poul

You are not logged in.
Login
Register

Change Language:



AddThis Social Bookmark Button

A Django site.

Powered by Sphene Community Tools
Board » General » Feature Discussions » Username instead of first and second name

Page: Previous 1 2 3 4 Next

yes, i guess there are some circular dependencies.. you gut put the import statement directly into the get_displayname_default function .. and not in module-level .. not nice, but a bit better than having the method in sphutils and models.
Oh yes. You're right I'll do it this way.

2. Caching issue. After you change displayusername in profile it is still read from cache in some places. I'm not sure how cache is used in SPH so any pointers will be helpful.
i guess you mean the authorinfo in the forum which is not updated ?

No. I mean the form which is shown right after the profile is saved. It is a list of last posts of a user. Hmm.. I digged to
post.body_escaped
function which sets cache. Is there any easy way to clear that cache?

3. I have created SPH_SETTING parameter called: 'community_displayname_filled_with_username_or_fullname'. It can be set to 'username', 'fullname' or None (or anything which is neither username nor fullname). Any other preferences for that?
i think that's perfect for now .. could you please add the allowed values in the comments to the option in sphsettings.py ?

Sure. I'll add the comments.
No. I mean the form which is shown right after the profile is saved. It is a list of last posts of a user. Hmm.. I digged to
post.body_escaped
function which sets cache. Is there any easy way to clear that cache?
Answering myself. I've written a quick cache cleaner to by put into sphboard_extras:

def clear_posts_render_cache(instance):
    allowed_categories = get_all_viewable_categories( instance.group, instance.user )
    post_list = Post.objects.filter( category__id__in = allowed_categories,
                                     author = instance.user )
    for post in post_list:
        cache.delete( post.__get_render_cachekey() )

dispatcher.connect(clear_posts_render_cache,
                   sender = CommunityUserProfile,
                   signal = signals.post_save)


Looks that it works.
    for post in post_list:
        cache.delete( post.__get_render_cachekey() )
Looks that it works.
looks nice .. maybe we could put the actual cache.delete(..) call into a method like clear_render_cache() of the Post method - because __get_render_cachekey() is actually meant as a "private" method .. in addition this method could be also used in the Post.save() method .. (i guess you have the cache.delete call from there?)
Hey, we have Signatures !!! Great, isn't it ? ;)
looks nice .. maybe we could put the actual cache.delete(..) call into a method like clear_render_cache() of the Post method - because __get_render_cachekey() is actually meant as a "private" method .. in addition this method could be also used in the Post.save() method .. (i guess you have the cache.delete call from there?)
Yes I know that this is private, but now I'm just hacking around to get something working. I have the cache delete call from CommunityUserProfile, because it changes the username (displayusername) which is displayed in the posts list. Just click my username to see my profile and the list I'm talking about.

A little problem I can see in the above code would be the "group" parameter which is not an attribute of CommunityUserProfile as I assumed.
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.
Attachments
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..

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


but other than that, the patch looks perfect :)
thanks
Hey, we have Signatures !!! Great, isn't it ? ;)
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.
Attachments
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.
i just needed a easy way to keep my server database in sync with my development on my notebook .. i haven't found a solution in django so i created this simple changelog script .. but i hope something comes out of the django model evolution branch :)


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.


i have looked through the patch .. seems fine :) please commit it, and i'll try it out on this server ;)

thanks,
herbert
Hey, we have Signatures !!! Great, isn't it ? ;)
i have looked through the patch .. seems fine :) please commit it, and i'll try it out on this server ;)

thanks,
herbert
Commited.
Commited.
thanks .. i've tried it now ..

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 ?
Hey, we have Signatures !!! Great, isn't it ? ;)

Page: Previous 1 2 3 4 Next

Please login to post a reply.



Powered by Sphene Community Tools