From ec56cf66af66c4d7cb209d0dfdd191f67b34d834 Mon Sep 17 00:00:00 2001 From: Kenan Wright Date: Fri, 14 Feb 2025 16:25:13 +0000 Subject: [PATCH 1/7] Add bage for each hackathon --- .../migrations/0022_auto_20250214_1439.py | 18 ++++++ hackathon/forms.py | 12 +++- .../migrations/0056_hackathon_badge_url.py | 18 ++++++ hackathon/models.py | 5 ++ .../templates/hackathon/create-event.html | 3 + .../templates/hackathon/hackathon_view.html | 1 + profiles/templates/profiles/profile.html | 55 +++++++++++-------- static/css/profile.css | 11 ++++ static/js/script.js | 12 ++++ teams/templates/change_teams.html | 2 +- teams/views.py | 4 +- 11 files changed, 116 insertions(+), 25 deletions(-) create mode 100644 accounts/migrations/0022_auto_20250214_1439.py create mode 100644 hackathon/migrations/0056_hackathon_badge_url.py diff --git a/accounts/migrations/0022_auto_20250214_1439.py b/accounts/migrations/0022_auto_20250214_1439.py new file mode 100644 index 00000000..bfc86057 --- /dev/null +++ b/accounts/migrations/0022_auto_20250214_1439.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.13 on 2025-02-14 14:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0021_auto_20250205_1138'), + ] + + operations = [ + migrations.AlterField( + model_name='customuser', + name='current_course', + 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), + ), + ] diff --git a/hackathon/forms.py b/hackathon/forms.py index c20c61a3..d197f0e4 100644 --- a/hackathon/forms.py +++ b/hackathon/forms.py @@ -43,6 +43,16 @@ class HackathonForm(forms.ModelForm): ), required=True ) + badge_url = forms.URLField( + label="Badge URL", + required=False, + widget=forms.TextInput( + attrs={ + 'placeholder': 'Add badge url if available', + 'type': 'url' + } + ) + ) start_date = forms.DateTimeField( label="Start Date", input_formats=['%d/%m/%Y %H:%M'], @@ -110,7 +120,7 @@ class Meta: fields = ['display_name', 'description', 'theme', 'start_date', 'end_date', 'status', 'organisation', 'score_categories', 'team_size', 'tag_line', 'is_public', 'max_participants', - 'allow_external_registrations', 'registration_form' + 'allow_external_registrations', 'registration_form', 'badge_url' ] def __init__(self, *args, **kwargs): diff --git a/hackathon/migrations/0056_hackathon_badge_url.py b/hackathon/migrations/0056_hackathon_badge_url.py new file mode 100644 index 00000000..81286b82 --- /dev/null +++ b/hackathon/migrations/0056_hackathon_badge_url.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.13 on 2025-02-14 14:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hackathon', '0055_remove_event_isreadonly'), + ] + + operations = [ + migrations.AddField( + model_name='hackathon', + name='badge_url', + field=models.URLField(blank=True, default='', help_text='Link to the badge image.'), + ), + ] diff --git a/hackathon/models.py b/hackathon/models.py index a7a5236d..e6b2cf34 100644 --- a/hackathon/models.py +++ b/hackathon/models.py @@ -87,6 +87,11 @@ class Hackathon(models.Model): blank=True, help_text=("Link to the Google Form for registrations.") ) + badge_url = models.URLField( + default="", + blank=True, + help_text=("Link to the badge image.") + ) def __str__(self): return self.display_name diff --git a/hackathon/templates/hackathon/create-event.html b/hackathon/templates/hackathon/create-event.html index f7196daf..9bca7ae5 100644 --- a/hackathon/templates/hackathon/create-event.html +++ b/hackathon/templates/hackathon/create-event.html @@ -58,6 +58,9 @@

Create Hackathon

{{ form.is_public|as_crispy_field }}
+
+ {{ form.badge_url|as_crispy_field }} +
{{ form.allow_external_registrations|as_crispy_field }}
diff --git a/hackathon/templates/hackathon/hackathon_view.html b/hackathon/templates/hackathon/hackathon_view.html index 41e1684b..42f75431 100644 --- a/hackathon/templates/hackathon/hackathon_view.html +++ b/hackathon/templates/hackathon/hackathon_view.html @@ -122,6 +122,7 @@

End: {{ hackathon.end_date }}

Organisation: {{ hackathon.organisation }}

+

hackathon badge

