Skip to content

Commit

Permalink
feat: gallery, well
Browse files Browse the repository at this point in the history
  • Loading branch information
hUwUtao committed May 15, 2024
1 parent 3d0db6c commit 5df3714
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 6 deletions.
26 changes: 22 additions & 4 deletions blog/migrations/0001_testphase_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@


class Migration(migrations.Migration):

replaces = [('blog', '0001_initial'), ('blog', '0002_blogpage_delete_blogindexpage'), ('blog', '0003_blogpage_thumb')]
replaces = [
('blog', '0001_initial'),
('blog', '0002_blogpage_delete_blogindexpage'),
('blog', '0003_blogpage_thumb'),
]

dependencies = [
('wagtailcore', '0083_workflowcontenttype'),
Expand All @@ -17,11 +20,26 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='BlogPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
(
'page_ptr',
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to='wagtailcore.page',
),
),
('date', models.DateField(verbose_name='Post date')),
('intro', models.CharField(max_length=250)),
('body', wagtail.fields.RichTextField(blank=True)),
('thumb', models.ImageField(blank=True, upload_to='', verbose_name='Thumbnail')),
(
'thumb',
models.ImageField(
blank=True, upload_to='', verbose_name='Thumbnail'
),
),
],
options={
'abstract': False,
Expand Down
2 changes: 1 addition & 1 deletion fuhoblog/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# The second parameter is the endpoint class that handles the requests
api_router.register_endpoint('pages', PagesAPIViewSet)
api_router.register_endpoint('images', ImagesAPIViewSet)
api_router.register_endpoint('documents', DocumentsAPIViewSet)
api_router.register_endpoint('documents', DocumentsAPIViewSet)
1 change: 1 addition & 0 deletions fuhoblog/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# MVC stuff
'blog',
'search',
'gallery',
# Stuff
'wagtail.locales',
# API engine
Expand Down
Empty file added gallery/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions gallery/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions gallery/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class GalleryConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'gallery'
41 changes: 41 additions & 0 deletions gallery/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 4.2.13 on 2024-05-15 16:55

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
initial = True

dependencies = [
('wagtailcore', '0093_uploadedfile'),
]

operations = [
migrations.CreateModel(
name='Picture',
fields=[
(
'page_ptr',
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to='wagtailcore.page',
),
),
('date', models.DateField(verbose_name='Post Date')),
(
'image',
models.ImageField(blank=True, upload_to='', verbose_name='Picture'),
),
('cap', models.CharField(max_length=1024, verbose_name='Caption')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]
Empty file added gallery/migrations/__init__.py
Empty file.
39 changes: 39 additions & 0 deletions gallery/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from django.db import models
from wagtail.models import Page
from wagtail.admin.panels import FieldPanel
from wagtail.api import APIField

from rest_framework.fields import DateField

# add this:
from wagtail.search import index

# keep the definition of BlogIndexPage model, and add the BlogPage model:


class Picture(Page):
date = models.DateField('Post Date')
image = models.ImageField('Picture', blank=True)
cap = models.CharField('Caption', max_length=1024)

search_fields = Page.search_fields + [
index.SearchField('cap'),
]

content_panels = Page.content_panels + [
FieldPanel('date'),
FieldPanel('cap'),
FieldPanel('image'),
]

api_fields = [
APIField(
'date',
serializer=DateField(format='%Y-%m-%dT%H:%M:%SZ'),
),
APIField('cap'),
APIField('image'),
# APIField(
# 'authors'
# ), # This will nest the relevant BlogPageAuthor objects in the API response
]
3 changes: 3 additions & 0 deletions gallery/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
2 changes: 1 addition & 1 deletion search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def search(request):
# },
# )

pass
pass

0 comments on commit 5df3714

Please sign in to comment.