Skip to content

Commit 95243c4

Browse files
committed
fixed problems with repo
1 parent 275179f commit 95243c4

3 files changed

Lines changed: 190 additions & 20 deletions

File tree

home/templates/includes/navigation.html

Lines changed: 153 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,13 @@
245245
{% trans "Match" %}
246246
</li>
247247
</a>
248+
{% if user.is_authenticated %}
248249
<a class="menu-link" href="{% url 'progress' %}">
249250
<li class="mb-2 menu ps-3 py-1">
250251
{% trans "Progress" %}
251252
</li>
252253
</a>
254+
{% endif %}
253255
</ul>
254256
</div>
255257
</li>
@@ -331,7 +333,60 @@
331333
</div>
332334
{% endif %}
333335

334-
<span class="hamburger-button-menu ms-2" type="button" data-bs-toggle="collapse" data-bs-target="#navbar_global" aria-controls="navbar_global" aria-expanded="false" aria-label="Toggle navigation">
336+
337+
<!-- language switcher (moved into right-side toolbar) -->
338+
<div class="dropdown ms-2" style="margin-left:10px;margin-right:5px;">
339+
{% get_current_language as CURRENT_LANG %}
340+
{% with code=CURRENT_LANG|lower|slice:":2" %}
341+
<button class="nav-link dropdown-toggle btn btn-link p-0"
342+
id="langDropdown"
343+
data-bs-toggle="dropdown"
344+
aria-expanded="false"
345+
title="{% trans 'Language' %}"
346+
type="button">
347+
{% if code == "en" %}
348+
🌐
349+
{% elif code == "es" %}
350+
<img class="flag-icon" src="{% static 'images/flags/es.png' %}" alt="Español">
351+
{% elif code == "zh" %}
352+
<img class="flag-icon" src="{% static 'images/flags/cn.png' %}" alt="简体中文">
353+
{% elif code == "fr" %}
354+
<img class="flag-icon" src="{% static 'images/flags/fr.png' %}" alt="Français">
355+
{% elif code == "ja" %}
356+
<img class="flag-icon" src="{% static 'images/flags/jp.png' %}" alt="日本語">
357+
{% elif code == "ko" %}
358+
<img class="flag-icon" src="{% static 'images/flags/kr.png' %}" alt="한국어">
359+
{% else %}
360+
🌐
361+
{% endif %}
362+
</button>
363+
{% endwith %}
364+
365+
<ul id="lang_menu" class="dropdown-menu dropdown-menu-end" aria-labelledby="langDropdown">
366+
<li><a class="dropdown-item d-flex align-items-center lang-choice" href="#" data-lang="en">
367+
<img class="flag-icon me-2" src="{% static 'images/flags/us.png' %}" alt="English"> English
368+
</a></li>
369+
<li><a class="dropdown-item d-flex align-items-center lang-choice" href="#" data-lang="es">
370+
<img class="flag-icon me-2" src="{% static 'images/flags/es.png' %}" alt="Español"> Español
371+
</a></li>
372+
<li><a class="dropdown-item d-flex align-items-center lang-choice" href="#" data-lang="zh-hans">
373+
<img class="flag-icon me-2" src="{% static 'images/flags/cn.png' %}" alt="简体中文"> 简体中文
374+
</a></li>
375+
<li><a class="dropdown-item d-flex align-items-center lang-choice" href="#" data-lang="fr">
376+
<img class="flag-icon me-2" src="{% static 'images/flags/fr.png' %}" alt="Français"> Français
377+
</a></li>
378+
<li><a class="dropdown-item d-flex align-items-center lang-choice" href="#" data-lang="ja">
379+
<img class="flag-icon me-2" src="{% static 'images/flags/jp.png' %}" alt="日本語"> 日本語
380+
</a></li>
381+
<li><a class="dropdown-item d-flex align-items-center lang-choice" href="#" data-lang="ko">
382+
<img class="flag-icon me-2" src="{% static 'images/flags/kr.png' %}" alt="한국어"> 한국어
383+
</a></li>
384+
</ul>
385+
</div>
386+
387+
<span class="hamburger-button-menu ms-2" type="button" data-bs-toggle="collapse"
388+
data-bs-target="#navbar_global" aria-controls="navbar_global" aria-expanded="false"
389+
aria-label="Toggle navigation">
335390
<span class="navbar-toggler-icon"></span>
336391
</span>
337392

