示例#1
0
class Submission(models.Model):
    filename = models.FileField(upload_to='submissions/')
    info = models.TextField(default='None')

    timeTaken = models.DecimalField(null=False,
                                    default=0,
                                    decimal_places=4,
                                    max_digits=4)

    late = models.BooleanField(default=False)

    status = EnumField(choices=['start', 'in_progress', 'complete', 'late'])
    result = EnumField(choices=['pass', 'fail', 'error'])
    language = EnumField(
        choices=['python2', 'python3', 'java', 'cpp', 'c', 'ruby'],
        default='python2')

    marks = models.IntegerField(
        validators=[MinValueValidator(0),
                    MaxValueValidator(100)])
    output = models.TextField

    def __str__(self):
        return 'Submission: ' + str(self.id) + '  ' + str(self.filename)

    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             on_delete=models.CASCADE,
                             null=False)
    assessment = models.ForeignKey(Assessment,
                                   on_delete=models.CASCADE,
                                   null=False,
                                   related_name="submissions")

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
示例#2
0
 def test_deconstruct(self):
     field = EnumField(choices=["a", "b"])
     name, path, args, kwargs = field.deconstruct()
     assert path == "django_mysql.models.EnumField"
     assert kwargs["choices"] == [("a", "a"), ("b", "b")]
     assert "max_length" not in kwargs
     EnumField(*args, **kwargs)
示例#3
0
class Submission(models.Model):
    filename = models.FileField(upload_to="submissions/")
    info = models.TextField(default="None")

    timeTaken = models.DecimalField(null=False,
                                    default=0,
                                    decimal_places=4,
                                    max_digits=6)

    late = models.BooleanField(default=False)

    status = EnumField(choices=["start", "in_progress", "complete", "late"])
    result = EnumField(choices=["pass", "fail", "error", "overtime"])
    language = EnumField(
        choices=["python2", "python3", "java", "cpp", "c", "ruby"],
        default="python2")

    marks = models.IntegerField(
        validators=[MinValueValidator(0),
                    MaxValueValidator(100)])
    output = models.TextField

    def __str__(self):
        return "Submission: " + str(self.id) + "  " + str(self.filename)

    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             on_delete=models.CASCADE,
                             null=False)
    assessment = models.ForeignKey(Assessment,
                                   on_delete=models.CASCADE,
                                   null=False,
                                   related_name="submissions")

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
class MPLPurchaseOrder(models.Model):
    class Meta:
        verbose_name = ("MPL Purchase Order")
        verbose_name_plural = ("MPL Purchase Orders")
        ordering = ('supplier__name', )

    supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE)
    purchase_order_no = models.CharField(max_length=20, null=True, blank=True)
    client_purchase_order = models.ForeignKey(ClientPurchaseOrder,
                                              null=True,
                                              blank=True,
                                              on_delete=models.SET_NULL)
    supplier_quotation = models.ForeignKey(SupplierQuotation,
                                           null=True,
                                           blank=True,
                                           on_delete=models.SET_NULL)
    description = models.CharField(max_length=200, null=True, blank=True)
    ordered_by = models.CharField(max_length=100, null=True, blank=True)
    order_date = models.DateTimeField(default=now, null=True, blank=True)
    requested_delivery_date = models.DateTimeField(default=now,
                                                   null=True,
                                                   blank=True)
    actual_delivery_date = models.DateTimeField(default=now,
                                                null=True,
                                                blank=True)
    status = EnumField(choices=MPLPODeliveryStatus, default="PENDING")
    notes = models.CharField(max_length=200, null=True, blank=True)
    currency = EnumField(choices=Currencies, default="USD")
    net_total = models.DecimalField(default=0, max_digits=9, decimal_places=2)

    def __unicode__(self):
        return str(self.supplier) + ' - ' + (str(self.purchase_order_no)
                                             if self.purchase_order_no else '')
示例#5
0
    def test_formfield(self):
        model_field = EnumField(choices=["this", "that"])
        form_field = model_field.formfield()

        assert form_field.clean("this") == "this"
        assert form_field.clean("that") == "that"

        with pytest.raises(ValidationError):
            form_field.clean("")

        with pytest.raises(ValidationError):
            form_field.clean("invalid")
