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 placeholder page for private accounts #1912

Merged
merged 8 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 4 additions & 4 deletions funnel/templates/profile_layout.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@
{% if profile.is_organization_profile %}
<a class="sub-navbar__item mui--text-subhead mui--text-dark mui--hidden-xs mui--hidden-sm {% if current_page == 'profile' %}sub-navbar__item--active{%- endif %}" href="{%- if current_page != 'profile' -%}{{ profile.url_for() }}{%- endif %}" data-cy-navbar="profile">{% trans %}Home{% endtrans %}</a>
<a class="sub-navbar__item mui--text-subhead mui--text-dark {% if current_page == 'admins' %}sub-navbar__item--active{%- endif %}" href="{%- if current_page != 'admins' -%}{{ profile.urls['members'] }}{%- endif %}" data-cy-navbar="admins">{% trans %}Admins{% endtrans %} <span class="sub-navbar__item__icon mui--pull-right">{{ faicon(icon='chevron-right', icon_size='subhead') }}</span></a>
{% else %}
<a class="sub-navbar__item mui--text-subhead mui--text-dark mui--hidden-xs mui--hidden-sm {% if current_page == 'profile' %}sub-navbar__item--active{%- endif %}" href="{{ profile.url_for() }}">{% trans %}Sessions{% endtrans %}</a>
<a class="sub-navbar__item mui--text-subhead mui--text-dark {% if current_page == 'projects' %}sub-navbar__item--active{%- endif %}" href="{{ profile.url_for('user_participated_projects') }}">{% trans %}Projects{% endtrans %}<span class="sub-navbar__item__icon mui--pull-right">{{ faicon(icon='chevron-right', icon_size='subhead') }}</span></a>
<a class="sub-navbar__item mui--text-subhead mui--text-dark {% if current_page == 'submissions' %}sub-navbar__item--active{%- endif %}" href="{{ profile.url_for('user_proposals') }}" data-cy="submissions">{% trans %}Submissions{% endtrans %}<span class="sub-navbar__item__icon mui--pull-right">{{ faicon(icon='chevron-right', icon_size='subhead') }}</span></a>
{% elif not profile.features.is_private() %}
<a class="sub-navbar__item mui--text-subhead mui--text-dark mui--hidden-xs mui--hidden-sm {% if current_page == 'profile' %}sub-navbar__item--active{%- endif %}" href="{{ profile.url_for() }}">{% trans %}Sessions{% endtrans %}</a>
<a class="sub-navbar__item mui--text-subhead mui--text-dark {% if current_page == 'projects' %}sub-navbar__item--active{%- endif %}" href="{{ profile.url_for('user_participated_projects') }}">{% trans %}Projects{% endtrans %}<span class="sub-navbar__item__icon mui--pull-right">{{ faicon(icon='chevron-right', icon_size='subhead') }}</span></a>
<a class="sub-navbar__item mui--text-subhead mui--text-dark {% if current_page == 'submissions' %}sub-navbar__item--active{%- endif %}" href="{{ profile.url_for('user_proposals') }}" data-cy="submissions">{% trans %}Submissions{% endtrans %}<span class="sub-navbar__item__icon mui--pull-right">{{ faicon(icon='chevron-right', icon_size='subhead') }}</span></a>
{% endif %}
</nav>
</div>
Expand Down
26 changes: 15 additions & 11 deletions funnel/templates/user_profile.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,22 @@
<div class="mui-container">
<div class="page-content">
{% block contentwrapper %}
<div class="grid projects-wrapper" id="tagged-sessions">
<div class="grid__col-xs-12">
{% if not tagged_sessions %}
<p class="mui-panel bg-accent">{% trans %}No tagged sessions yet{% endtrans %}</p>
{% endif %}
</div>
{% for session in tagged_sessions %}
<div class="grid__col-xs-12 grid__col-sm-6 grid__col-sm-4">
{{ video_thumbnail(session) }}
{% if profile.features.is_private() %}
<p class="mui-panel bg-accent">{% trans %}This is a private account{% endtrans %}</p>
{% else %}
<div class="grid projects-wrapper" id="tagged-sessions">
<div class="grid__col-xs-12">
{% if not tagged_sessions %}
<p class="mui-panel bg-accent">{% trans %}No tagged sessions yet{% endtrans %}</p>
{% endif %}
</div>
{% endfor %}
</div>
{% for session in tagged_sessions %}
<div class="grid__col-xs-12 grid__col-sm-6 grid__col-sm-4">
{{ video_thumbnail(session) }}
</div>
{% endfor %}
</div>
{% endif %}
{% endblock contentwrapper %}
</div>
</div>
Expand Down
30 changes: 18 additions & 12 deletions funnel/templates/user_profile_projects.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@

