Skip to content

Commit

Permalink
Merge branch 'central_mess_main4'
Browse files Browse the repository at this point in the history
  • Loading branch information
revatim committed Apr 4, 2019
2 parents e96bb09 + 35bece8 commit a2e41d2
Show file tree
Hide file tree
Showing 15 changed files with 330 additions and 137 deletions.
3 changes: 2 additions & 1 deletion FusionIIIT/applications/central_mess/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ class Menu_change_requestAdmin(admin.ModelAdmin):
model = Menu_change_request
fieldsets = [
('dish', {'fields': ['dish']}),
('student_id', {'fields': ['student_id']}),
('request', {'fields': ['request']}),
('status', {'fields': ['status']}),
]
list_display = ('dish', 'request', 'status')
list_display = ('dish','student_id', 'request', 'status')


class Mess_meetingAdmin(admin.ModelAdmin):
Expand Down
15 changes: 12 additions & 3 deletions FusionIIIT/applications/central_mess/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Mess_minutes, Mess_reg, Messinfo, Monthly_bill,
Nonveg_data, Nonveg_menu, Payments, Rebate,
Special_request, Vacation_food, MessBillBase)
from notification.views import central_mess_notif


today_g = datetime.today()
Expand Down Expand Up @@ -72,9 +73,11 @@ def add_mess_feedback(request, student):
data: to record success or any errors
"""
date_today = datetime.now().date()
mess_optn = Messinfo.objects.get(student_id=student)
description = request.POST.get('description')
feedback_type = request.POST.get('feedback_type')
feedback_object = Feedback(student_id=student, fdate=date_today,
mess=mess_optn.mess_option,
description=description,
feedback_type=feedback_type)

Expand Down Expand Up @@ -138,7 +141,7 @@ def add_vacation_food_request(request, student):
return data


def add_menu_change_request(request):
def add_menu_change_request(request, student):
# TODO logic here is flawed if the same dish is use more than once then it will give an error !!!
# or if there are two requests on the same dish
"""
Expand All @@ -155,7 +158,8 @@ def add_menu_change_request(request):
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, 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 All @@ -182,9 +186,11 @@ def handle_menu_change_response(request):
5 for error
"""
ap_id = request.POST.get('idm')
user = request.user
stat = request.POST['status']
application = Menu_change_request.objects.get(pk=ap_id)
print(stat)
# student = application.student_id
# receiver = User.objects.get(username=student)
if stat == '2':
application.status = 2
meal = application.dish
Expand All @@ -194,6 +200,7 @@ def handle_menu_change_response(request):
data = {
'status': '2',
}
# central_mess_notif(user, receiver, 'menu_change_accepted')

elif stat == '0':
application.status = 0
Expand Down Expand Up @@ -389,12 +396,14 @@ def handle_rebate_response(request):
"""
id = request.POST.get('id_rebate')
leaves = Rebate.objects.get(pk=id)
# receiver = ExtraInfo.
date_format = "%Y-%m-%d"
b = datetime.strptime(str(leaves.start_date), date_format)
d = datetime.strptime(str(leaves.end_date), date_format)
rebate_count = (d - b).days
leaves.status = request.POST["status"]
leaves.save()
# central_mess_notif(request.user, receiver, 'menu_change_accepted')
data = {
'message': 'You responded to request !'
}
Expand Down
2 changes: 2 additions & 0 deletions FusionIIIT/applications/central_mess/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +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)
reason = models.TextField()
request = models.CharField(max_length=100)
status = models.CharField(max_length=20, choices=STATUS, default='1')
Expand All @@ -245,6 +246,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')
fdate = models.DateField(default=datetime.date.today)
description = models.TextField()
feedback_type = models.CharField(max_length=20, choices=FEEDBACK_TYPE)
Expand Down
Loading

0 comments on commit a2e41d2

Please sign in to comment.