示例#6
0
    def test_formfield(self):
        model_field = EnumField(choices=['this', 'that'])
        form_field = model_field.formfield()

        assert form_field.clean('this') == 'this'
        assert form_field.clean('that') == 'that'

        with pytest.raises(ValidationError):
            form_field.clean('')

        with pytest.raises(ValidationError):
            form_field.clean('invalid')
    def test_formfield(self):
        model_field = EnumField(choices=['this', 'that'])
        form_field = model_field.formfield()

        assert form_field.clean('this') == 'this'
        assert form_field.clean('that') == 'that'

        with pytest.raises(ValidationError):
            form_field.clean('')

        with pytest.raises(ValidationError):
            form_field.clean('invalid')
class PostJobs(models.Model):
    user_account_id = models.ForeignKey(UserAccount,
                                        related_name='user_account_id_post',
                                        on_delete=models.CASCADE,
                                        null=True)
    job_title = models.CharField(max_length=1000, null=True)
    job_role = models.ForeignKey(Designation,
                                 related_name='designations_id_post',
                                 on_delete=models.CASCADE,
                                 null=True)
    job_description = models.CharField(max_length=900, null=True)
    min_experience = models.IntegerField(null=True)
    max_experience = models.IntegerField(null=True)
    is_fresher = models.BooleanField(default=0)
    currency = models.ForeignKey(Currency,
                                 related_name='currency_job_post',
                                 on_delete=models.CASCADE,
                                 null=True)
    min_salary = models.CharField(max_length=45, null=True)
    max_salary = models.CharField(max_length=45, null=True)
    is_salary_visible = models.BooleanField(default=0)
    no_of_vacancies = models.IntegerField(null=True)
    how_soon_required = models.CharField(max_length=100, null=True)
    industries_id = models.ForeignKey(Industries,
                                      related_name='industry_id_post',
                                      on_delete=models.CASCADE,
                                      null=True)
    functional_area_id = models.ForeignKey(
        FunctionalAreas,
        related_name='functional_area_id_post',
        on_delete=models.CASCADE,
        null=True)
    type_of_job = EnumField(choices=[
        "Part time", "Full time", "Part-time work from home",
        "Full-time work from home", "Freelancer"
    ],
                            null=True)
    is_longtime_break = models.BooleanField(default=0)
    reference_code = models.CharField(max_length=10, null=True)
    is_email_response = models.BooleanField(default=1)
    is_email_forward = models.BooleanField(default=0)
    forward_email_id = models.CharField(max_length=320, null=True)
    schedule_time = EnumField(choices=["Week", "Fortnight", "Month"],
                              null=True)
    status = EnumField(choices=["Post", "Draft", "Save"], null=True)
    hire_for = models.CharField(max_length=45, null=True)
    from_count = models.IntegerField(null=True)
    is_phd_premium_university = models.BooleanField(default=0)
    is_graduate_premium_university = models.BooleanField(default=0)
    candidate_profile = models.TextField(null=True)
    created_on = models.DateTimeField(auto_now_add=True)
示例#9
0
class Car(AbstractDateTime):
    mark = models.CharField(max_length=255)
    color = models.CharField(max_length=255, null=True)
    year = models.DateField(null=True)
    engine = models.CharField(max_length=255, null=True)
    seats = EnumField(choices=SEATS, null=True)
    transmission = EnumField(choices=TRANSMISSION)
    categories = EnumField(choices=CATEGORIES)

    def __str__(self):
        return self.mark

    class Meta:
        db_table = 'car'
class CinemaSeat(models.Model):
    seat_number = models.IntegerField()
    type = EnumField(choices=['Basic', 'Executive', 'Premium', 'VIP'])
    cinema_hall = models.ForeignKey(CinemaHall, on_delete=models.CASCADE)

    def __str__(self):
        return f"{self.cinema_hall} {self.type} {self.seat_number}"
