from django.db import models


# Church Repository.
class Repo(models.Model):
    repo_name = models.CharField(max_length=30)
    repo_alias = models.CharField(max_length=50)
    repo_total = models.FloatField()
    repo_note = models.CharField(max_length=100, blank=True)

    class Meta:
        ordering = ['repo_name']

    def __str__(self):
        return self.repo_name + ' : ' + self.repo_alias


# Donation Card.
class Donation(models.Model):
    donation_repo = models.ForeignKey(Repo, on_delete=models.CASCADE)
    donation_person = models.CharField(max_length=30)
    donation_time = models.DateTimeField(auto_now_add=True)
    donation_amount = models.FloatField()
    donation_text = models.CharField(max_length=100)

    class Meta:
        ordering = ['-donation_time', 'donation_person']
