From 6effe697936634b958a444dbcf7721d86447650e Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 2 Dec 2011 02:42:20 +0530 Subject: [PATCH] added emailer --- itf/emailer/__init__.py | 0 itf/emailer/admin.py | 47 ++++++++++++++++++++++++++++++++++ itf/emailer/models.py | 56 +++++++++++++++++++++++++++++++++++++++++ itf/emailer/tests.py | 23 +++++++++++++++++ itf/emailer/views.py | 1 + 5 files changed, 127 insertions(+) create mode 100644 itf/emailer/__init__.py create mode 100644 itf/emailer/admin.py create mode 100644 itf/emailer/models.py create mode 100644 itf/emailer/tests.py create mode 100644 itf/emailer/views.py diff --git a/itf/emailer/__init__.py b/itf/emailer/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/itf/emailer/admin.py b/itf/emailer/admin.py new file mode 100644 index 0000000..86522e5 --- /dev/null +++ b/itf/emailer/admin.py @@ -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) + diff --git a/itf/emailer/models.py b/itf/emailer/models.py new file mode 100644 index 0000000..aee0696 --- /dev/null +++ b/itf/emailer/models.py @@ -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 diff --git a/itf/emailer/tests.py b/itf/emailer/tests.py new file mode 100644 index 0000000..2247054 --- /dev/null +++ b/itf/emailer/tests.py @@ -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 +"""} + diff --git a/itf/emailer/views.py b/itf/emailer/views.py new file mode 100644 index 0000000..60f00ef --- /dev/null +++ b/itf/emailer/views.py @@ -0,0 +1 @@ +# Create your views here.