Skip to content

Commit

Permalink
Update profile page #6103
Browse files Browse the repository at this point in the history
  • Loading branch information
boryanagoncharenko committed Feb 16, 2025
1 parent 4f7809c commit 0222fa2
Show file tree
Hide file tree
Showing 72 changed files with 1,888 additions and 34 deletions.
7 changes: 6 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from website.log_fetcher import log_fetcher
from website.frontend_types import Adventure, Program, ExtraStory, SaveInfo
from website.flask_hedy import g_db
from website.newsletter import add_used_slides_to_subscription
from website.newsletter import get_subscription_status

logConfig(LOGGING_CONFIG)
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -2350,6 +2350,10 @@ def profile_page(user):
else:
session['messages'] = 0

subscription_status = ''
if profile.get('is_teacher', False):
subscription_status = get_subscription_status(user.get('email'))

return render_template(
'profile.html',
page_title=gettext('title_my-profile'),
Expand All @@ -2359,6 +2363,7 @@ def profile_page(user):
public_settings=public_profile_settings,
user_classes=classes,
current_page='my-profile',
subscription_status=subscription_status,
javascript_page_options=dict(
page='my-profile',
))
Expand Down
6 changes: 5 additions & 1 deletion build-tools/heroku/tailwind/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,10 @@ p.close-dialog {
@apply bg-blue-200 px-8 py-2 rounded-lg text-3xl cursor-pointer;
}

.section-header-important {
@apply bg-red-300 px-8 py-2 rounded-lg text-3xl cursor-pointer;
}

.profile-section-body-header {
@apply mb-4 pb-2 border-b inline-block w-full;
}
Expand Down Expand Up @@ -1022,4 +1026,4 @@ div[class^="ace_incorrect_hedy_code"] {

.adventure-item.selected .text-gray-500 {
@apply text-white !important;
}
}
27 changes: 27 additions & 0 deletions messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ msgstr ""
msgid "customize_class"
msgstr ""

msgid "danger_zone"
msgstr ""

msgid "dash"
msgstr ""

Expand Down Expand Up @@ -527,6 +530,9 @@ msgstr ""
msgid "destroy_profile"
msgstr ""

msgid "destroy_profile_message"
msgstr ""

msgid "developers_mode"
msgstr ""

Expand Down Expand Up @@ -1028,6 +1034,9 @@ msgstr ""
msgid "newline"
msgstr ""

msgid "newsletter"
msgstr ""

msgid "next_adventure"
msgstr ""

Expand Down Expand Up @@ -1637,12 +1646,24 @@ msgstr ""
msgid "subscribe"
msgstr ""

msgid "subscribe_message"
msgstr ""

msgid "subscribe_newsletter"
msgstr ""

msgid "subscribed_header"
msgstr ""

msgid "subscribed_message"
msgstr ""

msgid "successful_runs"
msgstr ""

msgid "successfully_subscribed"
msgstr ""

msgid "suggestion_color"
msgstr ""

Expand Down Expand Up @@ -1826,6 +1847,12 @@ msgstr ""
msgid "unsubmitted"
msgstr ""

msgid "unsubscribed_header"
msgstr ""

msgid "unsubscribed_message"
msgstr ""

msgid "update_adventure_prompt"
msgstr ""

Expand Down
11 changes: 10 additions & 1 deletion static/js/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ export async function turn_into_teacher_account() {
});
}

export async function subscribe_to_newsletter() {
tryCatchPopup(async () => {
const response = await postJson('/auth/subscribe-to-newsletter');
modal.notifySuccess(response.message);
$('#subscribe_panel').hide();
$('#subscribed_panel').show();
});
}

// *** User forms ***

export function initializeFormSubmits() {
Expand Down Expand Up @@ -279,4 +288,4 @@ async function afterLogin(loginData: Dict<boolean>) {
}
// Otherwise, redirect to the programs page
redirect('');
}
}
53 changes: 36 additions & 17 deletions templates/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,31 @@ <h2 class="profile-section-body-header">{{_('my_messages')}}</h2>
{% endfor %}
</div>
{% endif %}