@@ -485,10 +540,81 @@
485540
});
486541
</script>
487542

488-
489-
490543
</div>
491544
</div>
545+
<style>
546+
.flag-icon{
547+
width: 30px;
548+
height: 21px;
549+
object-fit: cover;
550+
flex-shrink: 0;
551+
margin-right: 10px;
552+
display: inline-block;
553+
vertical-align: middle;
554+
border-radius: 2px;
555+
}
556+
557+
.dropdown-menu#lang_menu {
558+
background-color: #fff !important;
559+
border: 1px solid #ccc !important;
560+
border-radius: 4px !important;
561+
box-shadow: 0 2px 6px rgba(0,0,0,.15) !important;
562+
padding: 0 !important;
563+
margin-top: 0.5rem !important;
564+
min-width: auto !important;
565+
width: auto !important;
566+
}
567+
568+
.dropdown-menu#lang_menu .dropdown-item {
569+
color: #4B5868 !important;
570+
font-weight: 500;
571+
padding: 0.5rem 0.8rem !important;
572+
padding-right: 1.2rem !important;
573+
background-color: transparent !important;
574+
border-bottom: 1px solid #eee;
575+
display: flex !important;
576+
align-items: center;
577+
justify-content: flex-start;
578+
}
579+
580+
.dropdown-menu#lang_menu .dropdown-item:last-child {
581+
border-bottom: none;
582+
}
583+
584+
.dropdown-menu#lang_menu .dropdown-item:hover,
585+
.dropdown-menu#lang_menu .dropdown-item:focus {
586+
background-color: #1967D2 !important;
587+
color: #fff !important;
588+
}
589+
590+
.dropdown-menu#lang_menu .dropdown-item.active {
591+
background-color: #ffcd11 !important;
592+
color: #fff !important;
593+
}
594+
595+
#langDropdown img.flag-icon {
596+
filter: none !important;
597+
opacity: 1 !important;
598+
}
599+
</style>
600+
<script>
601+
document.addEventListener('DOMContentLoaded', function () {
602+
const form = document.getElementById('set-lang-form');
603+
const input = document.getElementById('lang-input');
604+
document.querySelectorAll('.dropdown-item.lang-choice[data-lang]').forEach(a => {
605+
a.addEventListener('click', function (e) {
606+
e.preventDefault();
607+
input.value = this.dataset.lang;
608+
form.submit();
609+
});
610+
});
611+
});
612+
</script>
613+
614+
615+
616+
</div>
617+
</div>
492618
</nav>
493619
</header>
494620
<script src="{% static 'js/toggles.js' %}"></script>
@@ -632,5 +758,28 @@
632758
}
633759
});
634760
});
761+
635762
</script>
636-
<script src="{% static 'js/search_suggestions.js' %}"></script>
763+
<script src="{% static 'js/search_suggestions.js' %}"></script>
764+
765+
</script>
766+
<script src="{% static 'js/search_suggestions.js' %}"></script>
767+
<style>
768+
/* Keep navbar link text yellow, including when dropdown is expanded */
769+
.navbar .nav-link,
770+
.navbar .nav-link:hover,
771+
.navbar .nav-link:focus,
772+
.navbar .nav-link:active,
773+
.navbar .nav-link:visited,
774+
.navbar .nav-link.active,
775+
.navbar .dropdown-toggle[aria-expanded="true"],
776+
.navbar .dropdown-toggle.show {
777+
color: #FFCD11 !important;
778+
}
779+
780+
/* Ensure icons/arrows inherit the same yellow */
781+
.navbar .nav-link .fas,
782+
.navbar .nav-link .nav-link-arrow {
783+
color: inherit !important;
784+
}
785+
</style>

home/templates/pages/profile.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@
1313
</div>
1414
{% endif %}
1515

