added ability to display message to users (via admin)
This commit is contained in:
parent
312c364797
commit
73f13f56e1
@ -2,6 +2,13 @@ from django.contrib import admin
|
|||||||
from .models import *
|
from .models import *
|
||||||
|
|
||||||
|
|
||||||
|
class SpaceAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('name', 'message')
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(Space, SpaceAdmin)
|
||||||
|
|
||||||
|
|
||||||
class UserPreferenceAdmin(admin.ModelAdmin):
|
class UserPreferenceAdmin(admin.ModelAdmin):
|
||||||
list_display = ('name', 'theme', 'nav_color', 'default_page', 'search_style', 'comments')
|
list_display = ('name', 'theme', 'nav_color', 'default_page', 'search_style', 'comments')
|
||||||
|
|
||||||
|
21
cookbook/migrations/0083_space.py
Normal file
21
cookbook/migrations/0083_space.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Generated by Django 3.0.7 on 2020-09-22 10:24
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('cookbook', '0082_auto_20200922_1143'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Space',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(default='Default', max_length=128)),
|
||||||
|
('message', models.CharField(default='', max_length=512)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
21
cookbook/migrations/0084_auto_20200922_1233.py
Normal file
21
cookbook/migrations/0084_auto_20200922_1233.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Generated by Django 3.0.7 on 2020-09-22 10:33
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
def create_default_space(apps, schema_editor):
|
||||||
|
Space = apps.get_model('cookbook', 'Space')
|
||||||
|
Space.objects.create(
|
||||||
|
name='Default',
|
||||||
|
message=''
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
('cookbook', '0083_space'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(create_default_space),
|
||||||
|
]
|
18
cookbook/migrations/0085_auto_20200922_1235.py
Normal file
18
cookbook/migrations/0085_auto_20200922_1235.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.0.7 on 2020-09-22 10:35
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('cookbook', '0084_auto_20200922_1233'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='space',
|
||||||
|
name='message',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=512),
|
||||||
|
),
|
||||||
|
]
|
@ -25,6 +25,11 @@ def get_model_name(model):
|
|||||||
return ('_'.join(re.findall('[A-Z][^A-Z]*', model.__name__))).lower()
|
return ('_'.join(re.findall('[A-Z][^A-Z]*', model.__name__))).lower()
|
||||||
|
|
||||||
|
|
||||||
|
class Space(models.Model):
|
||||||
|
name = models.CharField(max_length=128, default='Default')
|
||||||
|
message = models.CharField(max_length=512, default='', blank=True)
|
||||||
|
|
||||||
|
|
||||||
class UserPreference(models.Model):
|
class UserPreference(models.Model):
|
||||||
# Themes
|
# Themes
|
||||||
BOOTSTRAP = 'BOOTSTRAP'
|
BOOTSTRAP = 'BOOTSTRAP'
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load theming_tags %}
|
{% load theming_tags %}
|
||||||
|
{% load custom_tags %}
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@ -158,6 +159,14 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
{% message_of_the_day as message_of_the_day %}
|
||||||
|
{% if message_of_the_day %}
|
||||||
|
<div class="bg-warning" style=" width: 100%; text-align: center!important; color: #ffffff; padding: 8px">
|
||||||
|
{{ message_of_the_day }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from django.urls import reverse, NoReverseMatch
|
|||||||
|
|
||||||
from cookbook.helper.mdx_attributes import MarkdownFormatExtension
|
from cookbook.helper.mdx_attributes import MarkdownFormatExtension
|
||||||
from cookbook.helper.mdx_urlize import UrlizeExtension
|
from cookbook.helper.mdx_urlize import UrlizeExtension
|
||||||
from cookbook.models import get_model_name
|
from cookbook.models import get_model_name, Space
|
||||||
from recipes import settings
|
from recipes import settings
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
@ -69,6 +69,11 @@ def recipe_last(recipe, user):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def message_of_the_day():
|
||||||
|
return Space.objects.first().message
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def is_debug():
|
def is_debug():
|
||||||
return settings.DEBUG
|
return settings.DEBUG
|
||||||
|
Loading…
Reference in New Issue
Block a user