Permalink
Browse files

added urls and views to render templates, mainly for tiny mce integra…

…tion for the template plugin
  • Loading branch information...
1 parent c7334db commit ef6539baa4c477548f43d34cadaaec137c100022 @sherzberg sherzberg committed Jun 22, 2011
Showing with 25 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +4 −0 emailer/models.py
  3. +2 −0 emailer/urls.py
  4. +17 −1 emailer/views.py
  5. BIN testsite/database.sqlite
  6. +1 −2 testsite/settings.py
View
1 .gitignore
@@ -10,5 +10,6 @@ media/tar/
media/tar-samples/
media/proofing/
*.db
+*.sqlite
.project
.pydevproject
View
4 emailer/models.py
@@ -26,6 +26,10 @@ class EmailTemplate(DefaultModel):
def __unicode__(self):
return str(self.name)
+ @models.permalink
+ def get_absolute_url(self):
+ return ('emailer-template', (), {'template_id': self.id})
+
class EmailList(DefaultModel):
TYPE_SITEUSERS_USERDEFINED = 0
View
2 emailer/urls.py
@@ -4,5 +4,7 @@
urlpatterns = patterns('emailer.views',
url(r'^tracking/(?P<tracking_id>.+).png$', 'tracking', name='emailer-tracking_png'),
+ url(r'^templates/$', 'templates', name='emailertemplate_list'),
+ url(r'^template/(?P<template_id>.+)/$', 'template', name='emailer-template'),
)
View
18 emailer/views.py
@@ -1,4 +1,8 @@
from django.http import HttpResponse
+from django.shortcuts import render_to_response, get_object_or_404
+from django.template import RequestContext
+
+from emailer.models import EmailTemplate
import Image
from emailer.models import Email
@@ -14,4 +18,16 @@ def tracking(request, tracking_id):
response = HttpResponse(mimetype="image/png")
image.save(response, "PNG")
- return response
+ return response
+
+def templates(request):
+ templates = EmailTemplate.objects.all()
+ return render_to_response('tinymce/template_list.js', {'templates': templates},
+ context_instance=RequestContext(request),
+ mimetype='text/javascript')
+
+def template(request, template_id):
+ template = get_object_or_404(EmailTemplate, id = template_id)
+
+ response = HttpResponse(template.html)
+ return response
View
BIN testsite/database.sqlite
Binary file not shown.
View
3 testsite/settings.py
@@ -99,7 +99,6 @@
USE_COMPRESSOR = False
TINYMCE_USE_TEMPLATES = True
-
TINYMCE_DEFAULT_CONFIG = {
'theme' : "advanced",
'plugins' : "autolink,lists,spellchecker,pagebreak,style,layer,table,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
@@ -123,6 +122,6 @@
'skin' : "o2k7",
'skin_variant' : "silver",
- 'template_external_list_url' : "tinymce/templates/",
+ 'template_external_list_url' : "emailer/templates/",
}

0 comments on commit ef6539b

Please sign in to comment.