added emailer
This commit is contained in:
parent
b6903cb912
commit
6effe69793
0
itf/emailer/__init__.py
Normal file
0
itf/emailer/__init__.py
Normal file
47
itf/emailer/admin.py
Normal file
47
itf/emailer/admin.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
from django.contrib import admin
|
||||
from models import *
|
||||
from markitup.widgets import MarkItUpWidget
|
||||
# from forms import ArticleForm
|
||||
|
||||
class ImageInline(admin.StackedInline):
|
||||
model = ArticleImage
|
||||
extra = 4
|
||||
|
||||
|
||||
class BBInline(admin.StackedInline):
|
||||
formfield_overrides = {models.TextField: {'widget': MarkItUpWidget}}
|
||||
model = BulletinBoardItem
|
||||
extra = 3
|
||||
|
||||
|
||||
class WeblinkInline(admin.StackedInline):
|
||||
formfield_overrides = {models.TextField: {'widget': MarkItUpWidget}}
|
||||
model = Weblink
|
||||
extra = 4
|
||||
|
||||
|
||||
class ArticleInline(admin.StackedInline):
|
||||
formfield_overrides = {models.TextField: {'widget': MarkItUpWidget}}
|
||||
model = EmailerArticle
|
||||
extra = 2
|
||||
|
||||
|
||||
class IssueAdmin(admin.ModelAdmin):
|
||||
list_display = ('title', 'issue_no', 'date', 'published',)
|
||||
inlines = [WeblinkInline, BBInline, ArticleInline]
|
||||
list_editable = ('published',)
|
||||
save_on_top = True
|
||||
formfield_overrides = {models.TextField: {'widget': MarkItUpWidget}}
|
||||
|
||||
class ArticleAdmin(admin.ModelAdmin):
|
||||
list_filter = ['issue']
|
||||
inlines = [ImageInline]
|
||||
|
||||
# form = ArticleForm
|
||||
|
||||
admin.site.register(EmailerIssue, IssueAdmin)
|
||||
admin.site.register(EmailerArticle, ArticleAdmin)
|
||||
# admin.site.register(Document, DocumentAdmin)
|
||||
admin.site.register(Weblink)
|
||||
admin.site.register(BulletinBoardItem)
|
||||
|
56
itf/emailer/models.py
Normal file
56
itf/emailer/models.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
from django.db import models
|
||||
from app.models import ItfModel
|
||||
|
||||
class EmailerIssue(ItfModel):
|
||||
title = models.CharField(max_length=512)
|
||||
date = models.DateField()
|
||||
issue_no = models.IntegerField()
|
||||
published = models.BooleanField(default=False)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
class Meta:
|
||||
ordering = ['-issue_no']
|
||||
|
||||
|
||||
class EmailerArticle(models.Model):
|
||||
issue = models.ForeignKey(EmailerIssue)
|
||||
title = models.CharField(max_length=512)
|
||||
subtitle = models.TextField(blank=True)
|
||||
author = models.CharField(max_length=512, blank=True)
|
||||
author_bio = models.TextField(blank=True)
|
||||
main_image = models.ImageField(upload_to='upload/images/emailer/', blank=True)
|
||||
text = models.TextField()
|
||||
position = models.IntegerField(null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
|
||||
class ArticleImage(models.Model):
|
||||
image = models.ImageField(upload_to='upload/images/emailer/')
|
||||
caption = models.CharField(max_length=512, blank=True)
|
||||
article = models.ForeignKey(EmailerArticle)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.caption
|
||||
|
||||
|
||||
class Weblink(models.Model):
|
||||
url = models.URLField()
|
||||
text = models.TextField(blank=True)
|
||||
issue = models.ForeignKey(EmailerIssue)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.url
|
||||
|
||||
|
||||
class BulletinBoardItem(models.Model):
|
||||
issue = models.ForeignKey(EmailerIssue)
|
||||
title = models.CharField(max_length=512)
|
||||
text = models.TextField()
|
||||
position = models.IntegerField(default=1)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title
|
23
itf/emailer/tests.py
Normal file
23
itf/emailer/tests.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
"""
|
||||
This file demonstrates two different styles of tests (one doctest and one
|
||||
unittest). These will both pass when you run "manage.py test".
|
||||
|
||||
Replace these with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.failUnlessEqual(1 + 1, 2)
|
||||
|
||||
__test__ = {"doctest": """
|
||||
Another way to test that 1 + 1 is equal to 2.
|
||||
|
||||
>>> 1 + 1 == 2
|
||||
True
|
||||
"""}
|
||||
|
1
itf/emailer/views.py
Normal file
1
itf/emailer/views.py
Normal file
|
@ -0,0 +1 @@
|
|||
# Create your views here.
|
Loading…
Reference in New Issue
Block a user