Skip to content

Commit e957b19

Browse files
Merge pull request #295 from kenanwright1988/dropoff_tracking
Dropoff tracking
2 parents c2060e3 + a668610 commit e957b19

19 files changed

Lines changed: 256 additions & 30 deletions

File tree

accounts/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CustomUserAdmin(BaseUserAdmin):
1414
'username', 'first_name', 'last_name',
1515
'full_name', 'slack_display_name',
1616
'current_lms_module', 'organisation',
17-
'timezone', 'user_type', 'is_external')}),
17+
'timezone', 'user_type', 'dropoffs', 'dropped_off_hackathon', 'is_external')}),
1818
('Permissions', {'fields': (
1919
'is_active', 'is_staff', 'is_superuser',
2020
'profile_is_public', 'email_is_public',
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-14 14:39
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+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 3.1.13 on 2025-02-17 09:13
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('accounts', '0022_auto_20250214_1439'),
10+
('accounts', '0022_auto_20250206_1702'),
11+
]
12+
13+
operations = [
14+
]
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-17 12:15
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('accounts', '0023_merge_20250217_0913'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='customuser',
15+
name='dropoffs',
16+
field=models.IntegerField(default=0, help_text='Number of times a user has dropped off from a hackathon'),
17+
),
18+
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Generated by Django 3.1.13 on 2025-02-19 14:54
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('hackathon', '0056_hackathon_badge_url'),
11+
('accounts', '0024_customuser_dropoffs'),
12+
]
13+
14+
operations = [
15+
migrations.AddField(
16+
model_name='customuser',
17+
name='dropped_off_hackathon',
18+
field=models.ForeignKey(blank=True, help_text='The hackathon that the user dropped off from', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='dropped_off_users', to='hackathon.hackathon'),
19+
),
20+
]

accounts/models.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ class CustomUser(AbstractUser):
119119
choices=TIMEZONE_CHOICES,
120120
)
121121

122+
dropoffs = models.IntegerField(
123+
default=0,
124+
help_text=("Number of times a user has dropped off from a hackathon")
125+
)
126+
127+
dropped_off_hackathon = models.ForeignKey(
128+
'hackathon.Hackathon',
129+
on_delete=models.SET_NULL,
130+
related_name='dropped_off_users',
131+
null=True,
132+
blank=True,
133+
help_text=("The hackathon that the user dropped off from")
134+
)
135+
122136
class Meta:
123137
verbose_name = 'User'
124138
verbose_name_plural = 'Users'
@@ -141,6 +155,7 @@ def to_team_member(self):
141155
'timezone': self.timezone_to_offset(),
142156
'num_hackathons': teams.count(),
143157
'participant_label': self.participant_label(),
158+
'dropoffs': self.dropoffs,
144159
}
145160

146161
def timezone_to_offset(self):

hackadmin/templates/includes/remove_participant.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<form class="delete" action="/hackadmin/{{hackathon.id}}/remove_participant/" method="POST">
1+
<form class="remove_hackathon_participant" action="/hackadmin/{{hackathon.id}}/remove_participant/" method="POST">
22
{% csrf_token %}
33
<input type="hidden" value="{{remove_from_hackathon}}" name="remove_from_hackathon">
44
<input type="hidden" value="{{team.id}}" name="team_id">

hackadmin/views.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ def remove_participant(request, hackathon_id):
100100
id=request.POST.get('team_id'))
101101
team.participants.remove(participant)
102102

103+
if request.POST.get('dropoffs'):
104+
participant.dropoffs += 1
105+
participant.dropped_off_hackathon = get_object_or_404(Hackathon, id=hackathon_id)
106+
participant.save()
107+
103108
messages.success(request, 'Participant successfully removed')
104109
return redirect(reverse('hackadmin:hackathon_participants',
105110
kwargs={'hackathon_id': hackathon_id}))

hackathon/forms.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ class HackathonForm(forms.ModelForm):
4343
),
4444
required=True
4545
)
46+
badge_url = forms.URLField(
47+
label="Badge URL",
48+
required=False,
49+
widget=forms.TextInput(
50+
attrs={
51+
'placeholder': 'Add badge url if available',
52+
'type': 'url'
53+
}
54+
)
55+
)
4656
start_date = forms.DateTimeField(
4757
label="Start Date",
4858
input_formats=['%d/%m/%Y %H:%M'],
@@ -110,7 +120,7 @@ class Meta:
110120
fields = ['display_name', 'description', 'theme', 'start_date',
111121
'end_date', 'status', 'organisation', 'score_categories',
112122
'team_size', 'tag_line', 'is_public', 'max_participants',
113-
'allow_external_registrations', 'registration_form'
123+
'allow_external_registrations', 'registration_form', 'badge_url'
114124
]
115125

116126
def __init__(self, *args, **kwargs):
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-14 14:39
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('hackathon', '0055_remove_event_isreadonly'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='hackathon',
15+
name='badge_url',
16+
field=models.URLField(blank=True, default='', help_text='Link to the badge image.'),
17+
),
18+
]

0 commit comments

Comments
 (0)