from __future__ import unicode_literals

# Create your models here.
from django.db import models

class Configurazione(models.Model):
  id     = models.CharField(db_column='id',primary_key=True,max_length=128)
  valore = models.TextField(db_column='valore')
  nota = models.TextField(db_column='nota')
  regex = models.TextField(db_column='regex')
  class Meta:
    ordering = ['id']
    db_table = 'configurazione'
    managed  = False


class MailServer(models.Model):
  id = models.IntegerField(db_column='id',primary_key=True)
  ip = models.CharField(db_column='ip',max_length=15)
  server = models.CharField(db_column='server',max_length=20)
  nota = models.TextField(db_column='nota')
  enabled = models.BooleanField(db_column='enabled')
  class Meta:
    ordering = ['server']
    db_table = 'mail_server'
    managed = False

'''
class DomainLevel(models.Model):
  id = models.IntegerField(db_column='id',primary_key=True)
  nome = models.CharField(db_column='nome',max_length=30)
  space_limit = models.IntegerField(db_column='space_limit')
  nota = models.TextField(db_column='nota')
  enabled = models.BooleanField(db_column='enabled')
  class Meta:
    ordering = ['nome']
    db_table = 'Local_domain_level'
    managed = False

class DomainLevels(models.Model):
  id = models.IntegerField(db_column='id',primary_key=True)
  nome = models.CharField(db_column='nome',max_length=256)
  note_access   = models.BooleanField(db_column='note_access') #accesso pannello note
  note_view     = models.BooleanField(db_column='note_view') #visualizza le note sul pannello opzioni

  mail_access   = models.BooleanField(db_column='mail_access') #accede al pannello posta utente
  mail_password = models.BooleanField(db_column='mail_password') #puo' aggiornare la password
  mail_services     = models.BooleanField(db_column='mail_services') #puo' gestire le abilitazioni o disabilitazioni servizi
  mail_delete       = models.BooleanField(db_column='mail_delete') #puo' cancellare l'utente
  mail_view_delete  = models.BooleanField(db_column='mail_view_delete') #permette la visualizzazione dei record 'tobedeleted=True'
  mail_test         = models.BooleanField(db_column='mail_test') #puo' effettuare il test di invio
  mail_access_level   = models.BooleanField(db_column='mail_access_level') #puo' gestire il livello utente
  mail_admin_password = models.BooleanField(db_column='mail_admin_password') #puo' gestire la password a livello amministrativa
  ftp_access   = models.BooleanField(db_column='ftp_access') #abilita l'accesso al pannello ftp
  domain_access       = models.BooleanField(db_column='domain_access') #accesso alle informazioni di dominio
  domain_access_write = models.BooleanField(db_column='domain_access_write') #consente l'editing delle informazioni generali di dominio
  control_other = models.BooleanField(db_column='control_other') #accesso al controllo relay esterno
 
  # gestione registrar
  domain_registrar = models.BooleanField(db_column='domain_registrar') #permette l'accesso alla tabella dei registrar in sola lettura
  domain_registrar_admin = models.BooleanField(db_column='domain_registrar_admin') #consente l'accesso in scrittura alla tabella registrar

  # gestione dei servizi assegnati al dominio
  domain_service_list = models.BooleanField(db_column='domain_service_list')
  domain_service_edit = models.BooleanField(db_column='domain_service_edit')
  domain_service_assign = models.BooleanField(db_column='domain_service_assign')

  #gestione degli owner di dominio
  domain_owner = models.BooleanField(db_column='domain_owner') #consente la visualizzazione delle informazioni dell'owner di dominio
  domain_owner_write = models.BooleanField(db_column='domain_owner_write') # permette all'utente di aggiornare le proprie informazioni owner.
  domain_owner_admin = models.BooleanField(db_column='domain_owner_admin') # permette l'accesso a tutte le liste owner e la loro amministrazione
  domain_list_access  = models.BooleanField(db_column='domain_list_access') #da' l'accesso alla lista dei domini e relativi parametri
  domain_list_new     = models.BooleanField(db_column='domain_list_new') #autorizza alla creazione di nuovi domini
  domain_mail_access  = models.BooleanField(db_column='domain_mail_access') #accesso all'elenco mail di dominio
  domain_mail_global_access = models.BooleanField(db_column='domain_mail_global_access') #accesso globale posta tutti i domini
  alias_list          = models.BooleanField(db_column='alias_list') # permette il listing degli alias
  alias_new           = models.BooleanField(db_column='alias_new') # permette di aggiungere un alias
  alias_edit          = models.BooleanField(db_column='alias_edit') # permette di modificare un alias
  alias_delete        = models.BooleanField(db_column='alias_delete') #permette di cancellare un alias
  alias_domain        = models.BooleanField(db_column='alias_domain') #permette di accedere a tutti gli alias in base al livello di accesso principale
  alias_domain_global = models.BooleanField(db_column='alias_domain_global') #listing globale alias
  test                = models.BooleanField(db_column='test') # livello di test
  sql_access	      = models.BooleanField(db_column='sql_access') # accesso ai database
  sql_list            = models.BooleanField(db_column='sql_list') # lista dei database per dominio
  sql_edit            = models.BooleanField(db_column='sql_edit') #editing dei campi database
  http_access         = models.BooleanField(db_column='http_access')
  http_edit           = models.BooleanField(db_column='http_edit')
  http_list           = models.BooleanField(db_column='http_list')
  proxy_access        = models.BooleanField(db_column='proxy_access')
  proxy_edit          = models.BooleanField(db_column='proxy_edit')
  proxy_list          = models.BooleanField(db_column='proxy_list')
  delete_all          = models.BooleanField(db_column='delete_all')
  delete_user         = models.BooleanField(db_column='delete_user')
  delete_domain       = models.BooleanField(db_column='delete_domain')
  delete_alias        = models.BooleanField(db_column='delete_alias')
  spam                = models.BooleanField(db_column='spam')
  class Meta:
    ordering = ['id']
    db_table = 'mail_level'
    managed = False
'''

