Modify

Opened 4 years ago

Last modified 3 years ago

#7594 new enhancement

[Patch] Populate username fields using session info

Reported by: rjollos Owned by: osimons
Priority: normal Component: FullBlogPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

When a user has a valid session (created by entering name and email in the preferences panel), the ticket's reporter field is populated with the user's name and email in the format: name <email>.

It would be nice if the same functionality existed for populating the blog post's Post Author field, and the blog comment's Your email or username: field. The latter is probably of more practical use because anonymous comments are probably commonly allowed, but I imagine a blog post typically requires an account.

That might bring up another feature to implement (assuming this can't be done already) ... an option to only allow comments when a user has a valid session key. This is done, for example, with the VotePlugin.

Attachments (1)

0001-Display-author-name-instead-of-account-name.patch.zip (4.8 KB) - added by olaf.meeuwissen@… 3 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 3 years ago by olaf.meeuwissen@…

+1

We're using account info from our Active Directory (AD) server and the account names (sids in the session table) are pretty unintelligible: two letters and a bunch of digits. So there's no telling who AC1234567 really is unless you've memorized all 400 of them ;-)

We do have the AD display names in the name field of the session attribute table so if those could be displayed that would go a long way to figuring out who AC1234567 actually is.

comment:2 Changed 3 years ago by olaf.meeuwissen@…

  • Summary changed from Populate username fields using session info to [Patch] Populate username fields using session info

A colleague and me hacked up a patch that does this. Works fine for us.

Changed 3 years ago by olaf.meeuwissen@…

comment:3 Changed 3 years ago by olaf.meeuwissen@…

Sorry, I had to zip the patch to work around the spam prevention measures. They don't like HTML ... :-(

comment:4 Changed 3 years ago by anonymous

Eh, there's a little issue still. The author name is not used when creating a new post and previewing a new post or comment.

comment:5 Changed 3 years ago by osimons

Thanks for the patch. It is somewhat more elaborate than what I had expected... I had just imagined a small lookup at the template level, with minor changes going from this:

req.authname

to

req.session.get('name') or req.authname

It should be no more than a few instances of this in the fullblog_edit.html template, and then whatever is entered there stays with the post anyway - regardless of where it is initially fetched.

comment:6 Changed 3 years ago by osimons

(And same treatment to the relevant part in fullblog_view.html where adding comments of course).

So the patch would just look like this to make it somewhat similar to the treatment of usernames in Ticket system:

  • 0.11/tracfullblog/templates/fullblog_edit.html

    a b  
    9292                <label for="blog-author">Post Author:</label><br /> 
    9393                <input id="blog-author" type="text"  
    9494                      name="author" size="40" 
    95                       value="${defined('blog_edit') and blog_edit.author or req.authname}" /> 
     95                      value="${(defined('blog_edit') and blog_edit.author) 
     96                               or (req.session.get('name') or req.authname)}" /> 
    9697              </div> 
    9798              <div class="field"> 
    9899                <label for="blog-categories">Categories (space separated):</label><br /> 
  • 0.11/tracfullblog/templates/fullblog_view.html

    a b  
    113113                      <br /> 
    114114                      <input id="author" type="text"  
    115115                          name="author" size="30" 
    116                           value="${defined('blog_comment') and blog_comment.author or req.authname}" /> 
     116                          value="${(defined('blog_comment') and blog_comment.author) 
     117                                   or (req.session.get('name') or req.authname)}" /> 
    117118                  </div> 
    118119                </py:if> 
    119120                <div class="buttons"> 

For commenting, I could even consider dropping the check for anonymous so that the comment author field is always displayed. Then the same logic would be used and made visible to the author - and even allowing changing if so desired.

Then I may even consider this logic for name suggestion:

req.session.get('name') or req.session.get('email') or req.authname

comment:7 Changed 3 years ago by olaf.meeuwissen@…

Blame the size of the changes on our sorely missing Trac knowledge.

Would your suggestion also work for existing posts and comments? Ours does, BTW. FWIW, ours also lets people retro-actively change their "real" name ;-)

comment:8 Changed 3 years ago by osimons

No, like all the other modules in Trac it will not link to some user dimension that in effect can change history. What is entered stays as-is for posts and comments - just like they do in wiki and ticket and other modules/plugins in Trac.

So, I won't be adding a user dimension - at least as long as no such dimension & API exists in Trac itself.

comment:9 Changed 3 years ago by olaf.meeuwissen@…

OK, I see but I've also come to realize that what we wanted is subtly different from the original #description. We want to use the FullBlogPlugin for a low-barrier blog site in a medium sized company (about 400 people). User account data (account name, display name and email address) come from an Active Directory server and cannot be modified by the user. Posts and comments require the user to be authenticated.

In this setup, entering any of the author info is unnecessary. We have even disabled the input field for that, IIRC. We want to submit the blog posts by account name (req.authname) to avoid the possibility of attributing posts to the wrong person in the not that unlikely case we have people with the same display name.

In that situation, you end up with a patch like the one we attached because it only changes the MVC View part. Your suggested changes would modify the MVC Controller part and would leave one guessing at the interpretation of when ended up in the database). Depending on one's goal, either approach has its pros and cons, I guess.

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.