Skip to content

Commit 3a4c7d9

Browse files
Add Course Selection to profile
1 parent 7a4d82e commit 3a4c7d9

File tree

5 files changed

+62
-3
lines changed

5 files changed

+62
-3
lines changed

accounts/forms.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django import forms
22
from django.contrib.auth import get_user_model
33

4-
from .lists import LMS_MODULES_CHOICES, TIMEZONE_CHOICES
4+
from .lists import LMS_MODULES_CHOICES, TIMEZONE_CHOICES, LMS_COURSE_CHOICES
55
from .models import CustomUser
66

77

@@ -23,6 +23,10 @@ class SignupForm(forms.Form):
2323
widget=forms.Select(choices=LMS_MODULES_CHOICES),
2424
label="Where are you currently in the programme?"
2525
)
26+
current_course = forms.CharField(
27+
widget=forms.Select(choices=LMS_COURSE_CHOICES),
28+
label="What course are you currently on?"
29+
)
2630
timezone = forms.CharField(
2731
widget=forms.Select(choices=TIMEZONE_CHOICES),
2832
label="Timezone"
@@ -31,7 +35,7 @@ class SignupForm(forms.Form):
3135
class Meta:
3236
fields = (
3337
'email', 'password1', 'password2', 'slack_display_name',
34-
'current_lms_module', 'timezone',
38+
'current_lms_module', 'timezone', 'current_course',
3539
)
3640
model = get_user_model()
3741

@@ -41,6 +45,7 @@ def signup(self, request, user):
4145
user.username = self.cleaned_data['email']
4246
user.slack_display_name = self.cleaned_data['slack_display_name']
4347
user.current_lms_module = self.cleaned_data['current_lms_module']
48+
user.current_course = self.cleaned_data['current_course']
4449
user.timezone = self.cleaned_data['timezone']
4550
user.save()
4651

@@ -62,6 +67,10 @@ class EditProfileForm(forms.ModelForm):
6267
widget=forms.Select(choices=LMS_MODULES_CHOICES),
6368
label="Where are you currently in the programme?"
6469
)
70+
current_course = forms.CharField(
71+
widget=forms.Select(choices=LMS_COURSE_CHOICES),
72+
label="What course are you currently on?"
73+
)
6574
about = forms.CharField(widget=forms.Textarea(), required=False)
6675
website_url = forms.CharField(required=False)
6776
timezone = forms.CharField(
@@ -76,6 +85,7 @@ class Meta:
7685
'full_name',
7786
'about',
7887
'slack_display_name',
88+
'current_course',
7989
'current_lms_module',
8090
'website_url',
8191
'timezone',

accounts/lists.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,17 @@
3131
('staff', 'Staff'),
3232
)
3333

34+
"""
35+
List of CI courses to be passed into dropdown of same name for each
36+
user selection.
37+
"""
38+
LMS_COURSE_CHOICES = (
39+
('', 'Select Current Course'),
40+
('L3', 'The Level 3 Diploma in Software Development (L3)'),
41+
('5P', 'The 5 project Diploma in Software Development Course (5P)'),
42+
('4P', 'The 4 project Diploma in Software Development Course (4P)'),
43+
('FSBC', 'The 16 Week Full Stack Developer Bootcamp (BC)'),
44+
('DATABC', 'The 16 Week Data-Analytics Bootcamp (DBC)'),
45+
)
46+
3447
TIMEZONE_CHOICES = [(tz, tz) for tz in pytz.all_timezones]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 3.1.13 on 2025-02-05 11:38
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('accounts', '0020_auto_20230104_1655'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='customuser',
15+
name='current_course',
16+
field=models.CharField(choices=[('', 'Select Current Course'), ('L3', 'The Level 3 Diploma in Software Development (L3)'), ('5P', 'The 5 project Diploma in Software Development Course (5P)'), ('4P', 'The 4 project Diploma in Software Development Course (4P)'), ('FSBC', 'The 16 Week Full Stack Developer Bootcamp (BC)'), ('DATABC', 'The 16 Week Data-Analytics Bootcamp (DBC)')], default='', max_length=50),
17+
),
18+
migrations.AlterField(
19+
model_name='customuser',
20+
name='current_lms_module',
21+
field=models.CharField(choices=[('', 'Select Learning Stage'), ('no_coding_experience', 'No coding experience'), ('just_starting', 'Just starting the course'), ('mid_course', 'In the middle of the course'), ('end_course', 'At the end of the course'), ('graduated', 'Graduated'), ('dev_duties', 'Working with some development duties'), ('working_dev', 'Working as a developer'), ('guest_judge', 'Guest judge'), ('guest_facilitator', 'Guest facilitator'), ('staff', 'Staff')], default='', max_length=50),
22+
),
23+
]

accounts/models.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.db import models
66
from django.contrib.auth.models import AbstractUser
77

8-
from .lists import LMS_MODULES_CHOICES, TIMEZONE_CHOICES
8+
from .lists import LMS_MODULES_CHOICES, TIMEZONE_CHOICES, LMS_COURSE_CHOICES
99
from main.models import SingletonModel
1010
from teams.lists import LMS_LEVELS
1111

@@ -61,6 +61,13 @@ class CustomUser(AbstractUser):
6161
choices=LMS_MODULES_CHOICES
6262
)
6363

64+
current_course = models.CharField(
65+
max_length=50,
66+
blank=False,
67+
default='',
68+
choices=LMS_COURSE_CHOICES
69+
)
70+
6471
organisation = models.ForeignKey(
6572
Organisation,
6673
on_delete=models.CASCADE,
@@ -130,6 +137,7 @@ def to_team_member(self):
130137
'userid': self.id,
131138
'name': self.slack_display_name or self.email,
132139
'level': LMS_LEVELS.get(self.current_lms_module) or 1,
140+
'course': LMS_LEVELS.get(self.current_lms_module) or 1,
133141
'timezone': self.timezone_to_offset(),
134142
'num_hackathons': teams.count(),
135143
'participant_label': self.participant_label(),

profiles/templates/profiles/profile.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171
<label for="about">About</label>
7272
<p id="about" class="profile-about">{% if user.about %}{{ user.about }}{% else %}N/A{% endif %}</p>
7373

74+
<label for="latestCourse">My Course</label>
75+
<p id="latestCourse">
76+
{{ user.current_course|upper }}
77+
</p>
78+
7479
<label for="latestModule">Latest Module</label>
7580
<p id="latestModule">
7681
{{ user.human_readable_current_lms_module|title }}

0 commit comments

Comments
 (0)