# Path: LL1_Academy/models.py
# class UserHistory(models.Model):
# 	user = models.ForeignKey(User, on_delete = models.CASCADE)
# 	grammar = models.ForeignKey(Grammar, on_delete = models.CASCADE)
# 	complete = models.BooleanField(default=False)
# 	score = models.IntegerField(default=-1)
# 	updateTime = models.DateTimeField()
# 
# 	def __str__(self):
# 		return str(self.user) + ' ' + str(self.grammar.gid)
# 
# 	def save(self, *args, **kwargs):
# 	    if self.complete and self.score < 0:
# 	        raise Exception("Score cannot be blank for a completed question")
# 	    self.updateTime = timezone.now()
# 	    super(UserHistory, self).save(*args, **kwargs) 
# 
# 	class Meta:
# 		unique_together = (("user","grammar"))


from django.core.management.base import BaseCommand, CommandError
from LL1_Academy.models import UserHistory

class Command(BaseCommand):
    help = 'This will delete all grammars in the database be careful'
    
    def handle(self, *args, **options):

# Path: LL1_Academy/models.py
# class UserHistory(models.Model):
# 	user = models.ForeignKey(User, on_delete = models.CASCADE)
# 	grammar = models.ForeignKey(Grammar, on_delete = models.CASCADE)
# 	complete = models.BooleanField(default=False)
# 	score = models.IntegerField(default=-1)
# 	updateTime = models.DateTimeField()
# 
# 	def __str__(self):
# 		return str(self.user) + ' ' + str(self.grammar.gid)
# 
# 	def save(self, *args, **kwargs):
# 	    if self.complete and self.score < 0:
# 	        raise Exception("Score cannot be blank for a completed question")
# 	    self.updateTime = timezone.now()
# 	    super(UserHistory, self).save(*args, **kwargs) 
# 
# 	class Meta:
# 		unique_together = (("user","grammar"))


# Path: LL1_Academy/management/commands/clearhistory.py
from django.core.management.base import BaseCommand, CommandError
from LL1_Academy.models import UserHistory


class Command(BaseCommand):
    help = 'This will delete all grammars in the database be careful'
    
    def handle(self, *args, **options):

        UserHistory.objects.all().delete()