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
|
2022-01-26 19:51:03 +11:00
|
|
|
from django.utils.timezone import now
|
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)
|
2022-01-02 22:04:47 +11:00
|
|
|
renders=models.BooleanField(default=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 20:15:19 +11:00
|
|
|
url=models.CharField(max_length=500,blank=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 21:52:02 +11:00
|
|
|
groups={0:'Preferred',1:'Suitable',2:'Discouraged',3:'Ignored',4:'Discontinued',5:'NSFW'}
|
|
|
|
group=models.IntegerField(choices=list(groups.items()))
|
2021-12-10 03:33:05 +11:00
|
|
|
priority=models.IntegerField()
|
2021-12-24 12:01:00 +11:00
|
|
|
desktop=models.BooleanField(default=True)
|
|
|
|
mobile=models.BooleanField(default=True)
|
2021-12-10 03:33:05 +11:00
|
|
|
|
|
|
|
def save(self,*args,**kwargs):
|
2021-12-12 21:52:02 +11:00
|
|
|
a,_=Update.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
|
|
|
|
2021-12-12 21:23:42 +11:00
|
|
|
class Update(models.Model):
|
2021-12-10 03:33:05 +11:00
|
|
|
page=models.CharField(max_length=100)
|
2022-01-26 19:51:03 +11:00
|
|
|
date=models.DateField(default=now)
|
2022-01-02 22:04:47 +11:00
|
|
|
|
|
|
|
class Redirect(models.Model):
|
|
|
|
match=models.CharField(max_length=200)
|
2022-02-27 23:23:26 +11:00
|
|
|
output=models.CharField(max_length=500)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.match
|