forked from external/museum

zhangxiaoyong
2023-02-23 149d2037a576c52f30f80835e89ca988701b2233
添加后台修改模版
21 files added
1 files modified
176 ■■■■■ changed files
museum/backend/__init__.py patch | view | raw | blame | history
museum/backend/admin.py 3 ●●●●● patch | view | raw | blame | history
museum/backend/apps.py 6 ●●●●● patch | view | raw | blame | history
museum/backend/migrations/__init__.py patch | view | raw | blame | history
museum/backend/models.py 51 ●●●●● patch | view | raw | blame | history
museum/backend/templates/wagtailadmin/404.html 6 ●●●●● patch | view | raw | blame | history
museum/backend/templates/wagtailadmin/admin_base.html 8 ●●●●● patch | view | raw | blame | history
museum/backend/templates/wagtailadmin/base.html 6 ●●●●● patch | view | raw | blame | history
museum/backend/templates/wagtailadmin/home.html 3 ●●●●● patch | view | raw | blame | history
museum/backend/templates/wagtailadmin/login.html 3 ●●●●● patch | view | raw | blame | history
museum/backend/templates/wagtailadmin/userbar/base.html 6 ●●●●● patch | view | raw | blame | history
museum/backend/tests.py 3 ●●●●● patch | view | raw | blame | history
museum/backend/views.py 3 ●●●●● patch | view | raw | blame | history
museum/backend/wagtail_hooks.py 58 ●●●●● patch | view | raw | blame | history
museum/base/__init__.py patch | view | raw | blame | history
museum/base/admin.py 3 ●●●●● patch | view | raw | blame | history
museum/base/apps.py 6 ●●●●● patch | view | raw | blame | history
museum/base/migrations/__init__.py patch | view | raw | blame | history
museum/base/models.py 3 ●●●●● patch | view | raw | blame | history
museum/base/tests.py 3 ●●●●● patch | view | raw | blame | history
museum/base/views.py 3 ●●●●● patch | view | raw | blame | history
museum/settings/base.py 2 ●●●●● patch | view | raw | blame | history
museum/backend/__init__.py
museum/backend/admin.py
New file
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
museum/backend/apps.py
New file
@@ -0,0 +1,6 @@
from django.apps import AppConfig
class BackendConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'museum.backend'
museum/backend/migrations/__init__.py
museum/backend/models.py
New file
@@ -0,0 +1,51 @@
from django.db import models
from wagtail.admin.panels import FieldPanel
from wagtail.images.edit_handlers import ImageChooserPanel
class Book(models.Model):
    title = models.CharField(max_length=255)
    author = models.CharField(max_length=255)
    cover_photo = models.ForeignKey(
        'wagtailimages.Image',
        on_delete=models.CASCADE,
        related_name='+'
    )
    panels = [
        FieldPanel('title'),
        FieldPanel('author'),
        ImageChooserPanel('cover_photo')
    ]
class Genre(models.Model):
    title = models.CharField(max_length=255)
    author = models.CharField(max_length=255)
    cover_photo = models.ForeignKey(
        'wagtailimages.Image',
        on_delete=models.CASCADE,
        related_name='+'
    )
    panels = [
        FieldPanel('title'),
        FieldPanel('author'),
        ImageChooserPanel('cover_photo')
    ]
class Author(models.Model):
    title = models.CharField(max_length=255)
    author = models.CharField(max_length=255)
    cover_photo = models.ForeignKey(
        'wagtailimages.Image',
        on_delete=models.CASCADE,
        related_name='+'
    )
    panels = [
        FieldPanel('title'),
        FieldPanel('author'),
        ImageChooserPanel('cover_photo')
    ]