diff --git a/profiles/templates/profiles/profile.html b/profiles/templates/profiles/profile.html index d5d7b116..33a95f64 100644 --- a/profiles/templates/profiles/profile.html +++ b/profiles/templates/profiles/profile.html @@ -15,34 +15,45 @@
-
-
+
+
+ {% if is_owner %} + + {% endif %} + {% if user.profile_image %} + Profile image + {% else %} + + Profile image + {% endif %} +
+
{% if is_owner %} - +

Welcome: {{ user.slack_display_name }}

+

Edit Profile

+ {% if not slack_enabled %} +

Change Password

{% endif %} - {% if user.profile_image %} - Profile image {% else %} - - Profile image +

{{ user.slack_display_name }}

{% endif %} +
-
- {% if is_owner %} -

Welcome: {{ user.slack_display_name }}

-

Edit Profile

- {% if not slack_enabled %} -

Change Password

- {% endif %} - {% else %} -

{{ user.slack_display_name }}

- {% endif %} +
+
+ + {% for team in user.get_participated_teams %} + {% if team.hackathon.badge_url %} + + Hackathon badge + {% endif %} + {% endfor %} +
-
@@ -114,7 +125,7 @@ {{ user.website_url }} - {% else %}N/A{% endif %} + {% else %}N/A{% endif %}git

