from django.db import models
from django.contrib.auth.models import User


# FEUERWEHR
class feuerwehr(models.Model):
    name = models.CharField(max_length=50)

    def __str__(self):
        return self.name

# FAHRZEUGE
class fahrzeug(models.Model):
    fw = models.ForeignKey(feuerwehr, on_delete=models.CASCADE, name="Standort", null=True)
    kürzel = models.CharField(max_length=50, name="kürzel", default="")
    fn = models.CharField(max_length=20, name="Funkrufname", default="")

    def __str__(self):
        return self.Standort.name + " -- " + str(self.Funkrufname) + " -- " + str(self.kürzel)

# STICHWORT
class alarmierung_SW(models.Model):
    kürzel = models.CharField(max_length=20)
    beschreibung = models.CharField(max_length=50)

    def __str__(self):
        return self.kürzel + " -- " + str(self.beschreibung)

# ALARMIERUNG
class alarmierung(models.Model):
    timestamp = models.DateTimeField(auto_created=True, auto_now_add=True)
    sw = models.ForeignKey(alarmierung_SW, on_delete=models.CASCADE, name="Stichwort")
    ft = models.CharField(max_length=100, null=True)
    fz = models.CharField(max_length=100, null=True)
    fw = models.ForeignKey(feuerwehr, on_delete=models.CASCADE, name="Standort")

    def __str__(self):
        return str(self.timestamp) + " -- " + str(self.Stichwort.kürzel) + " -- " + str(self.ft) + " -- " + str(self.fz) + " -- " + str(self.Standort.name)

class leitstelle(models.Model):
    name = models.CharField(max_length=50)
    fw = models.CharField(max_length=150)
    def __str__(self):
        return self.name