{% if user_data['is_teacher'] %}
<h1 class="section-header" id="my_subscription" onclick="$ ('#subscription').toggle()">{{_('newsletter')}}</h1>
<div id="subscription" data-cy="messages" class="profile-section-body"
{% if not invitations %} style="display: block;" {% endif %}>
{% if subscription_status == "subscribed" %}
<h2 class="profile-section-body-header">{{_('subscribed_header')}}</h2>
<p class="mt-0 mb-6">{{_('subscribed_message')}}</p>
{% elif subscription_status == "unsubscribed" %}
<h2 class="profile-section-body-header">{{_('unsubscribed_header')}}</h2>
<p class="mt-0 mb-6">{{_('unsubscribed_message')}}</p>
{% else %}
<div id="subscribe_panel">
<h2 class="profile-section-body-header">{{_('subscribe_newsletter')}}</h2>
<p class="mt-0 mb-6">{{_('subscribe_message')}}</p>
<button class="green-btn" onclick="hedyApp.subscribe_to_newsletter();">{{_('subscribe')}}</button>
</div>
<div id="subscribed_panel" class="hidden">
<h2 class="profile-section-body-header">{{_('subscribed_header')}}</h2>
<p class="mt-0 mb-6">{{_('subscribed_message')}}</p>
</div>
{% endif %}
</div>
{% endif %}

<h1 data-cy="profile_button" class="section-header" onclick="$ ('#public_profile_body').toggle()">{{_('public_profile')}}</h1>
<div id="public_profile_body" class="profile-section-body" {% if request.args.get('open') == "public-profile" %} style="display: inline;"{% endif %}>
<h2 class="profile-section-body-header">{{_('public_profile')}}</h2>
Expand Down Expand Up @@ -63,7 +88,8 @@ <h3 class="px-2 pt-0 pb-2 my-0 font-semibold">{{_('favourite_program')}}</h3>
</div>
{% endif %}
<div class="flex flex-row gap-4 items-center border-gray-400 border p-4 rounded-lg">
<input type="checkbox" name="agree_terms" data-cy="agree_terms" required class="" {% if public_settings %}checked{% endif %}>
<input id="agree_terms" type="checkbox" name="agree_terms" data-cy="agree_terms" required
class="" {% if public_settings %}checked{% endif %}>
<label for="agree_terms" class="cursor-pointer w-full">{{_('public_profile_info')}}</label>
</div>
<div class="flex flex-row">
Expand Down Expand Up @@ -145,22 +171,7 @@ <h2 class="profile-section-body-header">{{_('settings')}}</h2>
{% endfor %}
</select>
</div>
<div class="flex flex-row items-center mb-2">
<label for="subscribe" class="inline-block w-72">{{_('subscribe_newsletter')}}</label>
<input type="checkbox" class="ml-auto" data-cy="subscribe" name="subscribe">
</div>
<div class="flex flex-row items-center mb-2">
<label for="pair_with_teacher">{{_('pair_with_teacher')}}</label>
<input type="checkbox" class="ml-auto" data-cy="pair_with_teacher" name="pair_with_teacher">
</div>
<div class="flex flex-row items-center mb-6">
<label for="connect_guest_teacher">{{_('connect_guest_teacher')}}</label>
<input type="checkbox" class="ml-auto" data-cy="connect_guest_teacher" name="connect_guest_teacher"
_="on click toggle [@required='true'] on #phone
toggle .hidden on #phone_number">
</div>
</form>
<button class="red-btn" onclick="hedyApp.destroy('{{_('are_you_sure')}}')" data-cy="delete_profile_button">{{_('destroy_profile')}}</button>
</div>
<h1 id="password_toggle" class="section-header" onclick="$ ('#change_password_body').toggle()">{{_('change_password')}}</h1>
<div class="profile-section-body" id="change_password_body">
Expand All @@ -171,7 +182,7 @@ <h2 class="profile-section-body-header">{{_('change_password')}}</h2>
<input id="old_password" name="old_password" class="personal-input" minlength="6" type=password role="presentation" autocomplete="off" required>
</div>
<div class="flex flex-row items-center mb-2">
<label for="new-password" class="inline-block w-72">{{_('new_password')}}</label>
<label for="new_password" class="inline-block w-72">{{_('new_password')}}</label>
<input id="new_password" name="new-password" class="personal-input" minlength="6" type=password role="presentation" autocomplete="new-password" required>
</div>
<div class="flex flex-row items-center mb-2">
Expand All @@ -187,6 +198,14 @@ <h1 id="teacher_toggle" class="section-header" onclick="$ ('#turn_into_teacher_b
<button class="blue-btn" onclick="hedyApp.turn_into_teacher_account();">{{_('request_teacher_account')}}</button>
</div>
{% endif %}

