Compare commits
2 Commits
025f8fdf41
...
34085a3882
Author | SHA1 | Date | |
---|---|---|---|
34085a3882 | |||
e80bbc2329 |
|
@ -2,7 +2,7 @@ from django.contrib import admin
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
|
||||||
from .models import Page,Contact,Updates
|
from .models import Page,Contact,Update
|
||||||
admin.site.register(Page)
|
admin.site.register(Page)
|
||||||
admin.site.register(Contact)
|
admin.site.register(Contact)
|
||||||
admin.site.register(Updates)
|
admin.site.register(Update)
|
|
@ -17,11 +17,12 @@ 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)
|
||||||
group=models.IntegerField(choices=list({0:'Preferred',1:'Suitable',2:'Discouraged',3:'Ignored',4:'Discontinued',5:'NSFW'}.items()))
|
groups={0:'Preferred',1:'Suitable',2:'Discouraged',3:'Ignored',4:'Discontinued',5:'NSFW'}
|
||||||
|
group=models.IntegerField(choices=list(groups.items()))
|
||||||
priority=models.IntegerField()
|
priority=models.IntegerField()
|
||||||
|
|
||||||
def save(self,*args,**kwargs):
|
def save(self,*args,**kwargs):
|
||||||
a,_=Updates.objects.get_or_create(page='contact')
|
a,_=Update.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)
|
||||||
|
@ -29,6 +30,6 @@ class Contact(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.proto+': '+self.name
|
return self.proto+': '+self.name
|
||||||
|
|
||||||
class Updates(models.Model):
|
class Update(models.Model):
|
||||||
page=models.CharField(max_length=100)
|
page=models.CharField(max_length=100)
|
||||||
date=models.DateField()
|
date=models.DateField()
|
|
@ -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,Updates
|
from .models import Page,Contact,Update
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
|
@ -56,22 +56,27 @@ 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(name,proto,link='',note=''):
|
def lii(obj):
|
||||||
if link: name=f"<a href='{link}'>{name}</a>"
|
name=obj.name
|
||||||
if note: name=f"{name} ({note})"
|
if obj.url: name=f"<a href='{obj.url}'>{name}</a>"
|
||||||
return f"\n<li>{proto}: {name}</li>"
|
if obj.comment: name=f"{name} ({obj.comment})"
|
||||||
|
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/>"
|
||||||
out=parsecat('contacts',4)
|
contacts=sorted(models.Contact.objects.all(),key=lambda x:(x.group,x.priority))
|
||||||
|
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>{k}</h4>\n<ul>"
|
out2=f"\n<p><h4>{Contact.groups[k]}</h4>\n<ul>"
|
||||||
out2+='\n'.join([lii(*l) for l in v])
|
out2+='\n'.join(map(lii,v))
|
||||||
out2+="\n</ul></p>"
|
out2+="\n</ul></p>"
|
||||||
out3+=out2
|
out3+=out2
|
||||||
return {'title':'Contact','content':head+out3,'date':Updates.objects.get(page='contact').date}
|
return {'title':'Contact','content':head+out3,'date':Update.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:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user