# -*- encoding: utf-8 -*-
"""
Copyright (c) 2019 - present AppSeed.us
"""

from django.db import models
from django.contrib.auth.models import User
from django.forms import Textarea, widgets
from django_countries.fields import CountryField
from jalali_date.fields import JalaliDateField, SplitJalaliDateTimeField
from jalali_date.widgets import AdminJalaliDateWidget, AdminSplitJalaliDateTime
from django.utils import timezone
from tinymce.models import HTMLField
from phonenumber_field.modelfields import PhoneNumberField

class course(models.Model):
    name = models.CharField(max_length=100,default="none")
    course_id=models.CharField(max_length=100,default="none")
    sub_course=models.ManyToManyField("self", blank=True)
    free = models.BooleanField(default=False)
    pack = models.BooleanField(default=False)
    course_pack = models.BooleanField(default=False)
    hide = models.BooleanField(default=False)
    hide_in_index = models.BooleanField(default=False)
    alert_active = models.BooleanField(default=False)
    mablagh = models.CharField(max_length=100,default="none")
    def_price = models.CharField(max_length=100,default="none")
    update =models.CharField(max_length=100,default="none")
    time = models.CharField(max_length=100,default="none")
    date = models.CharField(max_length=100,default="none")
    get_type=models.CharField(max_length=100,default="none")
    demo=models.TextField(max_length = 800 , default="none")
    file=models.CharField(max_length=100,default="none")
    suport=models.CharField(max_length=100,default="none")
    cover = models.ImageField(upload_to='img',default="none")
    info = HTMLField()
    alert = models.TextField(max_length = 800 , blank=True)
    preview=models.TextField(max_length = 800 , default="none")
    class Meta:
        verbose_name = " دوره های اموزشی"
        verbose_name_plural = "دوره های اموزشی"
    def __str__(self):
        return self.name
        
        
class student(models.Model):
    name = models.CharField(max_length=100,default="none")
    phone = models.CharField(max_length=15,default="none")
    password = models.CharField(max_length=100,default="none")
    license = models.CharField(max_length=400,default="none")
    course=models.ManyToManyField(course,blank=True)
    class Meta:
        verbose_name = "دانشجویان"
        verbose_name_plural = "دانشجویان"
    def __str__(self):
        return self.name

class date_counter(models.Model):
    id = 1
    today = timezone.now()
    day=models.CharField(max_length=10,default=None)
    def __str__(self):
        return self.day
    
class insta_profile(models.Model):
    user_name = models.CharField(max_length=100,default="none")
    pro_pic = models.CharField(max_length=1000,default="none")
    bio = models.CharField(max_length=200,default="none")
    posts = models.CharField(max_length=100,default="none")
    followers = models.CharField(max_length=100,default="none")
    following = models.CharField(max_length=100,default="none")
    respons = models.CharField(max_length=1000,default="none")
    def __str__(self):
        return self.user_name



class spotplayer_license(models.Model):
    dore = models.ForeignKey(course,on_delete=models.CASCADE )
    user = models.ForeignKey(student,on_delete=models.CASCADE )
    license = models.TextField(max_length = 800 , default="none")
    def __uni__(self):
        return self.user
        
class input(models.Model):
    name = models.CharField(max_length=100,default="none")   
    input_id = models.IntegerField(default=0)
    count = models.IntegerField(default=0)
    class Meta:
        verbose_name = "امار ورودی ها"
        verbose_name_plural = "امار ورودی ها"
    def __str__(self):
        return self.name

class ghore(models.Model):
    username = models.CharField(max_length=100,default="none")
    
    ghore_id = models.IntegerField(default=0)

    def __str__(self):
        return self.username
        
class headline(models.Model):
    dore = models.ForeignKey(course,on_delete=models.CASCADE )
    title = models.CharField(max_length=100,default="none")
    headline_id = models.IntegerField(blank=True)
    def __str__(self):
        return self.title

class videos(models.Model):
    dore = models.ForeignKey(course,on_delete=models.CASCADE )
    headline = models.ForeignKey(headline,on_delete=models.SET_NULL,null=True)
    title = models.CharField(max_length=100,default="none")
    active = models.BooleanField(default=False)
    video_id=models.IntegerField()
    player_url=models.TextField(max_length = 800 , default="none")
    file = models.BooleanField(default=False)
    file_url=models.TextField(max_length = 800 , default="none")
    class Meta:
        verbose_name = "ویدیوها"
        verbose_name_plural = "ویدیوها"
    def __str__(self):
        return self.title

class course_file(models.Model):
    dore = models.ForeignKey(course,on_delete=models.CASCADE )
    title = models.CharField(max_length=100,default="none")
    file_id=models.IntegerField()
    url=models.FileField(upload_to ='file')
    class Meta:
        verbose_name = "فایل ها"
        verbose_name_plural = "فایل ها"
    def __str__(self):
        return self.title
