diff --git a/funnel/templates/account_menu.html.jinja2 b/funnel/templates/account_menu.html.jinja2 index fcaf35c39..039d88321 100644 --- a/funnel/templates/account_menu.html.jinja2 +++ b/funnel/templates/account_menu.html.jinja2 @@ -27,13 +27,32 @@ class="header__dropdown__item header__dropdown__item--flex mui--text-dark nounderline mui--text-subhead mui--text-light">{{ faicon(icon='plus', icon_size='title', baseline=false, css_class="mui--text-light") }}{% trans %}Add username{% endtrans %} {%- endif %} - {%- with orgmemlist = current_auth.user.views.recent_organization_memberships() %} - {%- if orgmemlist.recent|length -%} +
  • + {{ faicon(icon='sitemap', icon_size='title', baseline=false, css_class="mui--text-light") }}{% trans %}Organizations{% endtrans %} +
  • + {%- with orglist = current_auth.user.views.organizations_as_member %} + {%- for org in orglist %}
  • - {{ faicon(icon='sitemap', icon_size='title', baseline=false, css_class="mui--text-light") }}{% trans %}Organizations{% endtrans %} + + + {%- if org.logo_url.url %} + {{ org.title }} + {% else %} + {{ org.title }} + {% endif %} + + {{ org.title }}{{ faicon(icon='crown-solid', baseline=true, icon_size='body2', css_class="mui--text-success fa-icon--right-margin") }}{% trans %}Member{% endtrans %} +
  • + {%- endfor %} + {%- endwith %} + {%- with orgmemlist = current_auth.user.views.recent_organization_memberships() %} + {%- if orgmemlist.recent|length -%} {%- for orgmem in orgmemlist.recent %}
  • {{ faicon(icon='bell', icon_size='subhead', baseline=false, css_class="mui--text-light") }}{% trans %}Notification settings{% endtrans %}
  • - {%- if not orgmemlist.recent|length -%} -
  • - {{ faicon(icon='sitemap', icon_size='subhead', baseline=false, css_class="mui--text-light") }}{% trans %}Organizations{% endtrans %} -
  • - {%- endif %} {%- endwith %}
  • {% for account in featured_accounts %}
  • - {{ profilecard(account) }} + {%- if account.current_roles.member %} + {{ profilecard(account, snippet_html=false, is_member=true) }} + {%- else %} + {{ profilecard(account) }} + {% endif %}
  • {%- endfor -%} diff --git a/funnel/templates/macros.html.jinja2 b/funnel/templates/macros.html.jinja2 index a2ef2faa6..4191a8af4 100644 --- a/funnel/templates/macros.html.jinja2 +++ b/funnel/templates/macros.html.jinja2 @@ -446,7 +446,7 @@ {%- endif %} {%- endmacro %} -{% macro profilecard(account, snippet_html) %} +{% macro profilecard(account, snippet_html, is_member) %}
    @@ -465,6 +465,9 @@ {%- if snippet_html %}

    {{ faicon(icon='search', css_class="search-icon", baseline=false) }} {{ snippet_html }}

    {% endif %} + {%- if is_member %} +
    {{ faicon(icon='crown-solid', baseline=true, css_class="mui--text-success fa-icon--right-margin") }}{% trans %}Member{% endtrans %}
    + {% endif %}

    {% trans tcount=account.published_project_count, count=account.published_project_count|numberformat %}One project{% pluralize tcount %}{{ count }} projects{% endtrans %}

    {% trans %}Explore{% endtrans %} diff --git a/funnel/templates/project_layout.html.jinja2 b/funnel/templates/project_layout.html.jinja2 index 3c7aedaec..b2992d663 100644 --- a/funnel/templates/project_layout.html.jinja2 +++ b/funnel/templates/project_layout.html.jinja2 @@ -51,7 +51,7 @@ {% macro project_header(project) %} {%- if project.livestream_urls %} - {% if (project.is_restricted_video and project.current_roles.participant) or not project.is_restricted_video %} + {% if (project.is_restricted_video and project.current_roles.account_member) or not project.is_restricted_video %}
    {% if project.livestream_urls|length >= 2 %}
      @@ -125,7 +125,7 @@ {% endif %} {{ project.account.title }} - {% if project.features.subscription and project.current_roles.participant %} + {% if project.features.subscription and project.current_roles.account_member %} {{ faicon(icon='crown-solid', baseline=true, css_class="mui--text-success fa-icon--right-margin") }}{% trans %}Member{% endtrans %} {% elif project.features.subscription %} {{ faicon(icon='lock-alt', baseline=true, css_class="fa-icon--right-margin") }}{% trans %}For members{% endtrans %} diff --git a/funnel/views/account.py b/funnel/views/account.py index a28a7f8bc..283534470 100644 --- a/funnel/views/account.py +++ b/funnel/views/account.py @@ -117,7 +117,7 @@ def organizations_as_admin( owner: bool = False, limit: int | None = None, order_by_grant: bool = False, -) -> list[RoleAccessProxy]: +) -> list[RoleAccessProxy[Account]]: """Return organizations that the user is an admin of.""" if owner: orgmems = obj.active_organization_owner_memberships @@ -139,7 +139,7 @@ def organizations_as_admin( @Account.views() def organizations_as_owner( obj: Account, limit: int | None = None, order_by_grant: bool = False -) -> list[RoleAccessProxy]: +) -> list[RoleAccessProxy[Account]]: """Return organizations that the user is an owner of.""" return obj.views.organizations_as_admin( owner=True, limit=limit, order_by_grant=order_by_grant @@ -173,6 +173,18 @@ def recent_organization_memberships( ) +@Account.views(cached_property=True) +def organizations_as_member(obj: Account) -> list[RoleAccessProxy[Account]]: + """Return organizations that the user has a membership in.""" + return [ + acc.access_for(actor=obj, datasets=('primary', 'related')) + for acc in Account.query.filter( + Account.name_in(app.config['FEATURED_ACCOUNTS']) + ).all() + if 'member' in acc.roles_for(obj) + ] + + @Account.views('avatar_color_code', cached_property=True) def avatar_color_code(obj: Account) -> int: """Return a colour code for the user's autogenerated avatar image.""" diff --git a/funnel/views/index.py b/funnel/views/index.py index 31d789c7f..070e6f3f3 100644 --- a/funnel/views/index.py +++ b/funnel/views/index.py @@ -151,7 +151,7 @@ def home(self) -> ReturnRenderWith: 'featured_project_sessions': scheduled_sessions_list, 'featured_project_schedule': featured_project_schedule, 'featured_accounts': [ - p.access_for(roles={'all'}, datasets=('primary', 'related')) + p.current_access(datasets=('primary', 'related')) for p in featured_accounts ], }