Skip to content

Commit

Permalink
Merge pull request #292 from kenanwright1988/disable_registrations
Browse files Browse the repository at this point in the history
Disable registrations for external hackathons
  • Loading branch information
kenanwright1988 authored Sep 12, 2024
2 parents 3521af7 + cf392a9 commit edb72b1
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 15 deletions.
16 changes: 14 additions & 2 deletions hackathon/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,29 @@ class HackathonForm(forms.ModelForm):
})
)
is_public = forms.BooleanField(required=False)
allow_external_registrations = forms.BooleanField(required=False, label="Allow external registrations")
registration_form = forms.URLField(
label="External Registration Form",
required=False,
widget=forms.TextInput(
attrs={
'placeholder': 'Add form url if the event is open to external participants',
'type':'url',
}
)
)
max_participants = forms.IntegerField(
label="Max Number Of Participants (leave empty for no max)",
label="Max Participants",
required=False,
widget=forms.TextInput({'type': 'number'})
widget=forms.TextInput({'type': 'number', 'placeholder': 'Leave empty for no max'})
)

class Meta:
model = Hackathon
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'
]

def __init__(self, *args, **kwargs):
Expand Down
18 changes: 18 additions & 0 deletions hackathon/migrations/0049_hackathon_is_register.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.13 on 2024-09-11 08:30

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('hackathon', '0048_auto_20221219_1655'),
]

operations = [
migrations.AddField(
model_name='hackathon',
name='is_register',
field=models.BooleanField(default=True),
),
]
18 changes: 18 additions & 0 deletions hackathon/migrations/0050_hackathon_google_registrations_form.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.13 on 2024-09-11 11:48

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('hackathon', '0049_hackathon_is_register'),
]

operations = [
migrations.AddField(
model_name='hackathon',
name='google_registrations_form',
field=models.URLField(blank=True, default='', help_text='Link to the Google Form for registrations.'),
),
]
18 changes: 18 additions & 0 deletions hackathon/migrations/0051_auto_20240911_1306.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.13 on 2024-09-11 13:06

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('hackathon', '0050_hackathon_google_registrations_form'),
]

operations = [
migrations.RenameField(
model_name='hackathon',
old_name='google_registrations_form',
new_name='google_registration_form',
),
]
18 changes: 18 additions & 0 deletions hackathon/migrations/0052_auto_20240912_1324.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.13 on 2024-09-12 13:24

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('hackathon', '0051_auto_20240911_1306'),
]

operations = [
migrations.RenameField(
model_name='hackathon',
old_name='google_registration_form',
new_name='registration_form',
),
]
22 changes: 22 additions & 0 deletions hackathon/migrations/0053_auto_20240912_1527.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.1.13 on 2024-09-12 15:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('hackathon', '0052_auto_20240912_1324'),
]

operations = [
migrations.RemoveField(
model_name='hackathon',
name='is_register',
),
migrations.AddField(
model_name='hackathon',
name='allow_external_registrations',
field=models.BooleanField(default=False),
),
]
6 changes: 6 additions & 0 deletions hackathon/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ class Hackathon(models.Model):
)
is_public = models.BooleanField(default=True)
max_participants = models.IntegerField(default=None, null=True, blank=True)
allow_external_registrations = models.BooleanField(default=False)
registration_form = models.URLField(
default="",
blank=True,
help_text=("Link to the Google Form for registrations.")
)

