Compare commits
No commits in common. "34085a3882e0dd61734125cb91733f50b1f740a7" and "025f8fdf41041f394a7bbc95070e7150e3a8f710" have entirely different histories.
34085a3882
...
025f8fdf41
|
@ -2,7 +2,7 @@ from django.contrib import admin
|
|||
|
||||
# Register your models here.
|
||||
|
||||
from .models import Page,Contact,Update
|
||||
from .models import Page,Contact,Updates
|
||||
admin.site.register(Page)
|
||||
admin.site.register(Contact)
|
||||
admin.site.register(Update)
|
||||
admin.site.register(Updates)
|
|
@ -17,12 +17,11 @@ class Contact(models.Model):
|
|||
url=models.CharField(max_length=500,blank=True)
|
||||
proto=models.CharField(max_length=100)
|
||||
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(groups.items()))
|
||||
group=models.IntegerField(choices=list({0:'Preferred',1:'Suitable',2:'Discouraged',3:'Ignored',4:'Discontinued',5:'NSFW'}.items()))
|
||||
priority=models.IntegerField()
|
||||
|
||||
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.save()
|
||||
super().save(*args,**kwargs)
|
||||
|
@ -30,6 +29,6 @@ class Contact(models.Model):
|
|||
def __str__(self):
|
||||
return self.proto+': '+self.name
|
||||
|
||||
class Update(models.Model):
|
||||
class Updates(models.Model):
|
||||
page=models.CharField(max_length=100)
|
||||
date=models.DateField()
|
|
@ -4,7 +4,7 @@ from django.template import loader
|
|||
import random as ra
|
||||
import asyncio
|
||||
from . import mdl
|
||||
from .models import Page,Contact,Update
|
||||
from .models import Page,Contact,Updates
|
||||
|
||||
import functools
|
||||
|
||||
|
@ -56,27 +56,22 @@ def index():
|
|||
stuff=stuff.format(ra.choice(ids))
|
||||
return {'title':'Home','content':stuff,'date':'2021/09/20'}
|
||||
|
||||
def lii(obj):
|
||||
name=obj.name
|
||||
if obj.url: name=f"<a href='{obj.url}'>{name}</a>"
|
||||
if obj.comment: name=f"{name} ({obj.comment})"
|
||||
return f"<li>{obj.proto}: {name}</li>"
|
||||
def lii(name,proto,link='',note=''):
|
||||
if link: name=f"<a href='{link}'>{name}</a>"
|
||||
if note: name=f"{name} ({note})"
|
||||
return f"\n<li>{proto}: {name}</li>"
|
||||
|
||||
@rerender
|
||||
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/>"
|
||||
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]
|
||||
out=parsecat('contacts',4)
|
||||
out3=''
|
||||
for k,v in out.items():
|
||||
out2=f"\n<p><h4>{Contact.groups[k]}</h4>\n<ul>"
|
||||
out2+='\n'.join(map(lii,v))
|
||||
out2=f"\n<p><h4>{k}</h4>\n<ul>"
|
||||
out2+='\n'.join([lii(*l) for l in v])
|
||||
out2+="\n</ul></p>"
|
||||
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):
|
||||
with open('main/pages/specs') as b:
|
||||
|
|
Loading…
Reference in New Issue
Block a user