<h1 id="danger_zone" class="section-header-important"
onclick="$ ('#danger_zone_body').toggle()">{{_('danger_zone')}}</h1>
<div class="profile-section-body" id="danger_zone_body">
<h2 class="profile-section-body-header">{{_('destroy_profile')}}</h2>
<p class="mt-0 mb-6">{{_('destroy_profile_message')}}</p>
<button class="red-btn" onclick="hedyApp.destroy('{{_('are_you_sure')}}')" data-cy="delete_profile_button">{{_('destroy_profile')}}</button>
</div>
</div>
</div>
{% endblock %}
27 changes: 27 additions & 0 deletions translations/ar/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,9 @@ msgstr "تخصيص مغامرة"
msgid "customize_class"
msgstr "تخصيص الصف"

msgid "danger_zone"
msgstr ""

msgid "dash"
msgstr "علامة الشرطة"

Expand Down Expand Up @@ -630,6 +633,9 @@ msgstr ""
msgid "destroy_profile"
msgstr "حذف الملف الشخصي"

msgid "destroy_profile_message"
msgstr ""

msgid "developers_mode"
msgstr "وضع المبرمج"

Expand Down Expand Up @@ -1225,6 +1231,9 @@ msgstr ""
msgid "newline"
msgstr "سطر جديد"

msgid "newsletter"
msgstr ""

#, fuzzy
msgid "next_adventure"
msgstr ""
Expand Down Expand Up @@ -1911,13 +1920,25 @@ msgstr "هذا برنامج تسليمه ولا يمكن نعديله."
msgid "subscribe"
msgstr "اشترك"

msgid "subscribe_message"
msgstr ""

msgid "subscribe_newsletter"
msgstr "اشترك في النشرة الإخبارية"

msgid "subscribed_header"
msgstr ""

msgid "subscribed_message"
msgstr ""

#, fuzzy
msgid "successful_runs"
msgstr ""

msgid "successfully_subscribed"
msgstr ""

#, fuzzy
msgid "suggestion_color"
msgstr ""
Expand Down Expand Up @@ -2140,6 +2161,12 @@ msgstr ""
msgid "unsubmitted"
msgstr ""

msgid "unsubscribed_header"
msgstr ""

msgid "unsubscribed_message"
msgstr ""

msgid "update_adventure_prompt"
msgstr "هل أنت متأكد أنك تريد تعديل هذه المغامرة؟"

Expand Down
27 changes: 27 additions & 0 deletions translations/bg/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,9 @@ msgstr ""
msgid "customize_class"
msgstr ""

msgid "danger_zone"
msgstr ""

msgid "dash"
msgstr "тире"

Expand Down Expand Up @@ -675,6 +678,9 @@ msgstr ""
msgid "destroy_profile"
msgstr "Изтриване на акаунта"

msgid "destroy_profile_message"
msgstr ""

#, fuzzy
msgid "developers_mode"
msgstr ""
Expand Down Expand Up @@ -1313,6 +1319,9 @@ msgstr ""
msgid "newline"
msgstr "нов ред"

msgid "newsletter"
msgstr ""

#, fuzzy
msgid "next_adventure"
msgstr ""
Expand Down Expand Up @@ -2084,13 +2093,25 @@ msgstr ""
msgid "subscribe"
msgstr ""

msgid "subscribe_message"
msgstr ""

msgid "subscribe_newsletter"
msgstr "Абонирай се за нашия журнал"

msgid "subscribed_header"
msgstr ""

msgid "subscribed_message"
msgstr ""

#, fuzzy
msgid "successful_runs"
msgstr ""

msgid "successfully_subscribed"
msgstr ""

#, fuzzy
msgid "suggestion_color"
msgstr ""
Expand Down Expand Up @@ -2320,6 +2341,12 @@ msgstr ""
msgid "unsubmitted"
msgstr ""

msgid "unsubscribed_header"
msgstr ""

msgid "unsubscribed_message"
msgstr ""

#, fuzzy
msgid "update_adventure_prompt"
msgstr ""
Expand Down
Loading

0 comments on commit 0222fa2

Please sign in to comment.