from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver

class Student(models.Model):
	user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True)
	cardNo = models.TextField(max_length=15, blank=True)
	phoneNo = models.IntegerField(blank=True)
	foodType = models.CharField(max_length = 2, choices = [('v','veg'),('nv','nonveg'),('j','jain')], default = 'v')
	roomNo = models.IntegerField()

class rebateReq(models.Model):
	student = models.ForeignKey(Student,on_delete=models.CASCADE)
	fromDate = models.DateField(max_length=10, help_text="format : DDMMYYYY", null=True, auto_now_add=True)
	toDate = models.DateField(max_length=10, help_text="format : DDMMYYYY", null=True, auto_now_add=True)
	status = models.CharField(max_length = 1, choices = [('Y','yes'),('N','no'), ('W','wait')])

class Meal(models.Model):
	mealType = models.CharField(max_length=1, choices=[('B','breakfast'),('L','lunch'),('S','snacks'),('D','dinner')], primary_key=True)
	price = models.IntegerField(default = 60, choices = [(30,'breakfast'),(60,'lunch'),(30,'snacks'),(60,'dinner')])

class overheadReq(models.Model):
	student = models.ForeignKey(Student, on_delete=models.CASCADE)
	mealType = models.ForeignKey(Meal,on_delete=models.CASCADE)
	date = models.DateField(max_length=10, help_text="format : DDMMYYYY", null=True, auto_now_add=True)
	status = models.CharField(max_length = 1, choices = [('Y','yes'),('N','no'), ('W','wait')])
	count = models.IntegerField(default = 1)
