Skip to content

Commit

Permalink
Fix url validation on create hackathon, update variable is_register name
Browse files Browse the repository at this point in the history
  • Loading branch information
kenanwright1988 committed Sep 12, 2024
1 parent dd6d0c3 commit cf392a9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
7 changes: 4 additions & 3 deletions hackathon/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ class HackathonForm(forms.ModelForm):
})
)
is_public = forms.BooleanField(required=False)
is_register = forms.BooleanField(required=False, label="Allow external registrations")
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'
'placeholder': 'Add form url if the event is open to external participants',
'type':'url',
}
)
)
Expand All @@ -109,7 +110,7 @@ class Meta:
fields = ['display_name', 'description', 'theme', 'start_date',
'end_date', 'status', 'organisation', 'score_categories',
'team_size', 'tag_line', 'is_public', 'max_participants',
'is_register', 'registration_form'
'allow_external_registrations', 'registration_form'
]

def __init__(self, *args, **kwargs):
Expand Down
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),
),
]
2 changes: 1 addition & 1 deletion hackathon/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Hackathon(models.Model):
)
is_public = models.BooleanField(default=True)
max_participants = models.IntegerField(default=None, null=True, blank=True)
is_register = models.BooleanField(default=True)
allow_external_registrations = models.BooleanField(default=False)
registration_form = models.URLField(
default="",
blank=True,
Expand Down
4 changes: 2 additions & 2 deletions hackathon/templates/hackathon/create-event.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h1>Create Hackathon</h1>
{{ form.is_public|as_crispy_field }}
</div>
<div class="col-12 col-md-6 mb-3">
{{ form.is_register|as_crispy_field }}
{{ 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 }}
Expand All @@ -85,7 +85,7 @@ <h1>Create Hackathon</h1>
<script src="{% static 'js/datetimepicker.js' %}"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const isRegisterCheckbox = document.querySelector('#id_is_register');
const isRegisterCheckbox = document.querySelector('#id_allow_external_registrations');
const googleRegistrationFormWrapper = document.querySelector('#google-registration-form-wrapper');

function toggleGoogleRegistrationForm() {
Expand Down
2 changes: 1 addition & 1 deletion hackathon/templates/hackathon/hackathon_view_public.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<div class="row">
<div class="col p-0">
{% if hackathon.is_register %}
{% 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>
Expand Down

0 comments on commit cf392a9

Please sign in to comment.