{% block contentwrapper %}
<div class="grid projects-wrapper" id="tagged-projects">
<div class="grid__col-xs-12">
{% if not participated_projects %}
<p class="mui-panel bg-accent">{% trans %}No participation yet{% endtrans %}</p>
{% endif %}
</div>
<ul class="mui-list--unstyled grid upcoming" role="list">
{% for project in participated_projects %}
<li class="grid__col-xs-12 grid__col-sm-6 grid__col-lg-4" role="listitem">
{{ projectcard(project, include_calendar=true, calendarwidget_compact=false) }}
</li>
{%- endfor -%}
</ul>
{% if profile.features.is_private() %}
<div class="grid__col-xs-12">
<p class="mui-panel bg-accent">{% trans %}This is a private account{% endtrans %}</p>
</div>
{% else %}
<div class="grid__col-xs-12">
{% if not participated_projects %}
<p class="mui-panel bg-accent">{% trans %}No participation yet{% endtrans %}</p>
{% endif %}
</div>
<ul class="mui-list--unstyled grid upcoming" role="list">
{% for project in participated_projects %}
<li class="grid__col-xs-12 grid__col-sm-6 grid__col-lg-4" role="listitem">
{{ projectcard(project, include_calendar=true, calendarwidget_compact=false) }}
</li>
{%- endfor -%}
</ul>
{% endif %}
</div>
{% endblock contentwrapper %}

Expand Down
10 changes: 7 additions & 3 deletions funnel/templates/user_profile_proposals.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
{% block contentwrapper %}
<div class="grid projects-wrapper" id="tagged-submissions">
<div class="grid__col-xs-12">
{% if submitted_proposals %}
{{ proposal_list(submitted_proposals) }}
{% if profile.features.is_private() %}
<p class="mui-panel bg-accent">{% trans %}This is a private account{% endtrans %}</p>
{% else %}
<p class="mui-panel bg-accent">{% trans %}No submissions{% endtrans %}</p>
{% if submitted_proposals %}
{{ proposal_list(submitted_proposals) }}
{% else %}
<p class="mui-panel bg-accent">{% trans %}No submissions{% endtrans %}</p>
{% endif %}
{% endif %}
</div>
</div>
Expand Down
12 changes: 9 additions & 3 deletions funnel/views/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ def feature_profile_make_private(obj: Account):
return obj.current_roles.admin and obj.make_profile_private.is_available


@Account.features('is_private')
def feature_profile_is_private(obj: Account):
return (
obj.is_user_profile
vidya-ram marked this conversation as resolved.
Show resolved Hide resolved
and not obj.current_roles.admin
and not bool(obj.profile_state.ACTIVE_AND_PUBLIC)
vidya-ram marked this conversation as resolved.
Show resolved Hide resolved
)


def template_switcher(templateargs):
template = templateargs.pop('template')
return render_template(template, **templateargs)
Expand All @@ -72,7 +81,6 @@ def template_switcher(templateargs):
class ProfileView(AccountViewMixin, UrlChangeCheck, UrlForView, ModelView):
@route('', endpoint='profile')
@render_with({'text/html': template_switcher}, json=True)
@requires_roles({'reader', 'admin'})
def view(self) -> ReturnRenderWith:
template_name = None
ctx = {}
Expand Down Expand Up @@ -243,7 +251,6 @@ def view(self) -> ReturnRenderWith:

@route('in/projects')
@render_with('user_profile_projects.html.jinja2', json=True)
@requires_roles({'reader', 'admin'})
def user_participated_projects(self) -> ReturnRenderWith:
if self.obj.is_organization_profile:
abort(404)
Expand All @@ -263,7 +270,6 @@ def user_participated_projects(self) -> ReturnRenderWith:
@route('in/submissions')
@route('in/proposals') # Legacy route, will be auto-redirected to `in/submissions`
@render_with('user_profile_proposals.html.jinja2', json=True)
@requires_roles({'reader', 'admin'})
def user_proposals(self) -> ReturnRenderWith:
if self.obj.is_organization_profile:
abort(404)
Expand Down
Loading