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

show co-writers in answer cards #36

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions wagtail_helpdesk/cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,21 @@ def get_card_data(self):
"answers_page_url": self.get_parent().url if self.get_parent() else "",
}

def get_answer_card_data(self):
return {
"title": self.title,
"url": self.url,
"authors": self.experts,
"categories": self.get_all_categories(),
"type": "answer",
"answers_page_url": self.get_parent().url if self.get_parent() else "",
}

def get_as_overview_row_card(self):
if self.type == "answer":
return render_to_string(
"wagtail_helpdesk/core/includes/answer_block.html",
context=self.get_card_data(),
context=self.get_answer_card_data(),
)
else: # It's a column
return render_to_string(
Expand All @@ -377,7 +387,7 @@ def get_as_overview_row_card(self):
def get_as_home_row_card(self):
return render_to_string(
"wagtail_helpdesk/core/includes/answer_home_block.html",
context=self.get_card_data(),
context=self.get_answer_card_data(),
)

def get_as_related_row_card(self):
Expand Down
18 changes: 14 additions & 4 deletions wagtail_helpdesk/static_src/components/structures/_menu-bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
.menu-bar__logo-container {
align-self: center;
width: 33%;
flex-shrink: 0;
}

.menu-bar__logo {
Expand All @@ -28,7 +29,11 @@
.menu-bar__expert-container {
align-self: center;
text-align: center;
justify-content: center;
width: 33%;
display: flex;
flex-shrink: 0;
gap: 10px;
}

.menu-bar__expert-link {
Expand All @@ -38,20 +43,19 @@
.menu-bar__image {
height: 38px;
border-radius: 50%;
aspect-ratio: 1/1;
}

.menu-bar__expert-name {
display: none;
@include typography(navigation);
margin-left: 20px;
font-weight: 600;
vertical-align: super;
}

.menu-bar__expert-title {
display: none;
@include typography(navigation);
margin-left: 20px;
vertical-align: super;
}

Expand All @@ -60,6 +64,7 @@
width: 33%;
text-align: right;
margin-left: auto;
flex-shrink: 0;
}

.menu-bar__icon-button {
Expand All @@ -69,7 +74,7 @@
}

.menu-bar__icon {
background-image: url('../icons/menu.svg');
background-image: url("../icons/menu.svg");
background-position: center;
background-repeat: no-repeat;
background-size: 100%;
Expand Down Expand Up @@ -97,9 +102,14 @@
margin-left: 30px;
}

.menu-bar__image {
margin: 0;
}

.menu-bar__expert-container {
width: auto;
margin-left: 50px;
gap: 20px;
}

.menu-bar__expert-name {
Expand Down Expand Up @@ -133,6 +143,6 @@
}

.menu-bar__icon {
background-image: url('../icons/menu-white.svg');
background-image: url("../icons/menu-white.svg");
}
}
17 changes: 10 additions & 7 deletions wagtail_helpdesk/templates/wagtail_helpdesk/cms/answer_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,17 @@
</div>

<div class="menu-bar__expert-container">
{% with self.get_primary_expert as expert %}
<a class="menu-bar__expert-link" href="/experts#{{ expert.pk }}">
{% image expert.picture fill-200x200 as image %}
<img class="menu-bar__image" src="{{ image.url }}" alt="{{ image.alt }}">
<span class="menu-bar__expert-name">{{ expert.name }}</span>
<span class="menu-bar__expert-title">{{ expert.affiliation }}</span>
{% for expert in self.experts %}
<a class="menu-bar__expert-link" href="/experts#{{ expert.pk }}">
{% image expert.picture fill-200x200 as image %}
<img class="menu-bar__image" src="{{ image.url }}" alt="{{ image.alt }}">
<span class="menu-bar__expert-name">{{ expert.name }}</span>
{% if self.experts|length == 1 %}
<span class="menu-bar__expert-title">{{ expert.affiliation }}</span>
{% endif %}
</a>
{% endwith %}

{% endfor %}
</div>

<div class="menu-bar__icon-container">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{% load i18n %}
<div class="question-link">
<a href="{{ url }}"><h3 class="question-link__title">{{ title }}</h3></a>
<p class="question-link__author"> <span class="question-link__by">{% trans 'Answered by' %}</span> <span class="question-link__author-name">{{ author }}</span> </p>
<p class="question-link__author"><span class="question-link__by">{% trans 'Answered by' %}</span>
{% for author in authors %}
<span class="question-link__author-name">
{% if forloop.last and not forloop.first %}
& {{ author }}
{% elif forloop.revcounter != 2 and not forloop.last %}
{{ author }},
{% else %}
{{ author }}
{% endif %}
</span>
{% endfor %}
</p>
{% for category in categories %}
<a href="{{ category.url }}"><span class="tag">{{ category.title }}</span></a>
<a href="{{ category.url }}"><span class="tag">{{ category.title }}</span></a>
{% endfor %}
</div>
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
{% load i18n wagtailcore_tags wagtailroutablepage_tags %}
{% with object.get_card_data as card_data %}
{% with object.get_answer_card_data as card_data %}
<div class="question-link">
<a href="{% pageurl object %}"><h3 class="question-link__title">{{ card_data.title }}</h3></a>
<p class="question-link__author">
<span class="question-link__by">{% trans 'Answered by' %}</span>
{% if card_data.author and card_data.author.pk %}
<a href="{% routablepageurl expert_answers_overview_page "expert_answers" card_data.author.pk %}" class="question-link__author-name">{{ card_data.author }}</a>
{% if card_data.authors %}
{% for author in card_data.authors %}
{% if forloop.last and not forloop.first %}
& <a href="{% routablepageurl expert_answers_overview_page "expert_answers" author.pk %}" class="question-link__author-name">{{ author }}</a>
{% elif forloop.revcounter != 2 and not forloop.last %}
<a href="{% routablepageurl expert_answers_overview_page "expert_answers" author.pk %}" class="question-link__author-name">{{ author }}</a>,
{% else %}
<a href="{% routablepageurl expert_answers_overview_page "expert_answers" author.pk %}" class="question-link__author-name">{{ author }}</a>
{% endif %}
{% endfor %}
{% else %}
<span class="question-link__author-name">{% trans "Unknown" %}</span>
{% endif %}
Expand Down
Loading