2017-10-24 21:31:08 -04:00
|
|
|
class Entry:
|
|
|
|
fields = ()
|
|
|
|
|
2017-10-25 18:01:36 -04:00
|
|
|
def has(self, field):
|
|
|
|
return field in self.fields
|
2017-10-24 21:31:08 -04:00
|
|
|
|
2017-10-25 18:01:36 -04:00
|
|
|
def __init__(self, id, plural, icon, fields=()):
|
|
|
|
self.id = id
|
|
|
|
self.plural = plural
|
|
|
|
self.icon = icon
|
|
|
|
self.fields = fields
|
2017-10-24 21:31:08 -04:00
|
|
|
|
2017-10-25 18:01:36 -04:00
|
|
|
@property
|
|
|
|
def index(self):
|
|
|
|
return self.plural + '_index'
|
2017-10-24 21:01:52 -04:00
|
|
|
|
2017-10-25 18:01:36 -04:00
|
|
|
@property
|
|
|
|
def entry(self):
|
|
|
|
return self.plural + '_entry'
|
2017-10-24 21:01:52 -04:00
|
|
|
|
2017-10-25 18:01:36 -04:00
|
|
|
@property
|
|
|
|
def entry_slug(self):
|
|
|
|
return self.entry + '_slug'
|
|
|
|
|
|
|
|
|
|
|
|
Note = Entry(
|
|
|
|
id='note',
|
|
|
|
icon='fa fa-paper-plane',
|
|
|
|
plural='notes',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
Article = Entry(
|
|
|
|
id='article',
|
|
|
|
icon='fa fa-file-text',
|
|
|
|
plural='articles',
|
|
|
|
fields=('slug', 'name'),
|
|
|
|
)
|
2017-10-24 21:01:52 -04:00
|
|
|
|
|
|
|
|
|
|
|
all = (Note, Article)
|
|
|
|
from_id = {k.id: k for k in all}
|
|
|
|
from_plural = {k.plural: k for k in all}
|