museum/backend/templates/wagtailadmin/404.html
New file
@@ -0,0 +1,6 @@
{% extends "wagtailadmin/base.html" %}
{% load static %}
{% block branding_logo %}
{#    <img src="{% static 'images/custom-logo.svg' %}" alt="Custom Project" width="80" />#}
{% endblock %}
museum/backend/templates/wagtailadmin/admin_base.html
New file
@@ -0,0 +1,8 @@
{% extends "wagtailadmin/admin_base.html" %}
{% load static %}
{% block branding_favicon %}
{#    <link rel="shortcut icon" href="{% static 'images/favicon.ico' %}" />#}
{% endblock %}
{% block branding_title %}museum{% endblock %}
museum/backend/templates/wagtailadmin/base.html
New file
@@ -0,0 +1,6 @@
{% extends "wagtailadmin/base.html" %}
{% load static %}
{#{% block branding_logo %}#}
{#    <img src="{% static 'images/custom-logo.svg' %}" alt="Custom Project" width="80" />#}
{#{% endblock %}#}
museum/backend/templates/wagtailadmin/home.html
New file
@@ -0,0 +1,3 @@
{% extends "wagtailadmin/home.html" %}
{% block branding_welcome %} 你好{% endblock %}
museum/backend/templates/wagtailadmin/login.html
New file
@@ -0,0 +1,3 @@
{% extends "wagtailadmin/login.html" %}
{% block branding_login %}对方的 {% endblock %}
museum/backend/templates/wagtailadmin/userbar/base.html
New file
@@ -0,0 +1,6 @@
{% extends "wagtailadmin/base.html" %}
{% load static %}
{#{% block branding_logo %}#}
{#    <img src="{% static 'images/custom-logo.svg' %}" alt="Custom Project" width="80" />#}
{#{% endblock %}#}
museum/backend/tests.py
New file
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
museum/backend/views.py
New file
@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.
museum/backend/wagtail_hooks.py
New file
@@ -0,0 +1,58 @@
from wagtail.contrib.modeladmin.options import (
    ModelAdmin, modeladmin_register, ModelAdminGroup)
from wagtail.core import hooks
from .models import Book, Author, Genre
@hooks.register('construct_main_menu')
def hide_images_menu_item(request, menu_items):
    menu_items[:] = [item for item in menu_items if item.name != 'help']
# @hooks.register('construct_settings_menu')
# def hide_user_menu_item(request, menu_items):
#     menu_items[:] = [item for item in menu_items if item.name != 'user']
class BookAdmin(ModelAdmin):
    model = Book
    menu_label = 'Book'  # ditch this to use verbose_name_plural from model
    menu_icon = 'pilcrow'  # change as required
    # menu_order = 3000  # will put in 3rd place (000 being 1st, 100 2nd)
    # add_to_settings_menu = True  # or True to add your model to the Settings sub-menu
    # exclude_from_explorer = True  # or True to exclude pages of this type from Wagtail's explorer view
    list_display = ('title', 'author', 'cover_photo')
    list_filter = ('author',)
    search_fields = ('title', 'author')
class AuthorAdmin(ModelAdmin):
    model = Author
    menu_label = 'Author'  # ditch this to use verbose_name_plural from model
    menu_icon = 'user'  # change as required
    list_display = ('first_name', 'last_name')
    list_filter = ('first_name', 'last_name')
    search_fields = ('first_name', 'last_name')
class GenreAdmin(ModelAdmin):
    model = Genre
    menu_label = 'Genre'  # ditch this to use verbose_name_plural from model
    menu_icon = 'group'  # change as required
    list_display = ('name',)
    list_filter = ('name',)
    search_fields = ('name',)
class LibraryGroup(ModelAdminGroup):
    menu_label = 'Library'
    menu_icon = 'folder-open-inverse'  # change as required
    menu_order = 2000  # will put in 3rd place (000 being 1st, 100 2nd)
    items = (BookAdmin, AuthorAdmin, GenreAdmin)
# Now you just need to register your customised ModelAdmin class with Wagtail
# modeladmin_register(LibraryGroup)
# modeladmin_register(BookAdmin)
# modeladmin_register(AuthorAdmin)
# modeladmin_register(GenreAdmin)
museum/base/__init__.py
museum/base/admin.py
New file
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
museum/base/apps.py
New file
@@ -0,0 +1,6 @@
from django.apps import AppConfig
class BaseConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'museum.base'
museum/base/migrations/__init__.py
museum/base/models.py
New file
@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.
museum/base/tests.py
New file
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
museum/base/views.py
New file
@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.
museum/settings/base.py
@@ -31,6 +31,8 @@
    "museum.exhibition",
    "museum.education",
    "museum.information",
    "museum.backend",
    "museum.base",
    "wagtail.contrib.forms",
    "wagtail.contrib.redirects",
    "wagtail.embeds",