16+
<!-- Banner for users without project preferences -->
17+
{% if not has_preferences %}
18+
<div class="alert alert-warning alert-dismissible fade show mb-4" role="alert">
19+
<div class="d-flex align-items-center">
20+
<i class="fas fa-exclamation-triangle me-3 fs-4"></i>
21+
<div class="flex-grow-1">
22+
<h5 class="alert-heading mb-1">Complete Your Project Preferences</h5>
23+
<p class="mb-2">You haven't filled out your project preferences yet. Complete your preferences to get the most out of your experience!</p>
24+
<a href="/join-us/" class="btn btn-warning btn-sm">
25+
<i class="fas fa-plus me-1"></i>Complete Preferences
26+
</a>
27+
</div>
28+
</div>
29+
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
30+
</div>
31+
{% endif %}
32+
1633
<div class="row justify-content-center">
1734
<!-- Left column for profile picture -->
1835
<div class="col-md-5 mb-4">

home/views.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -189,21 +189,21 @@ def get_login_redirect_url(user):
189189
If user hasn't completed join-us form, redirect to /join-us/
190190
If user has completed it, redirect to profile page
191191
"""
192-
# TEMPORARY FIX: Always redirect to dashboard for OAuth users
193-
# This will be refined later to properly detect OAuth vs regular login
194192
print(f"DEBUG: get_login_redirect_url called for user: {user.email}")
195193

196-
# For now, always redirect to dashboard to fix OAuth redirect issue
197-
print(f"DEBUG: get_login_redirect_url - Redirecting to dashboard")
198-
return '/dashboard/'
199-
200-
# Original logic (commented out for now):
201-
# if Student.objects.filter(user=user).exists():
202-
# # User has completed join-us form, redirect to profile
203-
# return '/profile/'
204-
# else:
205-
# # User hasn't completed join-us form, redirect to join-us page
206-
# return '/join-us/'
194+
try:
195+
student = Student.objects.get(user=user)
196+
# Check if user has filled out project preferences
197+
if student.p1 or student.p2 or student.p3:
198+
print(f"DEBUG: User {user.email} has preferences, redirecting to profile")
199+
return '/profile/'
200+
else:
201+
print(f"DEBUG: User {user.email} has no preferences, redirecting to join-us")
202+
return '/join-us/'
203+
except Student.DoesNotExist:
204+
# User hasn't completed join-us form at all
205+
print(f"DEBUG: User {user.email} has no Student record, redirecting to join-us")
206+
return '/join-us/'
207207

208208

209209

@@ -353,10 +353,13 @@ def profile(request):
353353
except Profile.DoesNotExist:
354354
profile = Profile.objects.create(user=request.user)
355355

356-
# Get student object if exists
356+
# Get student object if exists and check preferences
357+
has_preferences = False
357358
try:
358359
student = Student.objects.get(user=request.user)
359360
skill_count = Progress.objects.filter(student=student, completed=True).count()
361+
# Check if user has filled out project preferences
362+
has_preferences = bool(student.p1 or student.p2 or student.p3)
360363
except Student.DoesNotExist:
361364
skill_count = 0
362365

@@ -408,6 +411,7 @@ def profile(request):
408411
'skill_count': skill_count,
409412
'achievement_count': achievement_count,
410413
'completed_challenges': completed_challenges,
414+
'has_preferences': has_preferences,
411415
}
412416

413417
return render(request, 'pages/profile.html', context)
@@ -697,7 +701,7 @@ def verify_otp(request):
697701
User = get_user_model()
698702
try:
699703
user = User.objects.get(id=user_id)
700-
login(request, user)
704+
login(request, user, backend='django.contrib.auth.backends.ModelBackend')
701705
# Clear session data on success
702706
request.session.pop('otp', None)
703707
request.session.pop('user_id', None)
@@ -1125,7 +1129,7 @@ def login_with_passkey(request):
11251129

11261130
if Passkey.objects.filter(user=user, key=passkey).exists():
11271131
request.session['pending_user_id'] = user.id # Store user ID temporarily
1128-
login(request, user)
1132+
login(request, user, backend='django.contrib.auth.backends.ModelBackend')
11291133

11301134
# Save IP and browser info when logging in with passkey
11311135
user.last_login_ip = get_client_ip(request)

0 commit comments

Comments
 (0)