# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#   * Rearrange models' order
#   * Make sure each model has one field with primary_key=True
#   * Make sure each ForeignKey has `on_delete` set to the desired behavior.
#   * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals
  
from django.contrib.auth.models import User
from django.db import models
  
   
class Album(models.Model):
    sequence = models.ForeignKey('Sequence', models.CASCADE, related_name="albums")
    detector = models.ForeignKey('Detector', models.DO_NOTHING, related_name="albums")
    name = models.CharField(max_length=45, blank=True, null=True)
    desc = models.TextField(blank=True, null=True)
    created = models.DateTimeField(blank=True, null=True)
    updated = models.DateTimeField(blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'album'
  
    def __str__(self):
        return (str(self.name))
  
  
class Alert(models.Model):
    request = models.OneToOneField('Request', models.CASCADE)
    strategyobs = models.ForeignKey('StrategyObs', models.DO_NOTHING, related_name="alerts")
    voevent_xml = models.TextField(blank=True, null=True)
    type = models.CharField(max_length=45, blank=True, null=True)
    client = models.CharField(max_length=45, blank=True, null=True)
    burst_jd = models.CharField(max_length=45, blank=True, null=True)
    burst_ra = models.CharField(max_length=45, blank=True, null=True)
    burst_dec = models.CharField(max_length=45, blank=True, null=True)
    equinox = models.CharField(max_length=45, blank=True, null=True)
    jd_pkt = models.IntegerField(blank=True, null=True)
    jd_send = models.IntegerField(blank=True, null=True)
    jd_received = models.IntegerField(blank=True, null=True)
    trigger_instrum = models.CharField(max_length=45, blank=True, null=True)
    trigger_num = models.CharField(max_length=45, blank=True, null=True)
    grb_error = models.CharField(max_length=45, blank=True, null=True)
    def_not_grb = models.IntegerField(blank=True, null=True)
    editor = models.CharField(max_length=45, blank=True, null=True)
    flag = models.CharField(max_length=45, blank=True, null=True)
    idgcn_notice = models.IntegerField(blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'alert'
  
    def __str__(self):
        return (self.request.name)
  
  
class Country(models.Model):
    name = models.CharField(max_length=45, blank=True, null=True)
    desc = models.TextField(blank=True, null=True)
    quota = models.FloatField(blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'country'
  
    def __str__(self):
        return (str(self.name))
  
  
class Detector(models.Model):
    device = models.OneToOneField('Device', models.CASCADE)
    telescope = models.ForeignKey('Telescope', models.DO_NOTHING, related_name="detectors")
    status = models.CharField(max_length=7, blank=True, null=True)
    nb_photo_x = models.IntegerField(blank=True, null=True)
    nb_photo_y = models.IntegerField(blank=True, null=True)
    photo_size_x = models.IntegerField(blank=True, null=True)
    photo_size_y = models.IntegerField(blank=True, null=True)
    has_shutter = models.IntegerField(blank=True, null=True)
    equivalent_foc_len = models.CharField(max_length=45, blank=True, null=True)
    acq_start = models.DateTimeField(blank=True, null=True)
    acq_stop = models.DateTimeField(blank=True, null=True)
    check_temp = models.FloatField(blank=True, null=True)
    gain = models.FloatField(blank=True, null=True)
    readout_noise = models.FloatField(blank=True, null=True)
    readout_time = models.FloatField(blank=True, null=True)
    idcam_readout_mode = models.IntegerField(blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'detector'
  
    def __str__(self):
        return (self.device.name)
  
class Device(models.Model):
    name = models.CharField(max_length=45, blank=True, null=True)
    desc = models.TextField(blank=True, null=True)
    created = models.DateTimeField(blank=True, null=True)
    updated = models.DateTimeField(blank=True, null=True)
    is_online = models.IntegerField(blank=True, null=True)
    status = models.CharField(max_length=11, blank=True, null=True)
    maintenance_date = models.DateTimeField(blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'device'
  
    def __str__(self):
        return (str(self.name))
  
class Filter(models.Model):
    device = models.OneToOneField(Device, models.CASCADE)
    detector = models.ForeignKey(Detector, models.DO_NOTHING, related_name="filters")
    category = models.CharField(max_length=1, blank=True, null=True)
    transmission_curve_doc = models.CharField(max_length=45, blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'filter'
  
    def __str__(self):
        return (self.device.name)
  
  
class Image(models.Model):
    plan = models.ForeignKey('Plan', models.CASCADE, related_name="images")
    nrtanalysis = models.ForeignKey('NrtAnalysis', models.DO_NOTHING, blank=True, null=True, related_name="images")
    name = models.CharField(max_length=45, blank=True, null=True)
    desc = models.TextField(blank=True, null=True)
    created = models.DateTimeField(blank=True, null=True)
    updated = models.DateTimeField(blank=True, null=True)
    date_from_gps = models.CharField(max_length=45, blank=True, null=True)
    level = models.IntegerField(blank=True, null=True)
    type = models.CharField(max_length=5, blank=True, null=True)
    quality = models.CharField(max_length=45, blank=True, null=True)
    flaggps = models.CharField(max_length=45, blank=True, null=True)
    exposure = models.CharField(max_length=45, blank=True, null=True)
    tempext = models.CharField(max_length=45, blank=True, null=True)
    pressure = models.CharField(max_length=45, blank=True, null=True)
    humidext = models.CharField(max_length=45, blank=True, null=True)
    wind = models.CharField(max_length=45, blank=True, null=True)
    wind_dir = models.CharField(max_length=45, blank=True, null=True)
    dwnimg = models.CharField(max_length=45, blank=True, null=True)
    dwncata = models.CharField(max_length=45, blank=True, null=True)
    dwn = models.CharField(max_length=45, blank=True, null=True)
    level0_fits_name = models.CharField(max_length=45, blank=True, null=True)
    level1a_fits_name = models.CharField(max_length=45, blank=True, null=True)
    level1b_fits_name = models.CharField(max_length=45, blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'image'
  
    def __str__(self):
        return (str(self.name))
  
  
class NrtAnalysis(models.Model):
    name = models.CharField(max_length=45, blank=True, null=True)
    desc = models.TextField(blank=True, null=True)
    created = models.DateTimeField(blank=True, null=True)
    updated = models.DateTimeField(blank=True, null=True)
    analysis = models.TextField(blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'nrtanalysis'
  
    def __str__(self):
        return (str(self.name))
  
  
class Plan(models.Model):
    album = models.ForeignKey(Album, models.CASCADE, related_name="plans")
    filter = models.ForeignKey(Filter, models.DO_NOTHING, related_name="plans")
    name = models.CharField(max_length=45, blank=True, null=True)
    desc = models.CharField(max_length=45, blank=True, null=True)
    created = models.DateTimeField(blank=True, null=True)
    updated = models.DateTimeField(blank=True, null=True)
    duration = models.FloatField(blank=True, null=True)
    position = models.CharField(max_length=45, blank=True, null=True)
    exposure_time = models.FloatField(blank=True, null=True)
    nb_images = models.IntegerField(blank=True, null=True)
    dithering = models.IntegerField(blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'plan'
  
    def __str__(self):
        return (str(self.name))
  
  
class Request(models.Model):
    pyros_user = models.ForeignKey('PyrosUser', models.DO_NOTHING, related_name="requests")
    scientificprogram = models.ForeignKey('ScientificProgram', models.DO_NOTHING, related_name="requests")
    name = models.CharField(max_length=45, blank=True, null=True)
    desc = models.TextField(blank=True, null=True)
    created = models.DateTimeField(blank=True, null=True)
    updated = models.DateTimeField(blank=True, null=True)
    is_alert = models.IntegerField(blank=True, null=True)
    type = models.CharField(max_length=8, blank=True, null=True)
    status = models.CharField(max_length=10, blank=True, null=True)
    target_or_theme = models.CharField(max_length=45, blank=True, null=True)
    priority = models.IntegerField(blank=True, null=True)
    autodeposit = models.IntegerField(blank=True, null=True)
    checkpoint = models.CharField(max_length=45, blank=True, null=True)
    flag = models.CharField(max_length=45, blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'request'
  
    def __str__(self):
        return (str(self.name))
  
  
class Schedule(models.Model):
    created = models.DateTimeField(blank=True, null=True)
    day_start = models.DateTimeField(blank=True, null=True)
    day_stop = models.DateTimeField(blank=True, null=True)
    flag = models.CharField(max_length=45, blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'schedule'
  
    def __str__(self):
        return (str(self.created))
  
  
class ScheduleHistory(models.Model):
    sequences = models.ManyToManyField('Sequence', related_name='schedulehistorys')
    created = models.DateTimeField(blank=True, null=True)
    day_start = models.DateTimeField(blank=True, null=True)
    day_stop = models.DateTimeField(blank=True, null=True)
    flag = models.CharField(max_length=45, blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'schedulehistory'
  
    def __str__(self):
        return (str(self.created))
  
  
class ScientificProgram(models.Model):
    pyros_users = models.ManyToManyField('PyrosUser', related_name="scientificprograms") 
    name = models.CharField(max_length=45, blank=True, null=True)
    desc = models.TextField(blank=True, null=True)
    quota = models.FloatField(blank=True, null=True)
    priority = models.IntegerField(blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'scientificprogram'
  
    def __str__(self):
        return (str(self.name))
  
class Sequence(models.Model):
    request = models.ForeignKey(Request, models.CASCADE, related_name="sequences")
    sequencetype = models.ForeignKey('SequenceType', models.DO_NOTHING, related_name="sequences")
    schedule = models.ForeignKey(Schedule, models.DO_NOTHING, related_name="sequences")
    name = models.CharField(max_length=45, blank=True, null=True)
    desc = models.TextField(blank=True, null=True)
    created = models.DateTimeField(blank=True, null=True)
    updated = models.DateTimeField(blank=True, null=True)
    is_alert = models.IntegerField(blank=True, null=True)
    status = models.CharField(max_length=11, blank=True, null=True)
    duration = models.FloatField(blank=True, null=True)
    pointing = models.CharField(max_length=45, blank=True, null=True)
    with_drift = models.IntegerField(blank=True, null=True)
    priority = models.IntegerField(blank=True, null=True)
    analysis_method = models.CharField(max_length=45, blank=True, null=True)
    exec_start = models.DateTimeField()
    exec_stop = models.DateTimeField(blank=True, null=True)
    moon_min = models.IntegerField(blank=True, null=True)
    alt_min = models.IntegerField(blank=True, null=True)
    type = models.CharField(max_length=6, blank=True, null=True)
    img_current = models.CharField(max_length=45, blank=True, null=True)
    img_total = models.CharField(max_length=45, blank=True, null=True)
    not_obs = models.IntegerField(blank=True, null=True)
    obsolete = models.IntegerField(blank=True, null=True)
    processing = models.IntegerField(blank=True, null=True)
    flag = models.CharField(max_length=45, blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'sequence'
  
    def __str__(self):
        return (str(self.name))
  
  
class SequenceType(models.Model):
    name = models.CharField(max_length=45, blank=True, null=True)
    desc = models.TextField(blank=True, null=True)
    priority = models.IntegerField(blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'sequencetype'
  
    def __str__(self):
        return (str(self.name))
  
  
class SiteWatch(models.Model):
    updated = models.DateTimeField(blank=True, null=True)
    lights = models.CharField(max_length=45, blank=True, null=True)
    dome = models.CharField(max_length=45, blank=True, null=True)
    doors = models.CharField(max_length=45, blank=True, null=True)
    temperature = models.FloatField(blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'sitewatch'
  
    def __str__(self):
        return (str(self.updated))
  
  
class SiteWatchHistory(models.Model):
    id = models.IntegerField(primary_key=True)
  
    class Meta:
        managed = True
        db_table = 'sitewatchhistory'
  
  
class StrategyObs(models.Model):
    name = models.CharField(max_length=45, blank=True, null=True)
    desc = models.TextField(blank=True, null=True)
    json_file = models.CharField(max_length=45, blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'strategyobs'
  
    def __str__(self):
        return (str(self.name))
  
  
class Telescope(models.Model):
    device = models.OneToOneField(Device, models.CASCADE)
    mount_type = models.CharField(max_length=9, blank=True, null=True)
    diameter = models.FloatField(blank=True, null=True)
    status = models.CharField(max_length=45, blank=True, null=True)
    latitude = models.FloatField(blank=True, null=True)
    longitude = models.FloatField(blank=True, null=True)
    sens = models.CharField(max_length=1, blank=True, null=True)
    altitude = models.FloatField(blank=True, null=True)
    readout_time = models.IntegerField(blank=True, null=True)
    slew_time = models.IntegerField(blank=True, null=True)
    slew_dead = models.IntegerField(blank=True, null=True)
    slew_rate_max = models.FloatField(blank=True, null=True)
    horizon_type = models.CharField(max_length=45, blank=True, null=True)
    horizon_def = models.FloatField(blank=True, null=True)
    lim_dec_max = models.FloatField(blank=True, null=True)
    lim_dec_min = models.FloatField(blank=True, null=True)
    lim_ha_rise = models.FloatField(blank=True, null=True)
    lim_ha_set = models.FloatField(blank=True, null=True)
    address = models.CharField(max_length=45, blank=True, null=True)
    night_elev_sun = models.FloatField(blank=True, null=True)
    mpc_code = models.CharField(max_length=45, blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'telescope'
  
    def __str__(self):
        return (self.device.name)
  
   
class PyrosUser(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    country = models.ForeignKey(Country, models.DO_NOTHING, related_name="pyros_users")
    userlevel = models.ForeignKey('UserLevel', models.DO_NOTHING, related_name="pyros_users")
    desc = models.TextField(blank=True, null=True)
    desce = models.TextField(blank=True, null=True)
    created = models.DateTimeField(blank=True, null=True)
    updated = models.DateTimeField(blank=True, null=True)
    url = models.CharField(max_length=45, blank=True, null=True)
    tel1 = models.CharField(max_length=45, blank=True, null=True)
    tel2 = models.CharField(max_length=45, blank=True, null=True)
    address = models.CharField(max_length=45, blank=True, null=True)
    last_connect = models.DateTimeField(blank=True, null=True)
    cur_connect = models.DateTimeField(blank=True, null=True)
    putvalid_beg = models.DateTimeField(blank=True, null=True)
    putvalid_end = models.DateTimeField(blank=True, null=True)
    acqvalid_beg = models.CharField(max_length=45, blank=True, null=True)
    acqvalid_end = models.CharField(max_length=45, blank=True, null=True)
    quota = models.FloatField(blank=True, null=True)
    quota_rea = models.FloatField(blank=True, null=True)
    u_priority = models.IntegerField(blank=True, null=True)
    p_priority = models.IntegerField(blank=True, null=True)
    dir_level = models.IntegerField(blank=True, null=True)
    can_del_void_req = models.IntegerField(blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'pyros_user'
  
    def __str__(self):
        return (str(self.name))
  
  
class UserLevel(models.Model):
    name = models.CharField(max_length=45, blank=True, null=True)
    desc = models.TextField(blank=True, null=True)
    priority = models.IntegerField(blank=True, null=True)
    quota = models.FloatField(blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'userlevel'
  
    def __str__(self):
        return (str(self.name))
  
  
class WeatherWatch(models.Model):
    updated = models.DateTimeField(blank=True, null=True)
    humid_int = models.FloatField(blank=True, null=True)
    humid_ext = models.FloatField(blank=True, null=True)
    wind = models.FloatField(blank=True, null=True)
    wind_dir = models.CharField(max_length=1, blank=True, null=True)
    temp_int = models.FloatField(blank=True, null=True)
    temp_ext = models.FloatField(blank=True, null=True)
    pressure = models.FloatField(blank=True, null=True)
    rain = models.FloatField(blank=True, null=True)
    dwn = models.CharField(max_length=45, blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'weatherwatch'
  
    def __str__(self):
        return (str(self.updated))
  
  
class WeatherWatchHistory(models.Model):
    datetime = models.DateTimeField(blank=True, null=True)
    humid_int = models.CharField(max_length=45, blank=True, null=True)
    humid_ext = models.CharField(max_length=45, blank=True, null=True)
    wind = models.CharField(max_length=45, blank=True, null=True)
    wind_dir = models.CharField(max_length=45, blank=True, null=True)
    temp_int = models.CharField(max_length=45, blank=True, null=True)
    temp_ext = models.CharField(max_length=45, blank=True, null=True)
    pressure = models.CharField(max_length=45, blank=True, null=True)
    rain = models.CharField(max_length=45, blank=True, null=True)
    dwn = models.CharField(max_length=45, blank=True, null=True)
  
    class Meta:
        managed = True
        db_table = 'weatherwatchhistory'
  
    def __str__(self):
        return (str(self.datetime))