示例#11
0
class CoreCommLog(CoreModel):
    NOTIFICATION_TYPE = (
        ('sms', 'sms'),
        ('email', 'email'),
        ('whatsapp', 'whatsapp'),
    )

    comm_type = EnumField(choices=NOTIFICATION_TYPE,
                          default='email',
                          verbose_name='Comm Type')
    user = models.ForeignKey(User, on_delete=models.DO_NOTHING, **dnb)
    provider = models.CharField(max_length=32,
                                **dnb,
                                verbose_name="Service Provider")
    sent_at = models.DateTimeField(editable=False,
                                   **dnb,
                                   verbose_name='Sent At')
    sender = models.CharField(max_length=128)
    to = models.CharField(max_length=512, **dnb)
    cc = models.CharField(max_length=512, **dnb)
    bcc = models.CharField(max_length=512, **dnb)
    subject = models.CharField(max_length=256, **dnb)
    message = models.TextField(**dnb)
    attrs = models.JSONField(**dnb, verbose_name='Attributes')
    status = models.BooleanField(default=False)
    response = models.TextField(**dnb)

    class Meta:
        db_table = 'corelog_comm'
        verbose_name = 'Communication Log'
        verbose_name_plural = 'Communication Log'
示例#12
0
class Hostingprovider(models.Model):
    archived = models.BooleanField(default=False)
    country = CountryField(db_column='countrydomain')
    customer = models.BooleanField(default=False)
    icon = models.CharField(max_length=50, blank=True)
    iconurl = models.CharField(max_length=255, blank=True)
    model = EnumField(choices=ModelType.choices,
                      default=ModelType.compensation)
    name = models.CharField(max_length=255, db_column='naam')
    partner = models.CharField(max_length=255,
                               null=True,
                               default=PartnerChoice.none,
                               choices=PartnerChoice.choices,
                               blank=True)
    showonwebsite = models.BooleanField(verbose_name='Show on website',
                                        default=False)
    website = models.CharField(max_length=255)
    datacenter = models.ManyToManyField('Datacenter',
                                        through='HostingproviderDatacenter',
                                        through_fields=('hostingprovider',
                                                        'datacenter'),
                                        related_name='hostingproviders')

    def __str__(self):
        return self.name

    class Meta:
        # managed = False
        verbose_name = "Hosting Provider"
        db_table = 'hostingproviders'
        indexes = [
            models.Index(fields=['name'], name='name'),
            models.Index(fields=['archived'], name='archived'),
            models.Index(fields=['showonwebsite'], name='showonwebsite'),
        ]
示例#13
0
class PaperAuthor(BaseModel):
    """PaperAuthor Model"""

    # Paper
    paper = models.ForeignKey(
        Paper,
        null=False,
        on_delete=models.CASCADE,
    )

    # Author
    author = models.ForeignKey(
        Author,
        null=False,
        on_delete=models.CASCADE,
    )

    # Author Type
    type = EnumField(choices=PAPER_AUTHOR_TYPE)

    # Rank
    rank = models.PositiveSmallIntegerField()

    class Meta:
        """Table Meta"""
        db_table = 'swpp_paper_author'  # Table 이름
        ordering = ['-pk']  # Default Order
示例#14
0
class Attendance(models.Model):
    present = EnumField(choices=['Yes', 'No'])
    student = models.ForeignKey(User, on_delete=models.CASCADE)
    schedule = models.ForeignKey(Schedule, on_delete=models.CASCADE)

    def __str__(self):
        return self.present
class SupplierQuotation(models.Model):
    class Meta:
        verbose_name = ("Supplier Quotation")
        verbose_name_plural = ("Supplier Quotations")

    supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE)
    quotation_no = models.CharField(max_length=20, null=True, blank=True)
    quotation_date = models.DateTimeField(default=now, null=True, blank=True)
    description = models.CharField(max_length=200, null=True, blank=True)
    status = EnumField(choices=SupplierQuotationStatus, default="UNDER_REVIEW")
    currency = EnumField(choices=Currencies, default="USD")
    net_total = models.DecimalField(default=0, max_digits=9, decimal_places=2)

    def __unicode__(self):
        return str(self.supplier) + ' - ' + (str(self.quotation_no)
                                             if self.quotation_no else '')
