@@ -8,16 +8,26 @@ <h6 class="card-subtitle mb-2 text-muted">{{ hackathon.start_date }} - {{ hackat
88 {% endif %}
99 < a href ="# " class ="btn btn-ci mr-3 "> Read More</ a >
1010
11- <!-- Delete button , only visible for admin users -->
11+ <!-- Edit and Delete buttons , only visible for admin users -->
1212 {% if user.is_authenticated and user.is_superuser %}
13+ <!-- Warn user if hackathon is ongoing or ended before loading edit form - trigger edit modal -->
14+ {% if hackathon.start_date|date:"jS F Y H:i" < = today|date:"jS F Y H:i" %}
15+ < button class ="btn btn-ci mr-3 " type ="button " data-toggle ="modal " data-target ="#edit-modal-{{ hackathon.id }} ">
16+ Edit
17+ </ button >
18+ {% else %}
19+ < a href ="{% url 'hackathon:update_hackathon' hackathon.id %} " class ="btn btn-ci mr-3 ">
20+ Edit
21+ </ a >
22+ {% endif %}
1323 < button class ="btn btn-ci " type ="button " data-toggle ="modal " data-target ="#delete-modal-{{ hackathon.id }} ">
1424 Delete Event
1525 </ button >
1626 {% endif %}
1727 </ div >
1828</ article >
1929
20- <!-- Modal - pass in hackathon id to modal id to enable rendering details and deleting correct hackathon event -->
30+ <!-- Delete modal - pass in hackathon id to modal id to enable rendering details and deleting correct hackathon event -->
2131< div class ="modal fade " id ="delete-modal-{{ hackathon.id }} " tabindex ="-1 " aria-labelledby ="delete-modal "
2232 aria-hidden ="true ">
2333 < div class ="modal-dialog ">
@@ -43,3 +53,31 @@ <h4 class="modal-title">Delete Hackathon</h4>
4353 </ div >
4454 </ div >
4555</ div >
56+
57+ <!-- Edit modal - pass in hackathon id to modal id to enable rendering details and editing correct hackathon event -->
58+ < div class ="modal fade " id ="edit-modal-{{ hackathon.id }} " tabindex ="-1 " aria-labelledby ="edit-modal "
59+ aria-hidden ="true ">
60+ < div class ="modal-dialog ">
61+ < div class ="modal-content ">
62+ < div class ="modal-header ">
63+ < h4 class ="modal-title "> Delete Hackathon</ h4 >
64+ < button type ="button " class ="close " data-dismiss ="modal " aria-label ="Close ">
65+ < span aria-hidden ="true "> ×</ span >
66+ </ button >
67+ </ div >
68+ < div class ="modal-body ">
69+ <!-- Warn user if hackathon has started and is in progress - dates need to be formatted to work correctly -->
70+ {% if hackathon.start_date|date:"jS F Y H:i" < = today|date:"jS F Y H:i" and hackathon.end_date|date:"jS F Y H:i" > = today|date:"jS F Y H:i" %}
71+ {{ hackathon.display_name }} is currently ongoing, do you really want to update it?
72+ {% else %}
73+ <!-- Warn user if hackathon has ended - dates need to be formatted to work correctly -->
74+ {{ hackathon.display_name }} has ended, do you really want to update it?
75+ {% endif %}
76+ </ div >
77+ < div class ="modal-footer ">
78+ < button type ="button " class ="btn btn-ci mr-3 " data-dismiss ="modal "> No</ button >
79+ < a href ="{% url 'hackathon:update_hackathon' hackathon.id %} " type ="button " class ="btn btn-ci "> Yes</ a >
80+ </ div >
81+ </ div >
82+ </ div >
83+ </ div >
0 commit comments