rakkapy/main/models.py

43 lines
1.3 KiB
Python
Raw Normal View History

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
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
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)
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)
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)
date=models.DateField(default=now)
class Redirect(models.Model):
match=models.CharField(max_length=200)
output=models.CharField(max_length=500)