Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User display #118

Closed
wants to merge 7 commits into from
Closed

User display #118

wants to merge 7 commits into from

Conversation

Brontes
Copy link

@Brontes Brontes commented Apr 9, 2018

Thank you for contributing to django-machina! A list of simple rules is available on the online
documentation to help you contribute to this project: https://django-machina.readthedocs.org/en/stable/contributing.html.
Please review these guidelines before submitting your pull request!

This is pull request for issue #115 .
I included two new settings:

  • FORUM_USER_DISPLAY - here you can write template snippet, for showing users name.
    Examples: '{{ user.get_full_name }}' or '{{ user.get_full_name }}<br>({{ user.username }})'
    if setting isn't set, then it will show only username as before.
  • FORUM_SEARCH_REAL_USER_NAME - if set to true, then search indexer will include also first an last name of the user in function prepare_poster_name. Default is false.

Please let me know if this is OK with you.

Regards.

Copy link
Owner

@ellmetha ellmetha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work! That said I disagree with the general approach of this PR. I don't like the idea of putting template snippets into the Django settings (IMHO these things should be clearly separated).

Like I said in the issue, the best way to handle the problem here would probably be to add a setting like:

MACHINA_FORUM_USER_DISPLAY_NAME_METHOD = "get_full_name"

No need to rely on the Django template system just to customize displayed user names.

@@ -35,7 +36,10 @@ def get_model(self):
return Post

def prepare_poster_name(self, obj):
return obj.poster.username if obj.poster else obj.username
return (obj.poster.username + ((' ' + obj.poster.first_name + ' ' + obj.poster.last_name)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make the assumption that the first_name/ last_name fields will always be available on the user instance here? If a custom User model is used without these fields defined this code wouldn't work at all.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We added templates because the user object doesn't really have that much customisability in it. With a template you can add anything you like as long as you make sure it's in the context.

As for the search, this one depends on a separate setting. So if somebody uses a custom user model, they might want to avoid setting this to True if they don't have the fields.

@grapo grapo mentioned this pull request Aug 23, 2018
@ellmetha
Copy link
Owner

ellmetha commented Dec 5, 2018

Fixed in 8d053ed. Closing this PR, thanks!

@ellmetha ellmetha closed this Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants