29 lines
927 B
Python
29 lines
927 B
Python
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)
|
|
|
|
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']
|