示例#16
0
class ProductoCampo(models.Model):
    IDProductoCampo = models.UUIDField(primary_key=True,
                                       default=uuid.uuid4,
                                       editable=False,
                                       unique=True)
    calidad_aprox = EnumField(
        choices=[('e', 'Excelente'), ('b', 'Buena'), ('r',
                                                      'Regular'), ('m',
                                                                   'Mala')])
    fecha_recepcion = models.DateTimeField('dia_creado',
                                           default=datetime.now,
                                           blank=True)
    firma = models.ImageField(upload_to='pic_folder/',
                              default='pic_folder/None/no-img.jpg')
    representante = models.CharField(max_length=100, blank=False, null=False)
    Empleado = models.ForeignKey('Empleado',
                                 on_delete=models.CASCADE,
                                 unique=False,
                                 null=False,
                                 blank=False)
    Productor = models.ForeignKey('Productor',
                                  on_delete=models.CASCADE,
                                  unique=False,
                                  null=False,
                                  blank=False)

    def __str__(self):
        # +" - "+self.fecha_recepcion.strftime('%d/%m/%Y - %X')
        return self.Productor.nombre + " - " + self.Productor.localidad
示例#17
0
class Stats(models.Model):
    checked_through = EnumField(choices=CheckedOptions.choices)
    count = models.IntegerField()
    ips = models.IntegerField()

    class Meta:
        abstract = True
示例#18
0
class Migration(migrations.Migration):

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="EnumDefaultModel",
            fields=[
                (
                    "id",
                    models.AutoField(
                        verbose_name="ID",
                        serialize=False,
                        auto_created=True,
                        primary_key=True,
                    ),
                ),
                (
                    "field",
                    EnumField(choices=[("lion", "Lion"), ("tiger",
                                                          "Tiger"), "bear"]),
                ),
            ],
            options={},
            bases=(models.Model, ),
        )
    ]
示例#19
0
class Publication(BaseModel):
    """Publication Model"""
    # Name
    name = models.CharField(max_length=200)

    # Publication Type
    type = EnumField(choices=PUBLICATION_TYPE)

    # Publisher
    publisher = models.ForeignKey(
        Publisher,
        null=False,
        on_delete=models.CASCADE,
    )

    # Papers
    papers = models.ManyToManyField(
        Paper,
        through='PaperPublication',
        through_fields=('publication', 'paper')
    )

    class Meta:
        """Table Meta"""
        db_table = 'swpp_publication'  # Table 이름
        ordering = ['-pk']  # Default Order

    def __str__(self):
        return self.name
示例#20
0
class NullableEnumModel(Model):
    field = EnumField(choices=[
        'goat',
        ('deer', 'Deer'),
        'bull',
        "dog's",   # Test if escaping works
    ], null=True)
示例#21
0
class EnumModel(Model):
    field = EnumField(choices=[
        ('red', 'Red'),
        ('bloodred', 'Blood Red'),
        'green',
        ('blue', 'Navy Blue'),
        ('coralblue', 'Coral Blue'),
    ])
示例#22
0
class VnfPkgInfo(models.Model):
    id = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4)
    vnfdId = models.TextField(null=True, blank=True)
    vnfProvider = models.TextField(null=True, blank=True)
    vnfProductName = models.TextField(null=True, blank=True)
    vnfSoftwareVersion = models.TextField(null=True, blank=True)
    vnfdVersion = models.TextField(null=True, blank=True)
    onboardingState = EnumField(choices=["CREATED", "UPLOADING ", "PROCESSING ", "ONBOARDED"], default="CREATED")
    operationalState = EnumField(choices=["ENABLED", "DISABLED"], default="DISABLED") 
    usageState = EnumField(choices=["IN_USE", "NOT_IN_USE"], default="NOT_IN_USE")
    userDefinedData = models.TextField(null=True, blank=True)

    class Meta:
        db_table = "VnfPkgInfo"

    def __str__(self):
        return str(self.id)
示例#23
0
class EnumModel(Model):
    field = EnumField(choices=[
        ("red", "Red"),
        ("bloodred", "Blood Red"),
        "green",
        ("blue", "Navy Blue"),
        ("coralblue", "Coral Blue"),
    ])
