2021-09-18 21:37:18 +10:00
|
|
|
from django.db import models
|
2021-12-10 03:33:05 +11:00
|
|
|
from datetime import date
|
2021-09-18 21:37:18 +10:00
|
|
|
|
|
|
|
# Create your models here.
|
2021-10-09 20:36:50 +11:00
|
|
|
|
2021-10-09 20:58:50 +11:00
|
|
|
class Page(models.Model):
|
2021-10-09 20:36:50 +11:00
|
|
|
url=models.CharField(max_length=500)
|
|
|
|
title=models.CharField(max_length=100)
|
|
|
|
contents=models.TextField()
|
2021-10-09 23:33:21 +11:00
|
|
|
last_edited=models.DateField(auto_now=True)
|
2021-10-09 20:36:50 +11:00
|
|
|
|
|
|
|
def __str__(self):
|
2021-12-06 16:01:01 +11:00
|
|
|
return self.title
|
|
|
|
|
2021-12-12 19:47:56 +11:00
|
|
|
class Contact(models.Model):
|
2021-12-06 16:01:01 +11:00
|
|
|
name=models.CharField(max_length=100)
|
2021-12-12 19:52:47 +11:00
|
|
|
url=models.CharField(max_length=500,null=True)
|
2021-12-06 16:01:01 +11:00
|
|
|
proto=models.CharField(max_length=100)
|
2021-12-12 19:52:47 +11:00
|
|
|
comment=models.CharField(max_length=100,blank=True)
|
2021-12-12 19:39:26 +11:00
|
|
|
group=models.IntegerField(choices=list({0:'Preferred',1:'Suitable',2:'Discouraged',3:'Ignored',4:'Discontinued',5:'NSFW'}.items()))
|
2021-12-10 03:33:05 +11:00
|
|
|
priority=models.IntegerField()
|
|
|
|
|
|
|
|
def save(self,*args,**kwargs):
|
2021-12-12 19:58:36 +11:00
|
|
|
a,_=Updates.objects.get_or_create(page='contact')
|
2021-12-10 03:33:05 +11:00
|
|
|
a.date=date.today()
|
|
|
|
a.save()
|
2021-12-12 19:47:56 +11:00
|
|
|
super().save(*args,**kwargs)
|
2021-12-12 20:01:10 +11:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.proto+': '+self.name
|
2021-12-10 03:33:05 +11:00
|
|
|
|
|
|
|
class Updates(models.Model):
|
|
|
|
page=models.CharField(max_length=100)
|
|
|
|
date=models.DateField()
|