from django.db import models
from tinymce.models import HTMLField
from taggit.managers import TaggableManager

# Create your models here.
class Event(models.Model):
    Judul = models.CharField(max_length=100)
    Mulai = models.DateTimeField()
    Selesai = models.DateTimeField(blank=True)
    Lokasi = models.TextField(blank=True)
    Link = models.URLField(blank=True)
    Keterangan = models.TextField(blank=True)

    def __str__(self):
        return self.Judul

class Pembicara(models.Model):
    Nama = models.CharField(max_length=100)
    Pekerjaan = models.CharField(max_length=100)
    Deskripsi_singkat = models.TextField(blank=True)
    Foto = models.ImageField(upload_to='web/')
    Email = models.EmailField(blank=True)
    Facebook = models.URLField(blank=True)
    Twitter = models.URLField(blank=True)
    Linkedin = models.URLField(blank=True)
    Instagram = models.URLField(blank=True)
    Keterangan = models.TextField(blank=True)

    def __str__(self):
        return self.Nama

class ListPembicara(models.Model):
    Acara = models.ForeignKey(Event, on_delete=models.PROTECT)
    Pembicara = models.ForeignKey(Pembicara, on_delete=models.PROTECT)

    def __str__(self):
        return str(self.Acara) + ' - ' + str(self.Pembicara)

class Artikel(models.Model):
    Judul = models.CharField(max_length=150)
    Tanggal = models.DateField(null=True)
    Isi = HTMLField()
    tags = TaggableManager()

    def __str__(self):
        return self.Judul