diff --git a/hackathon/forms.py b/hackathon/forms.py
index 8603735e..56f5a0ee 100644
--- a/hackathon/forms.py
+++ b/hackathon/forms.py
@@ -1,6 +1,8 @@
from django import forms
-from .models import Hackathon
+from accounts.models import Organisation
+from .models import Hackathon
+from .lists import STATUS_TYPES_CHOICES, JUDGING_STATUS_CHOICES
class HackathonForm(forms.ModelForm):
""" A form to enable users to add hackathon events via the frontend site.
@@ -25,8 +27,7 @@ class HackathonForm(forms.ModelForm):
'rows': 3,
'placeholder': 'Tell us more about this event...'
}
- ),
- required=True
+ )
)
theme = forms.CharField(
label='Theme',
@@ -63,7 +64,27 @@ class HackathonForm(forms.ModelForm):
}
),
)
+ status = forms.CharField(
+ label="Status",
+ required=True,
+ widget=forms.Select(choices=STATUS_TYPES_CHOICES),
+ ),
+ judging_status = forms.CharField(
+ label="Judging Status",
+ required=True,
+ widget=forms.Select(choices=JUDGING_STATUS_CHOICES),
+ ),
+ organisation = forms.ModelChoiceField(
+ label="Organisation",
+ queryset=Organisation.objects.order_by('display_name'),
+ ),
class Meta:
model = Hackathon
- fields = ['display_name', 'description', 'theme', 'start_date', 'end_date']
+ fields = ['display_name', 'description', 'theme', 'start_date',
+ 'end_date', 'status', 'judging_status', 'organisation',
+ ]
+
+ def __init__(self, *args, **kwargs):
+ super(HackathonForm, self).__init__(*args, **kwargs)
+ self.fields['organisation'].empty_label = None
diff --git a/hackathon/templates/hackathon/create-event.html b/hackathon/templates/hackathon/create-event.html
index ff3bc822..e6a50881 100644
--- a/hackathon/templates/hackathon/create-event.html
+++ b/hackathon/templates/hackathon/create-event.html
@@ -34,6 +34,15 @@
Create Hackathon
{{ form.theme|as_crispy_field }}
+
+ {{ form.organisation|as_crispy_field }}
+
+
+ {{ form.status|as_crispy_field }}
+
+
+ {{ form.judging_status|as_crispy_field }}
+
{{ form.start_date|as_crispy_field }}
diff --git a/hackathon/templates/hackathon/includes/hackathon_card.html b/hackathon/templates/hackathon/includes/hackathon_card.html
index 50469980..c69bd28d 100644
--- a/hackathon/templates/hackathon/includes/hackathon_card.html
+++ b/hackathon/templates/hackathon/includes/hackathon_card.html
@@ -1,10 +1,11 @@
-
{{ hackathon.display_name }}
+
{{ hackathon.display_name }} {% if user.user_type != 'participant' %}{{hackathon.status}} {% endif %}
{{ hackathon.start_date }} - {{ hackathon.end_date }}
-
{{ hackathon.description }}
- {% if hackathon.organiser %}
-
Organiser: {{ hackathon.organiser }}
+
Organised for {{ hackathon.organisation }}
+ {% if user.user_type != 'participant' %}
+
+ Participants: {{ hackathon.participants.all|length }} / Teams: {{ hackathon.teams.all|length }}
{% endif %}
Read More
diff --git a/hackathon/views.py b/hackathon/views.py
index 9b6e3246..9b9d9c24 100644
--- a/hackathon/views.py
+++ b/hackathon/views.py
@@ -150,7 +150,7 @@ def create_hackathon(request):
return redirect("hackathon:hackathon-list")
template = "hackathon/create-event.html"
- form = HackathonForm()
+ form = HackathonForm(initial={'organisation': 1})
return render(request, template, {"form": form})
@@ -178,6 +178,7 @@ def create_hackathon(request):
# Submit form and save record
if form.is_valid():
form.instance.created_by = request.user
+ form.instance.organiser = request.user
form.save()
messages.success(
request, 'Thanks for submitting a new Hackathon event!')
diff --git a/home/templates/home/index.html b/home/templates/home/index.html
index a62a0c8c..9840935f 100644
--- a/home/templates/home/index.html
+++ b/home/templates/home/index.html
@@ -5,39 +5,37 @@
+ {% if hackathons %}
Upcoming Hackathons
- {% if hackathons %}
- {% for hackathon in hackathons %}
- {% if hackathon.status == 'published' or user == hackathon.created_by %}
- {% if hackathon.organisation.id == 1 or hackathon.organisation == user.organisation %}
- {% if not hackathon.status == 'deleted' %}
-
-
-
-
-
-
Start: {{ hackathon.start_date }} - End: {{ hackathon.end_date }}
-
{{ hackathon.description }}
- {% if hackathon.organiser %}
-
Organiser: {{ hackathon.organiser }}
- {% endif %}
-
Read More
-
-
+ {% for hackathon in hackathons %}
+ {% if hackathon.status == 'published' %}
+ {% if hackathon.organisation.id == 1 or hackathon.organisation == user.organisation %}
+ {% if not hackathon.status == 'deleted' %}
+
+
+
+
+
Start: {{ hackathon.start_date }} - End: {{ hackathon.end_date }}
+
{{ hackathon.description }}
+ {% if hackathon.organiser %}
+
Organiser: {{ hackathon.organiser }}
+ {% endif %}
+
Read More
- {% endif %}
+
{% endif %}
{% endif %}
- {% endfor %}
- {% else %}
-
There aren't any Hackathons at the moment!
{% endif %}
+ {% endfor %}
+ {% else %}
+
There aren't any Hackathons at the moment!
+ {% endif %}
Project Portfolio
@@ -48,7 +46,6 @@ There aren't any Hackathons at the moment!
-
@@ -85,5 +82,4 @@
Submission Showcases
-
{% endblock %}