Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f22e365db1
|
@ -104,7 +104,7 @@ ASGI_APPLICATION = 'NewMediaMonitoring.routing.application'
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
'NAME': 'nmm',
|
'NAME': 'newmediaDB1',
|
||||||
'USER': 'newmedia',
|
'USER': 'newmedia',
|
||||||
'PASSWORD': 'newmedia2020!@#',
|
'PASSWORD': 'newmedia2020!@#',
|
||||||
'HOST': '210.77.68.250',
|
'HOST': '210.77.68.250',
|
||||||
|
|
|
@ -2,6 +2,16 @@ from django.db import models
|
||||||
import uuid
|
import uuid
|
||||||
import datetime
|
import datetime
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.db import models
|
||||||
|
from modelcluster.fields import ParentalKey, ParentalManyToManyField
|
||||||
|
|
||||||
|
from wagtail.core.models import Page, Orderable
|
||||||
|
from wagtail.core.models import Page
|
||||||
|
from wagtail.core.fields import RichTextField
|
||||||
|
from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanel
|
||||||
|
from wagtail.images.edit_handlers import ImageChooserPanel
|
||||||
|
from wagtail.snippets.models import register_snippet
|
||||||
|
|
||||||
|
|
||||||
from dashboard.models import Group
|
from dashboard.models import Group
|
||||||
|
|
||||||
|
@ -84,17 +94,71 @@ class URLMessage(Message):
|
||||||
|
|
||||||
class FileMessage(Message):
|
class FileMessage(Message):
|
||||||
title = models.CharField('title', max_length=256, null=False)
|
title = models.CharField('title', max_length=256, null=False)
|
||||||
file = models.FileField(upload_to='message/file/%Y/%m/%d/', null=True, blank=True)
|
file = models.FileField(
|
||||||
|
upload_to='message/file/%Y/%m/%d/', null=True, blank=True)
|
||||||
|
|
||||||
|
|
||||||
class ImageMessage(Message):
|
class ImageMessage(Message):
|
||||||
file = models.FileField(upload_to='resources/image/%Y/%m/%d/', null=True, blank=True)
|
file = models.FileField(
|
||||||
|
upload_to='resources/image/%Y/%m/%d/', null=True, blank=True)
|
||||||
|
|
||||||
|
|
||||||
class MessageRecord(models.Model):
|
class MessageRecord(models.Model):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ChatRecord(models.Model):
|
class ChatRecord(models.Model):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NewsPage(Page):
|
||||||
|
date = models.DateField("Post date")
|
||||||
|
source = models.CharField(max_length=64)
|
||||||
|
intro = models.CharField(max_length=250)
|
||||||
|
body = RichTextField(blank=True)
|
||||||
|
categories = ParentalManyToManyField('polls.NewsCategory', blank=True)
|
||||||
|
|
||||||
|
def main_image(self):
|
||||||
|
gallery_item = self.gallery_images.first()
|
||||||
|
if gallery_item:
|
||||||
|
return gallery_item.image
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
content_panels = Page.content_panels + [
|
||||||
|
FieldPanel('date'),
|
||||||
|
FieldPanel('source'),
|
||||||
|
FieldPanel('categories'),
|
||||||
|
FieldPanel('intro'),
|
||||||
|
FieldPanel('body', classname="full"),
|
||||||
|
InlinePanel('gallery_images', label="Gallery images"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class NewsPageGalleryImage(Orderable):
|
||||||
|
page = ParentalKey(NewsPage, on_delete=models.CASCADE,
|
||||||
|
related_name='gallery_images')
|
||||||
|
image = models.ForeignKey(
|
||||||
|
'wagtailimages.Image', on_delete=models.CASCADE, related_name='+'
|
||||||
|
)
|
||||||
|
caption = models.CharField(blank=True, max_length=250)
|
||||||
|
|
||||||
|
panels = [
|
||||||
|
ImageChooserPanel('image'),
|
||||||
|
FieldPanel('caption'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@register_snippet
|
||||||
|
class NewsCategory(models.Model):
|
||||||
|
name = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
panels = [
|
||||||
|
FieldPanel('name'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name_plural = 'news categories'
|
||||||
|
|
Loading…
Reference in New Issue