from django.db import models


class Country(models.Model):
    name = models.CharField(verbose_name="الدولة", max_length=30)

    def __str__(self):
        return self.name


class City(models.Model):
    country = models.ForeignKey(
        Country, verbose_name="الدولة", on_delete=models.CASCADE)
    name = models.CharField(verbose_name="المدينة", max_length=30)

    def __str__(self):
        return self.name


class Project(models.Model):
    title = models.CharField(
        verbose_name="عنوان المشروع", max_length=254, blank=False)
    abstract = models.TextField(verbose_name="النبذة", blank=False)
    image = models.ImageField(
        verbose_name="الصورة الخلفية", upload_to="media", height_field=None, width_field=None, max_length=None)
    year = models.CharField(
        verbose_name="السنة", blank=True, max_length=100)
    location = models.ManyToManyField(
        Country, verbose_name="الدول", blank=True)
    number_of_members = models.CharField(
        verbose_name="عدد فريق العمل", max_length=254, blank=True)
    twitter_thread = models.URLField(
        verbose_name="رابط سلسلة التغاريد", max_length=200, blank=True)
    project_email = models.EmailField(
        verbose_name="البريد الألكتروني للمشروع", max_length=254, blank=True)
    project_link = models.URLField(
        verbose_name="رابط العمل", max_length=200, blank=True)

    def __str__(self):
        return self.title


class Person(models.Model):
    name = models.CharField(verbose_name="الإسم الكامل",
                            max_length=100, blank=False)
    membership = models.CharField(
        verbose_name="(٢٠١٩-الآن)", blank=True, max_length=100)
    picture = models.ImageField(
        verbose_name="الصورة", default="./static/default.png", blank=True, null=True, upload_to="media", height_field=None, width_field=None, max_length=None)
    lates_projects = models.ManyToManyField(
        Project, verbose_name="المشاريع الأخيرة", blank=True)
    country = models.ForeignKey(
        Country, verbose_name="الدولة", on_delete=models.SET_NULL, null=True, blank=True)

    city = models.ForeignKey(
        "City", verbose_name="المدينة", on_delete=models.SET_NULL, null=True, blank=True)
    twitter_account = models.URLField(
        verbose_name="حساب تويتر", max_length=200, null=True, blank=True)
    ilarqam_email = models.EmailField(
        verbose_name="البريد الألكتروني", max_length=254, null=True, blank=True)

    def __str__(self):
        return self.name