class DomainNotes(models.Model):
  id = models.IntegerField(db_column='id',primary_key=True)
  date = models.DateField(db_column='date')
  level = models.IntegerField(db_column='level')
  head = models.CharField(db_column='head',max_length=256)
  body = models.TextField(db_column='body')
  user = models.IntegerField(db_column='user')
  domain = models.IntegerField(db_column='domain')
  other = models.TextField(db_column='other')

  class Meta:
    ordering = ['id']
    db_table = 'domain_notes'
    managed = False

class Menu(models.Model):
  id      = models.IntegerField(db_column='id',primary_key=True)
  menu    = models.CharField(db_column='menu',max_length=50)
  short   = models.CharField(db_column='short',max_length=20)
  command = models.CharField(db_column='command',max_length=50)
  reverse = models.CharField(db_column='reverse',max_length=50)
  level   = models.CharField(db_column='level',max_length=50)
  class Meta:
    ordering = ['id']
    db_table = 'local_menu'
    managed = False

class ControlOther(models.Model):
  CHOICES = (('ok','ok'),('reject','reject'),('hold','hold'),('pass','pass'))
  id        = models.IntegerField(db_column='id',primary_key=True)
  reference = models.CharField(db_column='reference',choices=CHOICES,max_length=256)
  status    = models.CharField(db_column='status',max_length=256)
  _in       = models.BooleanField(db_column='in')
  _out      = models.BooleanField(db_column='out')
  enabled   = models.BooleanField(db_column='enabled')
  class Meta:
    ordering = ['reference']
    db_table = 'local_control_other'
    managed = False

class QueueCommand(models.Model):
  id = models.IntegerField(db_column='id',primary_key=True)
  request = models.CharField(db_column='request',max_length=255)
  command = models.TextField(db_column='command')
  enabled = models.BooleanField(db_column='enabled')
  nota = models.TextField(db_column='nota')
  class Meta:
    ordering = ['command']
    db_table = 'queue_command'
    managed = False

class Queue(models.Model):
  id = models.IntegerField(db_column='id',primary_key=True)
  dtrequest = models.CharField(db_column='dtrequest',max_length=16)
  request = models.ForeignKey('QueueCommand',db_column='request',on_delete=models.CASCADE)
  exploded = models.TextField(db_column='exploded')
  params = models.TextField(db_column='params')
  server = models.CharField(db_column='server',max_length=15)
  chiave = models.TextField(db_column='chiave')
  dtanswer = models.CharField(db_column='dtanswer',max_length=16)
  answer = models.TextField(db_column='answer')
  class Meta:
    ordering = ['dtrequest']
    db_table = 'queue'
    managed = False

