Compare commits

..

No commits in common. "34085a3882e0dd61734125cb91733f50b1f740a7" and "025f8fdf41041f394a7bbc95070e7150e3a8f710" have entirely different histories.

3 changed files with 14 additions and 20 deletions

View File

@ -2,7 +2,7 @@ from django.contrib import admin
# Register your models here. # Register your models here.
from .models import Page,Contact,Update from .models import Page,Contact,Updates
admin.site.register(Page) admin.site.register(Page)
admin.site.register(Contact) admin.site.register(Contact)
admin.site.register(Update) admin.site.register(Updates)

View File

@ -17,12 +17,11 @@ class Contact(models.Model):
url=models.CharField(max_length=500,blank=True) url=models.CharField(max_length=500,blank=True)
proto=models.CharField(max_length=100) proto=models.CharField(max_length=100)
comment=models.CharField(max_length=100,blank=True) comment=models.CharField(max_length=100,blank=True)
groups={0:'Preferred',1:'Suitable',2:'Discouraged',3:'Ignored',4:'Discontinued',5:'NSFW'} group=models.IntegerField(choices=list({0:'Preferred',1:'Suitable',2:'Discouraged',3:'Ignored',4:'Discontinued',5:'NSFW'}.items()))
group=models.IntegerField(choices=list(groups.items()))
priority=models.IntegerField() priority=models.IntegerField()
def save(self,*args,**kwargs): def save(self,*args,**kwargs):
a,_=Update.objects.get_or_create(page='contact') a,_=Updates.objects.get_or_create(page='contact')
a.date=date.today() a.date=date.today()
a.save() a.save()
super().save(*args,**kwargs) super().save(*args,**kwargs)
@ -30,6 +29,6 @@ class Contact(models.Model):
def __str__(self): def __str__(self):
return self.proto+': '+self.name return self.proto+': '+self.name
class Update(models.Model): class Updates(models.Model):
page=models.CharField(max_length=100) page=models.CharField(max_length=100)
date=models.DateField() date=models.DateField()

View File

@ -4,7 +4,7 @@ from django.template import loader
import random as ra import random as ra
import asyncio import asyncio
from . import mdl from . import mdl
from .models import Page,Contact,Update from .models import Page,Contact,Updates
import functools import functools
@ -56,27 +56,22 @@ def index():
stuff=stuff.format(ra.choice(ids)) stuff=stuff.format(ra.choice(ids))
return {'title':'Home','content':stuff,'date':'2021/09/20'} return {'title':'Home','content':stuff,'date':'2021/09/20'}
def lii(obj): def lii(name,proto,link='',note=''):
name=obj.name if link: name=f"<a href='{link}'>{name}</a>"
if obj.url: name=f"<a href='{obj.url}'>{name}</a>" if note: name=f"{name} ({note})"
if obj.comment: name=f"{name} ({obj.comment})" return f"\n<li>{proto}: {name}</li>"
return f"<li>{obj.proto}: {name}</li>"
@rerender @rerender
def contact(): def contact():
head="Certain people keep asking me about the best ways to contact me. So here they are, in rough order of most to least preferred. More to come as I remember them/feel like it<br/>" head="Certain people keep asking me about the best ways to contact me. So here they are, in rough order of most to least preferred. More to come as I remember them/feel like it<br/>"
contacts=sorted(models.Contact.objects.all(),key=lambda x:(x.group,x.priority)) out=parsecat('contacts',4)
out={}
for n in contacts:
if n.group in out: out[n.group].append(n)
else: out[n.group]=[n]
out3='' out3=''
for k,v in out.items(): for k,v in out.items():
out2=f"\n<p><h4>{Contact.groups[k]}</h4>\n<ul>" out2=f"\n<p><h4>{k}</h4>\n<ul>"
out2+='\n'.join(map(lii,v)) out2+='\n'.join([lii(*l) for l in v])
out2+="\n</ul></p>" out2+="\n</ul></p>"
out3+=out2 out3+=out2
return {'title':'Contact','content':head+out3,'date':Update.objects.get(page='contact').date} return {'title':'Contact','content':head+out3,'date':Updates.objects.get(page='contact').date}
def specs(req): def specs(req):
with open('main/pages/specs') as b: with open('main/pages/specs') as b: