Skip to content

Commit edb72b1

Browse files
Merge pull request #292 from kenanwright1988/disable_registrations
Disable registrations for external hackathons
2 parents 3521af7 + cf392a9 commit edb72b1

11 files changed

Lines changed: 155 additions & 15 deletions

hackathon/forms.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,29 @@ class HackathonForm(forms.ModelForm):
8888
})
8989
)
9090
is_public = forms.BooleanField(required=False)
91+
allow_external_registrations = forms.BooleanField(required=False, label="Allow external registrations")
92+
registration_form = forms.URLField(
93+
label="External Registration Form",
94+
required=False,
95+
widget=forms.TextInput(
96+
attrs={
97+
'placeholder': 'Add form url if the event is open to external participants',
98+
'type':'url',
99+
}
100+
)
101+
)
91102
max_participants = forms.IntegerField(
92-
label="Max Number Of Participants (leave empty for no max)",
103+
label="Max Participants",
93104
required=False,
94-
widget=forms.TextInput({'type': 'number'})
105+
widget=forms.TextInput({'type': 'number', 'placeholder': 'Leave empty for no max'})
95106
)
96107

97108
class Meta:
98109
model = Hackathon
99110
fields = ['display_name', 'description', 'theme', 'start_date',
100111
'end_date', 'status', 'organisation', 'score_categories',
101112
'team_size', 'tag_line', 'is_public', 'max_participants',
113+
'allow_external_registrations', 'registration_form'
102114
]
103115

104116
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 2024-09-11 08:30
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('hackathon', '0048_auto_20221219_1655'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='hackathon',
15+
name='is_register',
16+
field=models.BooleanField(default=True),
17+
),
18+
]
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 2024-09-11 11:48
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('hackathon', '0049_hackathon_is_register'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='hackathon',
15+
name='google_registrations_form',
16+
field=models.URLField(blank=True, default='', help_text='Link to the Google Form for registrations.'),
17+
),
18+
]
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 2024-09-11 13:06
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('hackathon', '0050_hackathon_google_registrations_form'),
10+
]
11+
12+
operations = [
13+
migrations.RenameField(
14+
model_name='hackathon',
15+
old_name='google_registrations_form',
16+
new_name='google_registration_form',
17+
),
18+
]
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 2024-09-12 13:24
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('hackathon', '0051_auto_20240911_1306'),
10+
]
11+
12+
operations = [
13+
migrations.RenameField(
14+
model_name='hackathon',
15+
old_name='google_registration_form',
16+
new_name='registration_form',
17+
),
18+
]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 3.1.13 on 2024-09-12 15:27
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('hackathon', '0052_auto_20240912_1324'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(
14+
model_name='hackathon',
15+
name='is_register',
16+
),
17+
migrations.AddField(
18+
model_name='hackathon',
19+
name='allow_external_registrations',
20+
field=models.BooleanField(default=False),
21+
),
22+
]

hackathon/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ class Hackathon(models.Model):
8080
)
8181
is_public = models.BooleanField(default=True)
8282
max_participants = models.IntegerField(default=None, null=True, blank=True)
83+
allow_external_registrations = models.BooleanField(default=False)
84+
registration_form = models.URLField(
85+
default="",
86+
blank=True,
87+
help_text=("Link to the Google Form for registrations.")
88+
)
8389

8490
def __str__(self):
8591
return self.display_name

hackathon/templates/hackathon/create-event.html

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,20 @@ <h1>Create Hackathon</h1>
5555
<div class="col-12 mb-3">
5656
{{ form.score_categories|as_crispy_field }}
5757
</div>
58-
<div class="col-12 col-md-6 mb-3">
58+
<div class="col-12 col-md-12 mb-3">
5959
{{ form.is_public|as_crispy_field }}
6060
</div>
6161
<div class="col-12 col-md-6 mb-3">
62+
{{ form.allow_external_registrations|as_crispy_field }}
63+
</div>
64+
<div class="col-6 col-md-6 mb-3" id="google-registration-form-wrapper" style="display: none;" >
65+
{{ form.registration_form|as_crispy_field }}
66+
</div>
67+
<div class="col-12 col-md-12 mb-12">
6268
{{ form.max_participants|as_crispy_field }}
6369
</div>
6470
<div class="col-12 mb-5">
65-
<input type="submit" class="btn-ci mr-2">
71+
<input type="submit" class="btn-ci mr-2" value="Submit">
6672
<a href="{% url 'hackathon:hackathon-list' %}" type="button" class="btn-ci button">Cancel</a>
6773
</div>
6874
</div>
@@ -77,4 +83,23 @@ <h1>Create Hackathon</h1>
7783
integrity="sha256-FEqEelWI3WouFOo2VWP/uJfs1y8KJ++FLh2Lbqc8SJk=" crossorigin="anonymous">
7884
</script>
7985
<script src="{% static 'js/datetimepicker.js' %}"></script>
86+
<script>
87+
document.addEventListener('DOMContentLoaded', function() {
88+
const isRegisterCheckbox = document.querySelector('#id_allow_external_registrations');
89+
const googleRegistrationFormWrapper = document.querySelector('#google-registration-form-wrapper');
90+
91+
function toggleGoogleRegistrationForm() {
92+
if (isRegisterCheckbox.checked) {
93+
googleRegistrationFormWrapper.style.display = 'block';
94+
} else {
95+
googleRegistrationFormWrapper.style.display = 'none';
96+
}
97+
}
98+
99+
isRegisterCheckbox.addEventListener('change', toggleGoogleRegistrationForm);
100+
101+
// Initial check
102+
toggleGoogleRegistrationForm();
103+
});
104+
</script>
80105
{% endblock %}

hackathon/templates/hackathon/hackathon_view_public.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323

2424
<div class="row">
2525
<div class="col p-0">
26-
<a role="button" class="btn btn-ci mt-3 w-100" href="{% url 'account_login' %}">Login To Register</a>
26+
{% if hackathon.allow_external_registrations %}
27+
<a role="button" class="btn btn-ci mt-3 w-100" href="{{ hackathon.registration_form }}" target="_blank">Register your interest</a>
28+
{% else %}
29+
<a role="button" class="btn btn-ci mt-3 w-100" href="{% url 'account_login' %}">Login To Register</a>
30+
{% endif %}
2731
</div>
2832
</div>
2933

hackathon/templates/hackathon/includes/enrollpart.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{% load custom_tags %}
2-
32
{% if hackathon.status == 'registration_open' and not hackathon.max_participants_reached %}
43
<form id="enroll-form" action="{% url 'hackathon:enroll_toggle' %}" method="POST">
54
{% csrf_token %}

0 commit comments

Comments
 (0)