示例#24
0
class Data (models.Model):
    name = models.CharField(max_length=50)
    age = models.IntegerField()
    gender = EnumField(choices=['female', 'male'])
    phone = models.CharField(max_length=20)
    email = models.CharField(max_length=100)
    created_at = models.DateTimeField(auto_now_add=True)
    file = models.ForeignKey(FilesData, on_delete=models.CASCADE)
示例#25
0
class BookingInvoice(AbstractDateTime):
    booking = models.OneToOneField(Booking, on_delete=models.SET_NULL, null=True)
    status = EnumField(choices=INVOICE_STATUS)
    price = models.DecimalField(decimal_places=2, max_digits=10, validators=[MinValueValidator(1.0)])
    note = models.CharField(max_length=1024)

    class Meta:
        db_table = 'invoice'
示例#26
0
class Video(models.Model):
    title = models.TextField()
    description = models.TextField(null=False)
    thumbnails = jsonfield.JSONField(help_text='Storing thumbnails for videos', default=dict)
    source = EnumField(choices=[AppConstants.VIDEO_SOURCE_YOUTUBE], default=AppConstants.VIDEO_SOURCE_YOUTUBE, db_index=True)
    video_id = models.CharField(max_length=200, null=True)
    published_at = models.DateTimeField(null=False, default=timezone.now())
    created_at = models.DateTimeField(auto_now=True)
示例#27
0
class WebsiteJob(models.Model):
    id = models.AutoField(primary_key=True)
    job_type = models.IntegerField()
    status = EnumField(
        choices=['unprocessed', 'pending', 'working', 'finished', 'error'])
    website = models.ForeignKey(Website, on_delete=models.CASCADE)

    class Meta:
        db_table = 'website_jobs'
示例#28
0
class Cobertura(models.Model):
    id_cobertura = models.AutoField(primary_key=True)
    cobertura_estado = EnumField(choices=['completa', 'incompleta'])
    id_plan = models.ForeignKey('Plan', models.DO_NOTHING, db_column='id_plan')
    porcent_cob_total = models.IntegerField()

    class Meta:
        managed = True
        db_table = 'cobertura'
示例#29
0
class Greencheck(models.Model):
    hostingprovider = models.ForeignKey(Hostingprovider,
                                        db_column='id_hp',
                                        on_delete=models.CASCADE)
    greencheck_ip = models.ForeignKey(GreencheckIp,
                                      on_delete=models.CASCADE,
                                      db_column='id_greencheck')
    date = UnixDateTimeField(db_column='datum')
    green = EnumField(choices=BoolChoice.choices)
    ip = IpAddressField()
    tld = models.CharField(max_length=64)
    type = EnumField(choices=GreenlistChoice.choices)
    url = models.CharField(max_length=255)

    class Meta:
        db_table = 'greencheck_2020'

    def __str__(self):
        return f'{self.url} - {self.ip}'
示例#30
0
class Resource(models.Model):
    filename = models.FileField(upload_to='resources/')

    status = EnumField(choices=['start', 'in_progress', 'complete'])
    language = EnumField(
        choices=['python2', 'python3', 'java', 'cpp', 'c', 'ruby'],
        default='python2')

    def __str__(self):
        return 'Resource: ' + str(self.id) + '  ' + str(self.filename)

    assessment = models.ForeignKey('Assessment',
                                   on_delete=models.CASCADE,
                                   null=False,
                                   default=None,
                                   related_name="resources")

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
示例#31
0
class Biblioteca(models.Model):
    id_biblioteca = models.IntegerField(primary_key=True)
    nombre = models.CharField(max_length=100)
    direccion = models.CharField(max_length=150)
    telefono = models.IntegerField()
    biblioteca = EnumField(choices=['campus', 'sede'])

    class Meta:
        managed = True
        db_table = 'biblioteca'
 def test_deconstruct(self):
     field = EnumField(choices=['a', 'b'])
     name, path, args, kwargs = field.deconstruct()
     assert path == 'django_mysql.models.EnumField'
     assert 'max_length' not in kwargs
     EnumField(*args, **kwargs)