Skip to content

Commit c2060e3

Browse files
Update user competency selection and add course select (#294)
* Update selection in LATEST MODULE * Add Course Selection to profile * Add option for external/other on registration list. * Add user lable to profile page * Add hackathon count and veteran status to profile page * Updating build file * Automate S3 staticfiles creation * Amend script * Adjusting script * Adding missing migration file * Fixing participated hackathons function --------- Co-authored-by: Stefan Dworschak <stef.dworschak@gmail.com>
1 parent 355429e commit c2060e3

10 files changed

Lines changed: 140 additions & 27 deletions

File tree

.github/workflows/build.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
release:
55
types:
66
- created
7-
# branches: [ master ]
87

98
jobs:
109

@@ -15,9 +14,6 @@ jobs:
1514
steps:
1615
- uses: actions/checkout@v2
1716

18-
- name: Install AWS CLI
19-
run: sudo apt-get update -y && sudo apt-get install -y awscli
20-
2117
- name: Docker Login
2218
run: AWS_DEFAULT_REGION=eu-west-1 AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY}} AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} aws ecr get-login-password | docker login --username AWS --password-stdin 949266541515.dkr.ecr.eu-west-1.amazonaws.com/ci-hackathon-app
2319

@@ -26,3 +22,9 @@ jobs:
2622

2723
- name: Push Image to AWS Regristry
2824
run: docker push 949266541515.dkr.ecr.eu-west-1.amazonaws.com/ci-hackathon-app:${GITHUB_REF##*/}
25+
26+
- name: Extract staticfiles folder from image
27+
run: ./extract_staticfiles.sh ${GITHUB_REF##*/}
28+
29+
- name: Push staticfiles to S3
30+
run: AWS_DEFAULT_REGION=eu-west-1 AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY}} AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} aws s3 cp --recursive --acl public-read staticfiles s3://codeinstitute-webpublic/hackathon_staticfiles/${GITHUB_REF##*/}

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ COPY ./templates/ /hackathon-app/templates/
2525
COPY ./hackadmin/ /hackathon-app/hackadmin/
2626
COPY ./manage.py /hackathon-app/manage.py
2727

28+
RUN python3 manage.py collectstatic
29+
2830
EXPOSE 8000
2931
ENTRYPOINT ["gunicorn", "--workers=5", "--timeout=120", "--access-logfile=-",\
3032
"--bind=0.0.0.0:8000", "--max-requests=1000", "main.wsgi:application"]

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: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,31 @@
1818
"""
1919
LMS_MODULES_CHOICES = (
2020
('', 'Select Learning Stage'),
21-
('programme_preliminaries', 'Programme Preliminaries'),
22-
('programming_paradigms', 'Programming Paradigms'),
23-
('html_essentials', 'HTML Essentials'),
24-
('css_essentials', 'CSS Essentials'),
25-
('user_centric_frontend_development', 'User Centric Frontend Development'),
26-
('comparative_programming_languages_essentials',
27-
'Comparative Programming Languages Essentials'),
28-
('javascript_essentials', 'Javascript Essentials'),
29-
('interactive_frontend_development', 'Interactive Frontend Development'),
30-
('python_essentials', 'Python Essentials'),
31-
('practical_python', 'Practical Python'),
32-
('data_centric_development', 'Data Centric Development'),
33-
('backend_development', 'Backend Development'),
34-
('full_stack_frameworks_with_django', 'Full Stack Frameworks with Django'),
35-
('alumni', 'Alumni'),
21+
('no_coding_experience', 'No coding experience'),
22+
('just_starting', 'Just starting the course'),
23+
('mid_course', 'In the middle of the course'),
24+
('end_course', 'At the end of the course'),
25+
('graduated', 'Graduated'),
26+
('dev_duties',
27+
'Working with some development duties'),
28+
('working_dev', 'Working as a developer'),
29+
('guest_judge', 'Guest judge'),
30+
('guest_facilitator', 'Guest facilitator'),
3631
('staff', 'Staff'),
3732
)
3833

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+
('external', 'Other/External'),
46+
)
47+
3948
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+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.1.13 on 2025-02-06 17:02
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('accounts', '0021_auto_20250205_1138'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
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)'), ('external', 'Other/External')], default='', max_length=50),
17+
),
18+
]

accounts/models.py

Lines changed: 14 additions & 3 deletions
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(),
@@ -141,9 +149,12 @@ def timezone_to_offset(self):
141149
offset = datetime.now(pytz.timezone(self.timezone)).strftime('%z')
142150
return f'UTC{offset[:-2]}'
143151

144-
def participant_label(self):
145-
teams = self.participated_hackteams.filter(
152+
def get_participated_teams(self):
153+
return self.participated_hackteams.filter(
146154
hackathon__status='finished')
155+
156+
def participant_label(self):
157+
teams = self.get_participated_teams()
147158
if teams.count() == 0:
148159
return 'Hackathon Newbie'
149160
elif teams.count() < 2:

extract_staticfiles.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
rm -fr staticfiles
4+
5+
container_id=$(docker create 949266541515.dkr.ecr.eu-west-1.amazonaws.com/ci-hackathon-app:$1)
6+
docker cp $container_id:/hackathon-app/static ./staticfiles
7+
docker rm -v $container_id
8+

profiles/templates/profiles/profile.html

Lines changed: 28 additions & 1 deletion
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 }}
@@ -81,10 +86,32 @@
8186
{{ user.timezone|title }}
8287
</p>
8388

89+
<label for="userLabel">Hackathon Level</label>
90+
<p id="userLabel">
91+
{{ user.participant_label|title }}
92+
</p>
93+
94+
<label for="userTeamCount">Hackathons Joined</label>
95+
<p id="userTeamCount">
96+
{{ user.get_participated_teams|length }}
97+
</p>
98+
<label for="userHackathons">List of Hackathons Joined</label>
99+
{% if user.get_participated_teams %}
100+
<ul id="userHackathons">
101+
{% for team in user.get_participated_teams %}
102+
<li>
103+
<a href="{% url 'hackathon:view_hackathon' team.hackathon.id %}" class="profile-url">{{ team.hackathon.display_name }}</a>
104+
</li>
105+
{% endfor %}
106+
</ul>
107+
{% else %}
108+
<p id="userHackathons">You haven't participated in any hackathons yet. Why not sign up for the next one?</p>
109+
{% endif %}
110+
84111
<label for="website">Website</label>
85112
<p id="website" class="profile-website-url">
86113
{% if user.website_url %}
87-
<a href="{{ user.website_url }}" target="_blank">
114+
<a href="{{ user.website_url }}" target="_blank" class="profile-url">
88115
{{ user.website_url }}
89116
</a>
90117
{% else %}N/A{% endif %}

static/css/profile.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@
4646
display: block;
4747
}
4848

49+
.card .card-body a.profile-url {
50+
font-size: 1rem;
51+
}
52+
4953
.card .card-body p.profile-website-url a {
5054
text-transform: lowercase;
51-
font-size: 1rem;
5255
}
5356
/* For specific color targeting of 'o' chars in keeping with the CI Logo */
5457

@@ -66,4 +69,4 @@ hr.thick {
6669
html form label,
6770
.dark-text {
6871
font-weight: 700;
69-
}
72+
}

0 commit comments

Comments
 (0)