From e7d04d9817d4201c7292915c763b7620e485fffd Mon Sep 17 00:00:00 2001 From: Sli Date: Wed, 21 Aug 2024 11:44:11 +0200 Subject: [PATCH] Unify user profile display with a nice macro and handle camera errors --- core/static/core/style.scss | 6 + core/static/user/user_edit.scss | 11 +- core/templates/core/user_edit.jinja | 325 +++++++++++++--------------- 3 files changed, 172 insertions(+), 170 deletions(-) diff --git a/core/static/core/style.scss b/core/static/core/style.scss index b08be5fb..01ab8787 100644 --- a/core/static/core/style.scss +++ b/core/static/core/style.scss @@ -260,6 +260,12 @@ a:not(.button) { } } + &.btn-red { + background-color: #fc8181; + color: black; + border: #fc8181 1px solid; + } + i { margin-right: 4px; } diff --git a/core/static/user/user_edit.scss b/core/static/user/user_edit.scss index a0dcf559..08cff0ea 100644 --- a/core/static/user/user_edit.scss +++ b/core/static/user/user_edit.scss @@ -63,6 +63,11 @@ padding: 10px 10px 0; } + .camera-error { + background-color: red; + min-width: 100%; + } + &-display { display: flex; flex-direction: column; @@ -74,13 +79,17 @@ height: auto; } - >img { + > img, > video { width: 100% !important; object-fit: contain; height: auto; max-height: 100%; } + > i { + font-size: 32px; + } + >p { text-align: left !important; width: 100% !important; diff --git a/core/templates/core/user_edit.jinja b/core/templates/core/user_edit.jinja index 9ae0c195..7c114a77 100644 --- a/core/templates/core/user_edit.jinja +++ b/core/templates/core/user_edit.jinja @@ -8,6 +8,155 @@ {%- endblock -%} +{% macro profile_picture(field_name) %} +
+
+ {%- trans -%}Profile{%- endtrans -%} + + +
+
+ + +
+
+ {%- if form[field_name] -%} +

+ {{ form[field_name].label }} +

+ {{ form[field_name] }} + {%- if user.is_root and form.instance[field_name] -%} + + {%- endif -%} + {%- else -%} + {% trans %}To edit your profile picture, ask a member of the AE{% endtrans %} + {%- endif -%} +
+
+ +{% endmacro %} + {%- block content -%}

{%- trans -%}Edit user profile{%- endtrans -%}

@@ -17,88 +166,13 @@ {# User Pictures #}
-
-
- {%- trans -%}Profile{%- endtrans -%} - - - -
-
- {%- if form.profile_pict -%} -

{{ form.profile_pict.label }}

- {{ form.profile_pict }} - {%- else -%} - {% trans %}To edit your profile picture, ask a member of the AE{% endtrans %} - {%- endif -%} - {%- if user.is_board_member and form.instance.profile_pict.id -%} - - {%- trans -%}Delete{%- endtrans -%} - - {%- endif -%} -
-
-
-
- {%- if form.instance.avatar_pict -%} - {%- trans -%}Profile{%- endtrans -%} - {%- else -%} - {%- trans -%}Profile{%- endtrans -%} - {%- endif -%} -
-
-

{{ form.avatar_pict.label }}

- {{ form.avatar_pict }} - {%- if user.is_board_member and form.instance.avatar_pict.id -%} - - {%- trans -%}Delete{%- endtrans -%} - - {%- endif -%} -
-
-
-
- {%- if form.instance.scrub_pict -%} - {%- trans -%}Profile{%- endtrans -%} - {%- else -%} - {%- trans -%}Profile{%- endtrans -%} - {%- endif -%} -
-
-

{{ form.scrub_pict.label }}

- {{ form.scrub_pict }} - {%- if user.is_board_member and form.instance.scrub_pict.id -%} - - {%- trans -%}Delete{%-endtrans -%} - - {%- endif -%} -
-
+ + {{ profile_picture("profile_pict") }} + + {{ profile_picture("avatar_pict") }} + + {{ profile_picture("scrub_pict") }} +
@@ -169,91 +243,4 @@ {%- endif -%}

- - {%- endblock -%} - -{%- if not form.instance.profile_pict -%} - {%- block script -%} - {%- endblock -%} -{%- endif -%}