{% if is_owner or request.user.user_type|is_types:authorised_types or user.email_is_public %} diff --git a/static/css/profile.css b/static/css/profile.css index d6c7e5ab..853e6d44 100644 --- a/static/css/profile.css +++ b/static/css/profile.css @@ -70,3 +70,14 @@ html form label, .dark-text { font-weight: 700; } + + +.zoom-badge { + transform: scale(10); + z-index: 1000; +} + +.shrink-badge { + transform: scale(1); + transition: transform 2s linear; +} diff --git a/static/js/script.js b/static/js/script.js index c80e195a..c8d7a829 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -178,3 +178,15 @@ function _changeClass(element){ function _chageSelection(form_num, rating){ $(`#id_form-${form_num}-rating`).val(rating); } + +$('.mini-badge').click(function() { + $(this).addClass('zoom-badge'); + var poop = $(this); + setTimeout(function(){ + $(poop).removeClass('zoom-badge'); + $(poop).addClass('shrink-badge'); + }, 500); + setTimeout(function(){ + $(poop).removeClass('shrink-badge'); + }, 2500); +}); \ No newline at end of file diff --git a/teams/templates/change_teams.html b/teams/templates/change_teams.html index eae9a3b3..e6d79309 100644 --- a/teams/templates/change_teams.html +++ b/teams/templates/change_teams.html @@ -55,7 +55,7 @@
Leftover Participants
- {% include 'includes/menu.html' %} +{% include 'includes/menu.html' %} {% endblock %} diff --git a/teams/views.py b/teams/views.py index 10d2c5de..d5555e27 100644 --- a/teams/views.py +++ b/teams/views.py @@ -46,7 +46,9 @@ def change_teams(request, hackathon_id): team_sizes = sorted(choose_team_sizes(participants, team_size)) if len(team_sizes) == 0: return render(request, 'change_teams.html', - {'num_participants': len(participants)}) + {'num_participants': len(participants), + 'hackathon_id': hackathon_id, + }) grouped_participants, hackathon_level = group_participants( participants, len(team_sizes)) team_levels = sorted(choose_team_levels(len(team_sizes), hackathon_level)) From df81b29da6eb34d342794dd493bf8471a6bc4eb7 Mon Sep 17 00:00:00 2001 From: Kenan Wright Date: Mon, 17 Feb 2025 09:30:20 +0000 Subject: [PATCH 2/7] Add modal to zoom badge on click --- .../migrations/0023_merge_20250217_0913.py | 14 ++++++++++ profiles/templates/profiles/profile.html | 28 ++++++++++++++++++- static/css/profile.css | 11 -------- static/js/script.js | 12 -------- 4 files changed, 41 insertions(+), 24 deletions(-) create mode 100644 accounts/migrations/0023_merge_20250217_0913.py diff --git a/accounts/migrations/0023_merge_20250217_0913.py b/accounts/migrations/0023_merge_20250217_0913.py new file mode 100644 index 00000000..d75d5c6f --- /dev/null +++ b/accounts/migrations/0023_merge_20250217_0913.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.13 on 2025-02-17 09:13 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0022_auto_20250214_1439'), + ('accounts', '0022_auto_20250206_1702'), + ] + + operations = [ + ] diff --git a/profiles/templates/profiles/profile.html b/profiles/templates/profiles/profile.html index 33a95f64..cde17805 100644 --- a/profiles/templates/profiles/profile.html +++ b/profiles/templates/profiles/profile.html @@ -48,7 +48,7 @@ {% for team in user.get_participated_teams %} {% if team.hackathon.badge_url %} - Hackathon badge + Hackathon badge {% endif %} {% endfor %}
@@ -151,10 +151,36 @@
+ + + {% include 'upload_image.html' %} {% endblock %} {% block js %} + {% endblock %} diff --git a/static/css/profile.css b/static/css/profile.css index 853e6d44..d6c7e5ab 100644 --- a/static/css/profile.css +++ b/static/css/profile.css @@ -70,14 +70,3 @@ html form label, .dark-text { font-weight: 700; } - - -.zoom-badge { - transform: scale(10); - z-index: 1000; -} - -.shrink-badge { - transform: scale(1); - transition: transform 2s linear; -} diff --git a/static/js/script.js b/static/js/script.js index c8d7a829..c80e195a 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -178,15 +178,3 @@ function _changeClass(element){ function _chageSelection(form_num, rating){ $(`#id_form-${form_num}-rating`).val(rating); } - -$('.mini-badge').click(function() { - $(this).addClass('zoom-badge'); - var poop = $(this); - setTimeout(function(){ - $(poop).removeClass('zoom-badge'); - $(poop).addClass('shrink-badge'); - }, 500); - setTimeout(function(){ - $(poop).removeClass('shrink-badge'); - }, 2500); -}); \ No newline at end of file From c37c0c851c5fb169c33a90c313950ed5c39a1575 Mon Sep 17 00:00:00 2001 From: Kenan Wright Date: Mon, 17 Feb 2025 16:15:02 +0000 Subject: [PATCH 3/7] Add dropoff variable and confirmation on member removal --- accounts/admin.py | 2 +- .../migrations/0024_customuser_dropoffs.py | 18 ++++++++++++++++++ accounts/models.py | 6 ++++++ .../templates/includes/remove_participant.html | 2 +- hackadmin/views.py | 4 ++++ .../templates/hackathon/hackathon_view.html | 7 ++++++- static/js/script.js | 14 ++++++++++++++ 7 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 accounts/migrations/0024_customuser_dropoffs.py diff --git a/accounts/admin.py b/accounts/admin.py index 59bd3dde..93c782b6 100644 --- a/accounts/admin.py +++ b/accounts/admin.py @@ -14,7 +14,7 @@ class CustomUserAdmin(BaseUserAdmin): 'username', 'first_name', 'last_name', 'full_name', 'slack_display_name', 'current_lms_module', 'organisation', - 'timezone', 'user_type', 'is_external')}), + 'timezone', 'user_type', 'dropoffs', 'is_external')}), ('Permissions', {'fields': ( 'is_active', 'is_staff', 'is_superuser', 'profile_is_public', 'email_is_public', diff --git a/accounts/migrations/0024_customuser_dropoffs.py b/accounts/migrations/0024_customuser_dropoffs.py new file mode 100644 index 00000000..b9d5ba86 --- /dev/null +++ b/accounts/migrations/0024_customuser_dropoffs.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.13 on 2025-02-17 12:15 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0023_merge_20250217_0913'), + ] + + operations = [ + migrations.AddField( + model_name='customuser', + name='dropoffs', + field=models.IntegerField(default=0, help_text='Number of times a user has dropped off from a hackathon'), + ), + ] diff --git a/accounts/models.py b/accounts/models.py index 4f2367ce..fa994b84 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -119,6 +119,11 @@ class CustomUser(AbstractUser): choices=TIMEZONE_CHOICES, ) + dropoffs = models.IntegerField( + default=0, + help_text=("Number of times a user has dropped off from a hackathon") + ) + class Meta: verbose_name = 'User' verbose_name_plural = 'Users' @@ -141,6 +146,7 @@ def to_team_member(self): 'timezone': self.timezone_to_offset(), 'num_hackathons': teams.count(), 'participant_label': self.participant_label(), + 'dropoffs': self.dropoffs, } def timezone_to_offset(self): diff --git a/hackadmin/templates/includes/remove_participant.html b/hackadmin/templates/includes/remove_participant.html index 297e3cbf..0058b450 100644 --- a/hackadmin/templates/includes/remove_participant.html +++ b/hackadmin/templates/includes/remove_participant.html @@ -1,4 +1,4 @@ -
+ {% csrf_token %} diff --git a/hackadmin/views.py b/hackadmin/views.py index 2e2ab99f..be536a71 100644 --- a/hackadmin/views.py +++ b/hackadmin/views.py @@ -100,6 +100,10 @@ def remove_participant(request, hackathon_id): id=request.POST.get('team_id')) team.participants.remove(participant) + if request.POST.get('dropoffs'): + participant.dropoffs += 1; + participant.save() + messages.success(request, 'Participant successfully removed') return redirect(reverse('hackadmin:hackathon_participants', kwargs={'hackathon_id': hackathon_id})) diff --git a/hackathon/templates/hackathon/hackathon_view.html b/hackathon/templates/hackathon/hackathon_view.html index 42f75431..ccfe5a74 100644 --- a/hackathon/templates/hackathon/hackathon_view.html +++ b/hackathon/templates/hackathon/hackathon_view.html @@ -93,7 +93,12 @@ {% include 'hackathon/includes/judge_team_display.html' %} {% else %} - {% include 'hackathon/includes/enrollpart.html' %} + {% if request.user.dropoffs <= 3 %} + {% include 'hackathon/includes/enrollpart.html' %} +

Dropoffs: {{ request.user.dropoffs }}

+ {% else %} +

You have reached the maximum number of dropoffs and can not register for this hackathon. If you feel this is in error please reach out to the community team on Slack.

+ {% endif %} {% endif %}
diff --git a/static/js/script.js b/static/js/script.js index c80e195a..b28c1e04 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -10,6 +10,20 @@ $(document).ready(function(){ } }); + $('.remove_hackathon_participant').submit(function(event){ + let confirmation = confirm("Do you really want to remove this team member?"); + if(!confirmation){ + event.preventDefault(); + + } + else{ + let confirmationDropoff = confirm("Do you really want to mark this participant as a drop off?"); + if(confirmationDropoff){ + $(this).append(' '); + } + } + }); + $('.hackadmin-add-participant').click(function(){ let participantId = $(this).data('participant-id'); $('.participant_id').val(participantId); From 708fe077f28087f5f630492ae0dfd951c686e730 Mon Sep 17 00:00:00 2001 From: Kenan Wright Date: Tue, 18 Feb 2025 10:24:11 +0000 Subject: [PATCH 4/7] Add default badge image for hackathons --- hackathon/templates/hackathon/hackathon_view.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hackathon/templates/hackathon/hackathon_view.html b/hackathon/templates/hackathon/hackathon_view.html index ccfe5a74..53d4f870 100644 --- a/hackathon/templates/hackathon/hackathon_view.html +++ b/hackathon/templates/hackathon/hackathon_view.html @@ -127,7 +127,11 @@

End: {{ hackathon.end_date }}

Organisation: {{ hackathon.organisation }}

-

hackathon badge

+ {% if hackathon.badge_url %} +

hackathon badge

+ {% else %} +

hackathon badge

+ {% endif %} From fe7a1b24e17251b5a1611e859d3762597fc10681 Mon Sep 17 00:00:00 2001 From: Kenan Wright Date: Tue, 18 Feb 2025 11:38:04 +0000 Subject: [PATCH 5/7] Added dropoffs to profile page --- .../templates/hackathon/hackathon_view.html | 6 ++++-- profiles/templates/profiles/profile.html | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/hackathon/templates/hackathon/hackathon_view.html b/hackathon/templates/hackathon/hackathon_view.html index 53d4f870..c3ba1d9c 100644 --- a/hackathon/templates/hackathon/hackathon_view.html +++ b/hackathon/templates/hackathon/hackathon_view.html @@ -93,11 +93,13 @@ {% include 'hackathon/includes/judge_team_display.html' %} {% else %} - {% if request.user.dropoffs <= 3 %} + {% if request.user.dropoffs <= 2 %} {% include 'hackathon/includes/enrollpart.html' %}

Dropoffs: {{ request.user.dropoffs }}

{% else %} -

You have reached the maximum number of dropoffs and can not register for this hackathon. If you feel this is in error please reach out to the community team on Slack.

+

You've reached the maximum number of drop-offs and can't register for this hackathon. If you believe this is a mistake, + please contact the community team on Slack.
+ Make sure to read the Hackathon Code of Conduct.

{% endif %} {% endif %} diff --git a/profiles/templates/profiles/profile.html b/profiles/templates/profiles/profile.html index cde17805..f83508c7 100644 --- a/profiles/templates/profiles/profile.html +++ b/profiles/templates/profiles/profile.html @@ -118,14 +118,26 @@ {% else %}

You haven't participated in any hackathons yet. Why not sign up for the next one?

{% endif %} - + +

+ {% if user.dropoffs %} + {{ user.dropoffs }} + {% if user.dropoffs >= 1 %} + - Dropping off from a hackathon greatly impacts the team, we understand life happens but please try to only register if you can commit the minimum 3 - 5 hours per day. + {% endif %} + {% else %} + Thank you for not dropping off. Keep up the good work! + {% endif %} +

{% if user.website_url %} {{ user.website_url }} - {% else %}N/A{% endif %}git + {% else %} + N/A + {% endif %}

{% if is_owner or request.user.user_type|is_types:authorised_types or user.email_is_public %} From 8d1668ab130bd4f892a613d01e0f901eca97312b Mon Sep 17 00:00:00 2001 From: Kenan Wright Date: Wed, 19 Feb 2025 16:13:19 +0000 Subject: [PATCH 6/7] Add logic to check enrollment validity based on dropoff --- accounts/admin.py | 2 +- .../0025_customuser_dropped_off_hackathon.py | 20 +++++++++++++++++++ accounts/models.py | 9 +++++++++ hackadmin/views.py | 3 ++- .../templates/hackathon/hackathon_view.html | 9 +++++---- .../hackathon/includes/hackathon_card.html | 7 ++++++- hackathon/templatetags/custom_tags.py | 17 ++++++++++++++++ static/js/script.js | 2 +- 8 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 accounts/migrations/0025_customuser_dropped_off_hackathon.py diff --git a/accounts/admin.py b/accounts/admin.py index 93c782b6..798aa05c 100644 --- a/accounts/admin.py +++ b/accounts/admin.py @@ -14,7 +14,7 @@ class CustomUserAdmin(BaseUserAdmin): 'username', 'first_name', 'last_name', 'full_name', 'slack_display_name', 'current_lms_module', 'organisation', - 'timezone', 'user_type', 'dropoffs', 'is_external')}), + 'timezone', 'user_type', 'dropoffs', 'dropped_off_hackathon', 'is_external')}), ('Permissions', {'fields': ( 'is_active', 'is_staff', 'is_superuser', 'profile_is_public', 'email_is_public', diff --git a/accounts/migrations/0025_customuser_dropped_off_hackathon.py b/accounts/migrations/0025_customuser_dropped_off_hackathon.py new file mode 100644 index 00000000..129bb991 --- /dev/null +++ b/accounts/migrations/0025_customuser_dropped_off_hackathon.py @@ -0,0 +1,20 @@ +# Generated by Django 3.1.13 on 2025-02-19 14:54 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('hackathon', '0056_hackathon_badge_url'), + ('accounts', '0024_customuser_dropoffs'), + ] + + operations = [ + migrations.AddField( + model_name='customuser', + name='dropped_off_hackathon', + 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'), + ), + ] diff --git a/accounts/models.py b/accounts/models.py index fa994b84..245e4c6e 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -124,6 +124,15 @@ class CustomUser(AbstractUser): help_text=("Number of times a user has dropped off from a hackathon") ) + dropped_off_hackathon = models.ForeignKey( + 'hackathon.Hackathon', + on_delete=models.SET_NULL, + related_name='dropped_off_users', + null=True, + blank=True, + help_text=("The hackathon that the user dropped off from") + ) + class Meta: verbose_name = 'User' verbose_name_plural = 'Users' diff --git a/hackadmin/views.py b/hackadmin/views.py index be536a71..911258dd 100644 --- a/hackadmin/views.py +++ b/hackadmin/views.py @@ -101,7 +101,8 @@ def remove_participant(request, hackathon_id): team.participants.remove(participant) if request.POST.get('dropoffs'): - participant.dropoffs += 1; + participant.dropoffs += 1 + participant.dropped_off_hackathon = get_object_or_404(Hackathon, id=hackathon_id) participant.save() messages.success(request, 'Participant successfully removed') diff --git a/hackathon/templates/hackathon/hackathon_view.html b/hackathon/templates/hackathon/hackathon_view.html index c3ba1d9c..7fa1418f 100644 --- a/hackathon/templates/hackathon/hackathon_view.html +++ b/hackathon/templates/hackathon/hackathon_view.html @@ -93,14 +93,15 @@ {% include 'hackathon/includes/judge_team_display.html' %} {% else %} - {% if request.user.dropoffs <= 2 %} + {% with is_blocked=request.user|user_is_blocked:hackathon %} + {% if not is_blocked %} {% include 'hackathon/includes/enrollpart.html' %} -

Dropoffs: {{ request.user.dropoffs }}

{% else %} -

You've reached the maximum number of drop-offs and can't register for this hackathon. If you believe this is a mistake, +

Because you dropped off from the last hackathon you will not be allowed to register for this hackathon. If you believe this is a mistake, please contact the community team on Slack.
Make sure to read the Hackathon Code of Conduct.

- {% endif %} + {% endif %} + {% endwith %} {% endif %} diff --git a/hackathon/templates/hackathon/includes/hackathon_card.html b/hackathon/templates/hackathon/includes/hackathon_card.html index 1eb99eca..d5bb63bc 100644 --- a/hackathon/templates/hackathon/includes/hackathon_card.html +++ b/hackathon/templates/hackathon/includes/hackathon_card.html @@ -1,5 +1,6 @@ {% load static %} {% load account_tags %} +{% load custom_tags %}
+ {% with is_blocked=request.user|user_is_blocked:hackathon %} + {% if not is_blocked %} +
{% include 'hackathon/includes/enroll_card.html' %}
+ {% endif %} + {% endwith %} {% endif %} {% endwith %} diff --git a/hackathon/templatetags/custom_tags.py b/hackathon/templatetags/custom_tags.py index 02d0d86f..fe89ded8 100644 --- a/hackathon/templatetags/custom_tags.py +++ b/hackathon/templatetags/custom_tags.py @@ -4,7 +4,9 @@ import re from django.template import Library +from django.db.models import Q import datetime +from hackathon.models import Hackathon ANCHOR_PATTERN = r'href[=][\"]?.+?(?=[\"])[\"]' @@ -132,3 +134,18 @@ def remove_hrefs(text): TODO: Add functionality to only remove specific links and show others """ return re.sub(ANCHOR_PATTERN, '', text) + + +@register.filter +def user_is_blocked(user, hackathon): + """ Checks if the user is blocked from the this hackathon""" + if not user.dropped_off_hackathon: + return False + else: + orgs = [1] + orgs.append(user.organisation.id) + hackathons = Hackathon.objects.filter((Q(organisation__in=orgs) | Q(is_public=True)) & Q(end_date__lte=hackathon.end_date)).exclude(status__in=['deleted', 'draft']).order_by('-end_date') + if user.dropped_off_hackathon in hackathons[:2]: + return True + return False + diff --git a/static/js/script.js b/static/js/script.js index b28c1e04..fd38dc19 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -19,7 +19,7 @@ $(document).ready(function(){ else{ let confirmationDropoff = confirm("Do you really want to mark this participant as a drop off?"); if(confirmationDropoff){ - $(this).append(' '); + $(this).append(' '); } } }); From a668610c3341e9ac244e6b56833d12c0f35dc0f0 Mon Sep 17 00:00:00 2001 From: Kenan Wright Date: Thu, 20 Feb 2025 09:45:39 +0000 Subject: [PATCH 7/7] Move JS for modal from profile.html to script.js --- profiles/templates/profiles/profile.html | 10 ---------- static/js/script.js | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/profiles/templates/profiles/profile.html b/profiles/templates/profiles/profile.html index f83508c7..2aa99dee 100644 --- a/profiles/templates/profiles/profile.html +++ b/profiles/templates/profiles/profile.html @@ -185,14 +185,4 @@ {% block js %} - {% endblock %} diff --git a/static/js/script.js b/static/js/script.js index fd38dc19..fcd727b9 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -192,3 +192,13 @@ function _changeClass(element){ function _chageSelection(form_num, rating){ $(`#id_form-${form_num}-rating`).val(rating); } + +// Modal for enlarging the badge when clicked +document.addEventListener('DOMContentLoaded', function() { + $('#badgeModal').on('show.bs.modal', function(event) { + var button = $(event.relatedTarget); + var badgeUrl = button.data('badge-url'); + var modal = $(this); + modal.find('#badgeModalImage').attr('src', badgeUrl); + }); +}); \ No newline at end of file