Skip to content

Commit

Permalink
To featured cards on the homepage, add link to membership section of …
Browse files Browse the repository at this point in the history
…account (#1957)

* Show explore membership button on homepage

* add read access to `membership_project` property

* Change button colour and link membership section
  • Loading branch information
vidya-ram committed Jan 23, 2024
1 parent 63f1940 commit f9da28e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion funnel/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ def published_project_count(self) -> int:
self.listed_projects.filter(Project.state.PUBLISHED).order_by(None).count()
)

@with_roles(grants_via={None: {'participant': 'member'}})
@with_roles(read={'all'}, grants_via={None: {'participant': 'member'}})
@cached_property
def membership_project(self) -> Project | None:
"""Return a project that has memberships flag enabled (temporary)."""
Expand Down
24 changes: 14 additions & 10 deletions funnel/templates/macros.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
</footer>
{% endmacro %}

{% macro video_thumbnail(session, project_heading=false) %}
{% macro video_thumbnail(session) %}
<div class="video">
<a class="video__thumbnail {%- if not (session.views.video.thumbnail or session.banner_image_url.url) %} video__thumnail--novideo {%- endif %}" href="{%- if session.proposal %}{{ session.proposal.url_for() }}{%- else %}{{ session.url_for() }}{%- endif %}" data-ga="view session video">
{%- if session.views.video.thumbnail %}
Expand All @@ -229,9 +229,6 @@
<img src="{{ session.banner_image_url }}" class="video__thumbnail__img img-responsive" data-cy="thumbnail" alt="{{ session.title }}"/>
{%- endif %}
</a>
{%- if project_heading %}
<p class="mui--text-title text-bold video__txt" data-cy="project-title">{{ session.project.title }}</p>
{%- endif %}
<p class="mui--text-subhead text-bold video__txt" data-cy="title">{{ session.title }}</p>
{%- if session.speaker %}<p class="mui--text-body2 mui--text-light video__txt">{{ session.speaker }}</p>{%- endif %}
{%- if session.views.video %}
Expand Down Expand Up @@ -465,13 +462,20 @@
{%- if snippet_html %}
<p class="mui--text-body2 mui--text-light zero-top-margin search-snippets">{{ faicon(icon='search', css_class="search-icon", baseline=false) }} {{ snippet_html }}</p>
{% endif %}
{%- if is_member %}
<div class="mui--text-dark mui--text-subhead text-bold nounderline margin-auto"><span class="chip chip--bg-success text-bold">{{ faicon(icon='crown-solid', baseline=true, css_class="mui--text-success fa-icon--right-margin") }}{% trans %}Member{% endtrans %}</span></div>
{%- if account.membership_project and not is_member %}
<div class="profile-card__btn-wrapper">
<p class=" mui--text-center mui--text-caption mui--text-light top-padding margin-bottom">{% trans tcount=account.published_project_count, count=account.published_project_count|numberformat %}One project{% pluralize tcount %}{{ count }} projects{% endtrans %}</p>
<a class="mui-btn mui-btn--primary mui-btn--raised full-width-btn" href="{{ account.url_for(_anchor='membership') }}" data-ga="Become a member(homepage)">{% trans %}Become a member{% endtrans %}</a>
</div>
{% else %}
{%- if is_member %}
<div class="mui--text-dark mui--text-subhead text-bold nounderline margin-auto"><span class="chip chip--bg-success text-bold">{{ faicon(icon='crown-solid', baseline=true, css_class="mui--text-success fa-icon--right-margin") }}{% trans %}Member{% endtrans %}</span></div>
{% endif %}
<div class="profile-card__btn-wrapper">
<p class=" mui--text-center mui--text-caption mui--text-light top-padding margin-bottom">{% trans tcount=account.published_project_count, count=account.published_project_count|numberformat %}One project{% pluralize tcount %}{{ count }} projects{% endtrans %}</p>
<a class="mui-btn mui-btn--dark mui-btn--raised full-width-btn" href="{{ account.url_for() }} ">{% trans %}Explore{% endtrans %}</a>
</div>
{% endif %}
<div class="profile-card__btn-wrapper">
<p class=" mui--text-center mui--text-caption mui--text-light top-padding margin-bottom">{% trans tcount=account.published_project_count, count=account.published_project_count|numberformat %}One project{% pluralize tcount %}{{ count }} projects{% endtrans %}</p>
<a class="mui-btn mui-btn--primary mui-btn--raised full-width-btn" href="{{ account.url_for() }} ">{% trans %}Explore{% endtrans %}</a>
</div>
</div>
</div>
{% endmacro %}
2 changes: 1 addition & 1 deletion funnel/templates/past_sessions_section.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% for session in past_sessions %}
<li class="grid__col-12 grid__col-xs-12 grid__col-sm-6 grid__col-lg-4" role="listitem">
{{ video_thumbnail(session, project_heading=true) }}
{{ video_thumbnail(session) }}
</li>
{%- else -%}
<p class="mui--text-subhead mui--text-light margin-top left-padding">{% trans %}No past videos{% endtrans %}</p>
Expand Down

0 comments on commit f9da28e

Please sign in to comment.