Skip to content

Commit

Permalink
Merge branch 'central_mess_main5'
Browse files Browse the repository at this point in the history
  • Loading branch information
revatim committed Apr 18, 2019
2 parents b1a2cd6 + 51359ba commit faaa009
Show file tree
Hide file tree
Showing 12 changed files with 270 additions and 104 deletions.
Binary file modified FusionIIIT/Fusion/fusion.db
Binary file not shown.
4 changes: 2 additions & 2 deletions FusionIIIT/applications/central_mess/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ def add_menu_change_request(request, student):
new_dish = request.POST.get("newdish")
print("newdish")
reason = request.POST.get("reason")
menu_object = Menu_change_request(dish=dish, request=new_dish, reason=reason)
# menu_object = Menu_change_request(dish=dish, student_id=student, request=new_dish, reason=reason)
# menu_object = Menu_change_request(dish=dish, request=new_dish, reason=reason)
menu_object = Menu_change_request(dish=dish, student_id=student, request=new_dish, reason=reason)
menu_object.save()
data = {
'status': 1
Expand Down
6 changes: 3 additions & 3 deletions FusionIIIT/applications/central_mess/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime
from django.db import models
from applications.academic_information.models import Student
from applications.academic_information.models import (Student, Holiday)

# Create your models here.
LEAVE_TYPE = (
Expand Down Expand Up @@ -234,7 +234,7 @@ def __str__(self):

class Menu_change_request(models.Model):
dish = models.ForeignKey(Menu, on_delete=models.CASCADE)
# student_id = models.ForeignKey(Student, on_delete=models.CASCADE)
student_id = models.ForeignKey(Student, on_delete=models.CASCADE)
reason = models.TextField()
request = models.CharField(max_length=100)
status = models.CharField(max_length=20, choices=STATUS, default='1')
Expand All @@ -247,7 +247,7 @@ def __str__(self):
class Feedback(models.Model):
student_id = models.ForeignKey(Student, on_delete=models.CASCADE)
mess = models.CharField(max_length=10, choices=MESS_OPTION, default='mess1')
# mess_rating = models.PositiveSmallIntegerField(default='5')
mess_rating = models.PositiveSmallIntegerField(default='5')
fdate = models.DateField(default=datetime.date.today)
description = models.TextField()
feedback_type = models.CharField(max_length=20, choices=FEEDBACK_TYPE)
Expand Down
1 change: 1 addition & 0 deletions FusionIIIT/applications/central_mess/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
url(r'^$', views.mess, name='mess'),
url(r'^menurequest/', views.menu_change_request, name='menu_change_request'),
url(r'^placeorder/', views.place_order, name='placeorder'),
url(r'^addleavet/', views.add_leave_manager, name='addleavet'),
url(r'^submitmessfeedback/', views.submit_mess_feedback, name='submitmessfeedback'),
url(r'^messvacationsubmit/', views.mess_vacation_submit, name='messvacationsubmit'),
url(r'^messmenusubmit/', views.submit_mess_menu, name='messmenusubmit'),
Expand Down
71 changes: 61 additions & 10 deletions FusionIIIT/applications/central_mess/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def mess(request):
rebates = Rebate.objects.filter(student_id=student).order_by('-app_date')
splrequest = Special_request.objects.filter(student_id=student).order_by('-app_date')
mess_optn = Messinfo.objects.get(student_id=student)
if student.programme == 'B.Tech' or student.programme == 'B.Des':
programme = 1
else:
programme = 0
# newmenu = Menu_change_request.objects.all()
# meeting = Mess_meeting.objects.all()
# minutes = Mess_minutes.objects.all()
Expand Down Expand Up @@ -144,7 +148,7 @@ def mess(request):
meeting = Mess_meeting.objects.all()
minutes = Mess_minutes.objects.all()
feed = Feedback.objects.filter(mess='mess1').order_by('-fdate')
feed2 = Feedback.objects.filter(mess='mess1').order_by('-fdate')
feed2 = Feedback.objects.filter(mess='mess2').order_by('-fdate')
sprequest = Special_request.objects.filter(status='1').order_by('-app_date')
sprequest_past = Special_request.objects.filter(status='2').order_by('-app_date')
# count1 = feed.filter(Q(feedback_type='Maintenance') & Q(mess='mess1')).count()
Expand Down Expand Up @@ -195,6 +199,7 @@ def mess(request):
'sprequest': sprequest,
'splrequest': splrequest,
'sprequest_past': sprequest_past,
'programme':programme,
'count1': count1,
'count2': count2,
'count3': count3,
Expand All @@ -214,7 +219,7 @@ def mess(request):
meeting = Mess_meeting.objects.all()
minutes = Mess_minutes.objects.all()
feed = Feedback.objects.filter(mess='mess2').order_by('-fdate')
feed2 = Feedback.objects.filter(mess='mess2').order_by('-fdate')
feed2 = Feedback.objects.filter(mess='mess1').order_by('-fdate')
sprequest = Special_request.objects.filter(status='1').order_by('-app_date')
sprequest_past = Special_request.objects.filter(status='2').order_by('-app_date')
# count5 = feed.filter(Q(feedback_type='Maintenance') & Q(mess='mess2')).count()
Expand Down Expand Up @@ -260,6 +265,7 @@ def mess(request):
'current_date': current_date,
'count': count,
'rebates': rebates,
'programme': programme,
'meeting': meeting,
'minutes': minutes,
'sprequest': sprequest,
Expand Down Expand Up @@ -295,6 +301,7 @@ def mess(request):
'rebates': rebates,
'splrequest': splrequest,
'form': form,
'programme': programme,
'desig': desig
}

Expand All @@ -316,6 +323,7 @@ def mess(request):
y = Menu.objects.all()
x = Nonveg_menu.objects.all()
leave = Rebate.objects.filter(status='1').order_by('-app_date')
leave_past = Rebate.objects.filter(status='2').order_by('-app_date')

context = {
'bill_base': current_bill,
Expand All @@ -329,6 +337,7 @@ def mess(request):
'vaca_all': vaca_all,
'info': extrainfo,
'leave': leave,
'leave_past': leave_past,
'current_date': current_date,
'mess_reg': mess_reg,
'desig': desig,
Expand Down Expand Up @@ -403,14 +412,8 @@ def place_order(request):
if extra_info.user_type == 'student':
student = Student.objects.get(id=extra_info)
student_mess = Messinfo.objects.get(student_id=student)

if student_mess.mess_option == 'mess1':
add_nonveg_order(request, student)
return HttpResponseRedirect('/mess')
elif student_mess.mess_option == 'mess2':
messages.info(request,"You cannot apply for non veg food")
else:
return HttpResponse("you can't apply for this application sorry for the inconvenience")
add_nonveg_order(request, student)
return HttpResponseRedirect('/mess')


@csrf_exempt
Expand Down Expand Up @@ -903,3 +906,51 @@ def get_nonveg_order(request):
'status': 1,
}
return JsonResponse(data)


def add_leave_manager(request):
flag = 1
start_date = request.POST.get('l_startd')
end_date = request.POST.get('l_endd')
roll_number = request.POST.get('l_rollno')
type = request.POST.get('l_type')
purpose = request.POST.get('l_purpose')
student = Student.objects.get(id__id=roll_number)
add_obj = Rebate(student_id = student,
start_date = start_date,
end_date = end_date,
purpose = purpose,
status='2',
leave_type=type)

if (end_date < start_date):
data = {
'status': 3,
'message': "Please check the dates"
}
flag = 0
return HttpResponse('Check the dates')

date_format = "%Y-%m-%d"
b = datetime.strptime(str(start_date), date_format)
d = datetime.strptime(str(end_date), date_format)

rebates = Rebate.objects.filter(student_id=student)
rebate_check = rebates.filter(status='2')

for r in rebate_check:
a = datetime.strptime(str(r.start_date), date_format)
c = datetime.strptime(str(r.end_date), date_format)
if ((b <= a and (d >= a and d <= c)) or (b >= a and (d >= a and d <= c))
or (b <= a and (d >= c)) or ((b >= a and b <= c) and (d >= c))):
flag = 0
data = {
'status': 3,
'message': "Already applied for these dates",
}
return HttpResponse('You are seeing this page : As the leave has been applied for these days already')
if flag == 1:
message = 'Your leave request has been accepted between dates ' + str(b.date()) + ' and ' + str(d.date())
central_mess_notif(request.user, student.id.user, 'leave_request', message)
add_obj.save()
return HttpResponseRedirect('/mess')
10 changes: 6 additions & 4 deletions FusionIIIT/templates/messModule/applications.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@

{% comment %}The tab menu starts here!{% endcomment %}
<div class="ui pointing secondary menu">
{% if programme == 1 %}
<a class="ui active item" data-tab="" id="la">
Leave Requests
</a>
{% endif %}

<a class="ui item" data-tab="" id="va">
<a class="ui {% if programme == 0 %}active{% endif%} item" data-tab="" id="va">
Vacation Food Requests
</a>
<a class="ui item" data-tab="" id="sa">
Special Food Requests
</a>
</div>
<div class="ui active tab" data-tab="" id="latab">
<div class="ui {% if programme == 1 %}active{% endif%} tab" data-tab="" id="latab">
<div class="ui two item menu">
<a class="ui active item" data-tab="" id="la_1">
<a class="ui item" data-tab="" id="la_1">
Apply for leave
</a>
<a class="ui item" data-tab="" id="la_2">
Expand Down Expand Up @@ -193,7 +195,7 @@
</div>
</div>

<div class="ui tab" data-tab="" id="vatab">
<div class="ui {% if programme == 0 %}active{% endif%} tab" data-tab="" id="vatab">
<div class="ui two item menu">
<a class="ui active item" data-tab="" id="va_1">
Apply for Food During Vacation
Expand Down
4 changes: 2 additions & 2 deletions FusionIIIT/templates/messModule/messactivities.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<td>
{% for items in members %}
{% if items.designation.name == "mess_committee_mess1" or items.designation.name == "mess_convener_mess1" %}
<p> {{ items.user }} - {{ items.user.first_name }} {{ items.user.last_name }}
<p> {{ items.user|truncatechars:7 }} - {{ items.user.first_name|title }} {{ items.user.last_name|title }}
{% if items.designation.name == "mess_convener_mess1" %}
(Mess Convener)
{% endif %}
Expand All @@ -46,7 +46,7 @@
{% for items in members %}

{% if items.designation.name == "mess_committee_mess2" or items.designation.name == "mess_convener_mess2" %}
<p> {{ items.user }} - {{ items.user.first_name }} {{ items.user.last_name }}
<p> {{ items.user|truncatechars:7 }} - {{ items.user.first_name|title }} {{ items.user.last_name|title }}
{% if items.designation.name == "mess_convener_mess2" %}
(Mess Convener)
{% endif %}
Expand Down
6 changes: 3 additions & 3 deletions FusionIIIT/templates/messModule/respondmenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<div class="content">
<strong>Date of Application:</strong> {{list.app_date}}
<br>
<strong>Student:</strong> Mess Convener
<strong>Student:</strong> {{ list.student_id|truncatewords:1|slice:"-4" }}
<br>
<strong>Reason:</strong> {{list.reason}}
<br>
Expand Down Expand Up @@ -81,7 +81,7 @@
<p style="text-align: center; "><strong>Accepted</strong></p>
<strong>Date of Application:</strong> {{list.app_date}}
<br>
<strong>Student:</strong> Mess Convener
<strong>Student:</strong> {{ list.student_id|truncatewords:1|slice:"-4" }}
<br>
<strong>Reason:</strong> {{list.reason}}
<br>
Expand All @@ -100,7 +100,7 @@
<p style="text-align: center; "><strong>Rejected</strong></p>
<strong>Date of Application:</strong> {{list.app_date}}
<br>
<strong>Student:</strong> Mess Convener
<strong>Student:</strong> {{ list.student_id|truncatewords:1|slice:"-4" }}
<br>
<strong>Reason:</strong> {{list.reason}}
<br>
Expand Down
Loading

0 comments on commit faaa009

Please sign in to comment.