-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add view partials for repeated content on post or topic writer #221
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{% load forum_member_tags %} | ||
{% load i18n %} | ||
|
||
{% if is_search %} | ||
{% if item.poster %} | ||
{% url 'forum_member:profile' item.poster as poster_url %} | ||
{% blocktrans trimmed with username=item.poster_name creation_date=item.created %} | ||
By: <a href="{{ poster_url }}">{{ username }}</a> on {{ creation_date }} | ||
{% endblocktrans %} | ||
{% else %} | ||
{% blocktrans trimmed with poster_username=item.poster_name creation_date=item.created %} | ||
By: {{ poster_username }} on {{ creation_date }} | ||
{% endblocktrans %} | ||
{% endif %} | ||
{% else %} | ||
Comment on lines
+4
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fact that we need to pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi I had a second look at it, IMO, we should pass through as we did before (before the fixup), the username, the creation date and poster now that we have 3 cases : topics, posts and search, this way the partial will be generic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can try! Though I think the resulting partial should be as simple as possible and not contain too much logic. |
||
{% if item.poster %} | ||
{% url 'forum_member:profile' item.poster_id as profil_url %} | ||
{% if show_by_prefix %} | ||
<a href="{{profil_url }}">{% if highlight_username %}<b>{% endif %}{{ item.poster|forum_member_display_name }}{% if highlight_username %}</b>{% endif %}</a> | ||
{% else %} | ||
{% if show_creation_date %} | ||
{% blocktrans trimmed with username=item.poster|forum_member_display_name creation_date=item.created %} | ||
By: <a href="{{ profil_url }}">{{ username }}</a> on {{ creation_date }} | ||
{% endblocktrans %} | ||
{% else %} | ||
{% blocktrans trimmed with username=item.poster|forum_member_display_name %} | ||
By: <a href="{{ profil_url }}">{{ username }}</a> | ||
{% endblocktrans %} | ||
{% endif %} | ||
{% endif %} | ||
{% else %} | ||
{% if show_by_prefix %} | ||
{% if highlight_username %}<b>{% endif %}{{ username }}{% if highlight_username %}</b>{% endif %} | ||
{% else %} | ||
{% if show_creation_date %} | ||
{% if is_topic %} | ||
{% blocktrans trimmed with username=topic.first_post.username creation_date=item.created %} | ||
By: {{ username }} on {{ creation_date }} | ||
{% endblocktrans %} | ||
{% else %} | ||
{% blocktrans trimmed with username=item.username creation_date=item.created %} | ||
By: {{ username }} on {{ creation_date }} | ||
{% endblocktrans %} | ||
{% endif %} | ||
{% else %} | ||
{% if is_topic %} | ||
{% blocktrans trimmed with username=topic.first_post.username %} | ||
By: {{ username }} | ||
{% endblocktrans %} | ||
{% else %} | ||
{% blocktrans trimmed with username=item.username %} | ||
By: {{ username }} | ||
{% endblocktrans %} | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could probably improve how this partial works so that it - kindof - keep working like things were working previously.
For example why not:
post
variable ortopic
variable (depending on whether you want to display the poster info for the post or the topic itself) - this would allow to avoid passingposter
,username
andcreation_date
systematically in each partial use (which would be less error prone in my opinion)show_creation_date
variable (True / False)no_trans
would be replaced by something more explicit likeshow_by_prefix
username_highlighted
would be replaced byhighlight_username
(True / False) to improve consistencyWhat do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, definitely, I think it's way simpler this way. I'll work around it and suggest it as a fix.
thank you for you feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've commited with a fixup, I had forgotten to add a file with the search in the previous commit which was another case.
I don't know what to think of this new version. I had to make more cases to be able to read username as it is not specified anymore.
Tell me please what you think of it.