2023-10-24 12:55:14 +00:00
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
|
|
|
class Candidate(models.Model):
|
|
|
|
name = models.CharField('Candidate name', max_length=50)
|
|
|
|
slug = models.SlugField(max_length=50, unique=True)
|
|
|
|
vendor = models.CharField('Vendor name', max_length=50)
|
|
|
|
device = models.CharField('Device name', max_length=50)
|
|
|
|
release_date = models.DateField()
|
|
|
|
description = models.TextField()
|
|
|
|
source_url = models.URLField()
|
|
|
|
binary_url = models.URLField(blank=True)
|
2023-10-30 22:31:28 +00:00
|
|
|
ordering = models.SmallIntegerField(default=0)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ['ordering', 'name']
|
2023-10-24 12:55:14 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class Comment(models.Model):
|
|
|
|
candidate = models.ForeignKey(Candidate, on_delete=models.CASCADE)
|
|
|
|
user = models.ForeignKey(User, on_delete=models.PROTECT)
|
|
|
|
time = models.DateTimeField(auto_now_add=True)
|
|
|
|
message = models.TextField()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f'{self.candidate.name}, {self.user}, {self.time}'
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ['id']
|