From b4c5cfa4dd6c735e438f0e27f7a3437617b12867 Mon Sep 17 00:00:00 2001 From: Vidya Ramakrishnan Date: Thu, 26 Oct 2023 19:12:07 +0530 Subject: [PATCH 1/6] For private profile show just the header --- funnel/templates/profile_layout.html.jinja2 | 8 ++--- funnel/templates/user_profile.html.jinja2 | 26 +++++++++------- .../user_profile_projects.html.jinja2 | 30 +++++++++++-------- .../user_profile_proposals.html.jinja2 | 10 +++++-- funnel/views/profile.py | 10 +++++++ 5 files changed, 54 insertions(+), 30 deletions(-) diff --git a/funnel/templates/profile_layout.html.jinja2 b/funnel/templates/profile_layout.html.jinja2 index 0a7a9a1a7..01c2e51cf 100644 --- a/funnel/templates/profile_layout.html.jinja2 +++ b/funnel/templates/profile_layout.html.jinja2 @@ -426,10 +426,10 @@ {% if profile.is_organization_profile %} {% trans %}Home{% endtrans %} {% trans %}Admins{% endtrans %} {{ faicon(icon='chevron-right', icon_size='subhead') }} - {% else %} - {% trans %}Sessions{% endtrans %} - {% trans %}Projects{% endtrans %}{{ faicon(icon='chevron-right', icon_size='subhead') }} - {% trans %}Submissions{% endtrans %}{{ faicon(icon='chevron-right', icon_size='subhead') }} + {% elif not profile.features.is_private() %} + {% trans %}Sessions{% endtrans %} + {% trans %}Projects{% endtrans %}{{ faicon(icon='chevron-right', icon_size='subhead') }} + {% trans %}Submissions{% endtrans %}{{ faicon(icon='chevron-right', icon_size='subhead') }} {% endif %} diff --git a/funnel/templates/user_profile.html.jinja2 b/funnel/templates/user_profile.html.jinja2 index 8e8fd02e6..cbe8c5929 100644 --- a/funnel/templates/user_profile.html.jinja2 +++ b/funnel/templates/user_profile.html.jinja2 @@ -35,18 +35,22 @@
{% block contentwrapper %} -
-
- {% if not tagged_sessions %} -

{% trans %}No tagged sessions yet{% endtrans %}

- {% endif %} -
- {% for session in tagged_sessions %} -
- {{ video_thumbnail(session) }} + {% if profile.features.is_private() %} +

{% trans %}This is a private account{% endtrans %}

+ {% else %} +
+
+ {% if not tagged_sessions %} +

{% trans %}No tagged sessions yet{% endtrans %}

+ {% endif %}
- {% endfor %} -
+ {% for session in tagged_sessions %} +
+ {{ video_thumbnail(session) }} +
+ {% endfor %} +
+ {% endif %} {% endblock contentwrapper %}
diff --git a/funnel/templates/user_profile_projects.html.jinja2 b/funnel/templates/user_profile_projects.html.jinja2 index feb9a523d..34578edd7 100644 --- a/funnel/templates/user_profile_projects.html.jinja2 +++ b/funnel/templates/user_profile_projects.html.jinja2 @@ -8,18 +8,24 @@ {% block contentwrapper %}
-
- {% if not participated_projects %} -

{% trans %}No participation yet{% endtrans %}

- {% endif %} -
-
    - {% for project in participated_projects %} -
  • - {{ projectcard(project, include_calendar=true, calendarwidget_compact=false) }} -
  • - {%- endfor -%} -
+ {% if profile.features.is_private() %} +
+

{% trans %}This is a private account{% endtrans %}

+
+ {% else %} +
+ {% if not participated_projects %} +

{% trans %}No participation yet{% endtrans %}

+ {% endif %} +
+
    + {% for project in participated_projects %} +
  • + {{ projectcard(project, include_calendar=true, calendarwidget_compact=false) }} +
  • + {%- endfor -%} +
+ {% endif %}
{% endblock contentwrapper %} diff --git a/funnel/templates/user_profile_proposals.html.jinja2 b/funnel/templates/user_profile_proposals.html.jinja2 index f2b376aae..a750825ac 100644 --- a/funnel/templates/user_profile_proposals.html.jinja2 +++ b/funnel/templates/user_profile_proposals.html.jinja2 @@ -9,10 +9,14 @@ {% block contentwrapper %}
- {% if submitted_proposals %} - {{ proposal_list(submitted_proposals) }} + {% if profile.features.is_private() %} +

{% trans %}This is a private account{% endtrans %}

