Skip to content

Commit

Permalink
Merge pull request #36 from Hi-TechMissile/main
Browse files Browse the repository at this point in the history
Added changes to Allocation Form
  • Loading branch information
mittal-ishaan authored Sep 22, 2023
2 parents 2948186 + de0fdcc commit a249332
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ db.sqlite3
db1.sqlite3
__pycache__
migrations
venv
4 changes: 2 additions & 2 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@ def allocationForm(request):
message = ""
if alloc_form.start_time and alloc_form.start_time>now() and alloc_form.end_time and alloc_form.end_time<now():
message = "Form is closed for now."
if Allocation.objects.filter(email=student,period=alloc_form.period).exists():
elif Allocation.objects.filter(email=student,period=alloc_form.period).exists():
allocation_id = Allocation.objects.filter(email=student,period=alloc_form.period).last()
message = "You have already filled the form for this period. with first preference:" + allocation_id.first_pref + " second preference:" + allocation_id.second_pref
if request.method == "POST" and request.user.is_authenticated :
elif request.method == "POST" and request.user.is_authenticated :
try:
period_obj = alloc_form.period
high_tea = request.POST["high_tea"]
Expand Down
33 changes: 31 additions & 2 deletions templates/allocationForm.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ <h4 class="px-5 mx-5">
<div class="form-group p-2">
<b>Period of Allocation: {{ allocation_form_details.period.start_date }} to {{ allocation_form_details.period.end_date }}</b>
</div>
<br>
<div id = "notice">
<strong>NOTE: </strong>High-Tea is <strong>NOT</strong> available for students registering for Jain food.
</div>
<div class="form-group p-2">
<label for="high_tea">High Tea: </label>
<select class="form-control-sm" id="high_tea" name="high_tea">
Expand All @@ -36,10 +40,12 @@ <h4 class="px-5 mx-5">
<div class="form-group p-2">
<label for="high_tea">Jain: </label>
<select class="form-control-sm" id="jain" name="jain">
<option value="True">Yes</option>
<option value="False">No</option>
<option value="True">Yes</option>
</select>
</div>


{%if caterer_list.count > 0%}
<div class="form-group p-2">
<label for="Preference1">First Preference: </label>
Expand Down Expand Up @@ -122,6 +128,29 @@ <h4 class="px-5 mx-5">
document.getElementById("warning-response").innerHTML = "";
}
});

const jainChoice = document.getElementById('jain');
const highTeaChoice = document.getElementById('high_tea');
const notice = document.getElementById('notice');

jainChoice.addEventListener('change', function () {
const selectedOption = jainChoice.value;
console.log(selectedOption);

if(selectedOption === "True")
{
highTeaChoice.value = "False";
}
})

highTeaChoice.addEventListener('change', function () {
const selectedOption = highTeaChoice.value;

if(selectedOption === "True")
{
jainChoice.value = "False";
}
})
// document.getElementById('preference').addEventListener("change",function(event){
// if(event.target.name=='first_pref'){
// caterer = event.target.value;
Expand Down Expand Up @@ -194,4 +223,4 @@ <h4 class="px-5 mx-5">
// }
// }});
</script>
{% endblock %}
{% endblock %}

0 comments on commit a249332

Please sign in to comment.