def __str__(self):
return self.display_name
Expand Down
29 changes: 27 additions & 2 deletions hackathon/templates/hackathon/create-event.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,20 @@ <h1>Create Hackathon</h1>
<div class="col-12 mb-3">
{{ form.score_categories|as_crispy_field }}
</div>
<div class="col-12 col-md-6 mb-3">
<div class="col-12 col-md-12 mb-3">
{{ form.is_public|as_crispy_field }}
</div>
<div class="col-12 col-md-6 mb-3">
{{ form.allow_external_registrations|as_crispy_field }}
</div>
<div class="col-6 col-md-6 mb-3" id="google-registration-form-wrapper" style="display: none;" >
{{ form.registration_form|as_crispy_field }}
</div>
<div class="col-12 col-md-12 mb-12">
{{ form.max_participants|as_crispy_field }}
</div>
<div class="col-12 mb-5">
<input type="submit" class="btn-ci mr-2">
<input type="submit" class="btn-ci mr-2" value="Submit">
<a href="{% url 'hackathon:hackathon-list' %}" type="button" class="btn-ci button">Cancel</a>
</div>
</div>
Expand All @@ -77,4 +83,23 @@ <h1>Create Hackathon</h1>
integrity="sha256-FEqEelWI3WouFOo2VWP/uJfs1y8KJ++FLh2Lbqc8SJk=" crossorigin="anonymous">
</script>
<script src="{% static 'js/datetimepicker.js' %}"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const isRegisterCheckbox = document.querySelector('#id_allow_external_registrations');
const googleRegistrationFormWrapper = document.querySelector('#google-registration-form-wrapper');

function toggleGoogleRegistrationForm() {
if (isRegisterCheckbox.checked) {
googleRegistrationFormWrapper.style.display = 'block';
} else {
googleRegistrationFormWrapper.style.display = 'none';
}
}

isRegisterCheckbox.addEventListener('change', toggleGoogleRegistrationForm);

// Initial check
toggleGoogleRegistrationForm();
});
</script>
{% endblock %}
6 changes: 5 additions & 1 deletion hackathon/templates/hackathon/hackathon_view_public.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@

<div class="row">
<div class="col p-0">
<a role="button" class="btn btn-ci mt-3 w-100" href="{% url 'account_login' %}">Login To Register</a>
{% if hackathon.allow_external_registrations %}
<a role="button" class="btn btn-ci mt-3 w-100" href="{{ hackathon.registration_form }}" target="_blank">Register your interest</a>
{% else %}
<a role="button" class="btn btn-ci mt-3 w-100" href="{% url 'account_login' %}">Login To Register</a>
{% endif %}
</div>
</div>

Expand Down
1 change: 0 additions & 1 deletion hackathon/templates/hackathon/includes/enrollpart.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% load custom_tags %}

{% if hackathon.status == 'registration_open' and not hackathon.max_participants_reached %}
<form id="enroll-form" action="{% url 'hackathon:enroll_toggle' %}" method="POST">
{% csrf_token %}
Expand Down
18 changes: 9 additions & 9 deletions scripts/docker_seed.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
echo "============================"
echo "Seeding fixtures"
echo "============================"
docker-compose exec hackathon-app python3 manage.py loaddata organisation
docker-compose exec hackathon-app python3 manage.py loaddata accounts
docker-compose exec hackathon-app python3 manage.py loaddata resources
docker-compose exec hackathon-app python3 manage.py loaddata profiles
docker-compose exec hackathon-app python3 manage.py loaddata emailaddresses
docker-compose exec hackathon-app python3 manage.py loaddata hackathons
docker-compose exec hackathon-app python3 manage.py loaddata showcase
docker-compose exec hackathon-app python3 manage.py loaddata showcase_site_settings
docker-compose exec hackathon-app python3 manage.py loaddata reviews
docker compose exec hackathon-app python3 manage.py loaddata organisation
docker compose exec hackathon-app python3 manage.py loaddata accounts
docker compose exec hackathon-app python3 manage.py loaddata resources
docker compose exec hackathon-app python3 manage.py loaddata profiles
docker compose exec hackathon-app python3 manage.py loaddata emailaddresses
docker compose exec hackathon-app python3 manage.py loaddata hackathons
docker compose exec hackathon-app python3 manage.py loaddata showcase
docker compose exec hackathon-app python3 manage.py loaddata showcase_site_settings
docker compose exec hackathon-app python3 manage.py loaddata reviews

0 comments on commit edb72b1

Please sign in to comment.