{% else %} -

{% trans %}No submissions{% endtrans %}

+ {% if submitted_proposals %} + {{ proposal_list(submitted_proposals) }} + {% else %} +

{% trans %}No submissions{% endtrans %}

+ {% endif %} {% endif %}
diff --git a/funnel/views/profile.py b/funnel/views/profile.py index 02e75ba97..d93b8d8f0 100644 --- a/funnel/views/profile.py +++ b/funnel/views/profile.py @@ -62,6 +62,16 @@ 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): + print('obj.current_roles.admin', obj.current_roles.admin, bool(obj.profile_state.PRIVATE)) + return ( + obj.is_user_profile + and not obj.current_roles.admin + and not bool(obj.profile_state.ACTIVE_AND_PUBLIC) + ) + + def template_switcher(templateargs): template = templateargs.pop('template') return render_template(template, **templateargs) From 19808eb46abe9651583438890d0204a28aa91542 Mon Sep 17 00:00:00 2001 From: Vidya Ramakrishnan Date: Thu, 26 Oct 2023 19:12:56 +0530 Subject: [PATCH 2/6] Remove print statments --- funnel/views/profile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/funnel/views/profile.py b/funnel/views/profile.py index d93b8d8f0..ce91149ec 100644 --- a/funnel/views/profile.py +++ b/funnel/views/profile.py @@ -64,7 +64,6 @@ def feature_profile_make_private(obj: Account): @Account.features('is_private') def feature_profile_is_private(obj: Account): - print('obj.current_roles.admin', obj.current_roles.admin, bool(obj.profile_state.PRIVATE)) return ( obj.is_user_profile and not obj.current_roles.admin From 6167454c4cd7df3a164e104f47c4f7d9e5208fa2 Mon Sep 17 00:00:00 2001 From: Vidya Ramakrishnan Date: Fri, 27 Oct 2023 10:24:57 +0530 Subject: [PATCH 3/6] Remove role check --- funnel/views/profile.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/funnel/views/profile.py b/funnel/views/profile.py index ce91149ec..948b5a14f 100644 --- a/funnel/views/profile.py +++ b/funnel/views/profile.py @@ -81,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 = {} @@ -252,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) @@ -272,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) From 0fa812d35053c9cebac8622cbdc01d9f8cb1c3d2 Mon Sep 17 00:00:00 2001 From: Vidya Ramakrishnan Date: Mon, 6 Nov 2023 19:51:27 +0530 Subject: [PATCH 4/6] User profile check not required --- funnel/views/profile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/funnel/views/profile.py b/funnel/views/profile.py index 948b5a14f..633d2feff 100644 --- a/funnel/views/profile.py +++ b/funnel/views/profile.py @@ -65,8 +65,7 @@ def feature_profile_make_private(obj: Account): @Account.features('is_private') def feature_profile_is_private(obj: Account): return ( - obj.is_user_profile - and not obj.current_roles.admin + not obj.current_roles.admin and not bool(obj.profile_state.ACTIVE_AND_PUBLIC) ) From f9e9a4687c8278d38c7dae0983551c05e8f3780e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:26:42 +0000 Subject: [PATCH 5/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- funnel/views/profile.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/funnel/views/profile.py b/funnel/views/profile.py index 633d2feff..e042736ca 100644 --- a/funnel/views/profile.py +++ b/funnel/views/profile.py @@ -64,10 +64,7 @@ def feature_profile_make_private(obj: Account): @Account.features('is_private') def feature_profile_is_private(obj: Account): - return ( - not obj.current_roles.admin - and not bool(obj.profile_state.ACTIVE_AND_PUBLIC) - ) + return not obj.current_roles.admin and not bool(obj.profile_state.ACTIVE_AND_PUBLIC) def template_switcher(templateargs): From 616e261da72a3a2fe181feee8233bb9d33cc3de1 Mon Sep 17 00:00:00 2001 From: Vidya Ramakrishnan Date: Tue, 7 Nov 2023 10:59:21 +0530 Subject: [PATCH 6/6] Fix org url in the dropdown menu --- funnel/templates/account_menu.html.jinja2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/funnel/templates/account_menu.html.jinja2 b/funnel/templates/account_menu.html.jinja2 index 382e9e75f..fcaf35c39 100644 --- a/funnel/templates/account_menu.html.jinja2 +++ b/funnel/templates/account_menu.html.jinja2 @@ -36,7 +36,7 @@ {%- for orgmem in orgmemlist.recent %}
  • - {%- if orgmem.account.logo_url.url %}