Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding a simple view for viewing a campaign online in the browser

  • Loading branch information...
commit 90b342f0efead9b1db192810005c8141f9c03146 1 parent 4a72925
@arneb arneb authored
View
2  campaign/admin.py
@@ -114,7 +114,7 @@ def wrapper(*args, **kwargs):
class CampaignAdmin(admin.ModelAdmin):
filter_horizontal=('recipients',)
- list_display=('name', 'sent')
+ list_display=('name', 'sent', 'online')
send_template = None
def has_send_permission(self, request, obj):
View
1  campaign/models.py
@@ -85,6 +85,7 @@ class Campaign(models.Model):
template = models.ForeignKey(MailTemplate, verbose_name=_(u"Template"))
recipients = models.ManyToManyField(SubscriberList, verbose_name=_(u"Subscriber lists"))
sent = models.BooleanField(_(u"sent out"), default=False, editable=False)
+ online = models.BooleanField(_(u"available online"), default=True, blank=True, help_text=_(u"make a copy available online"))
def __unicode__(self):
return self.name
View
4 campaign/templates/admin/campaign/subscriber/import.html
@@ -28,8 +28,8 @@
{"email": "news@example.de", "name": "Hans"}]</pre>
{% blocktrans %}or in csv format with ',' as delimiter:
{% endblocktrans %}
- <pre>"info@example.com", "Peter"
-"news@example.de", "Hans"</pre>
+ <pre>"info@example.com","Peter"
+"news@example.de","Hans"</pre>
</div>
<div class="form-row">
View
5 campaign/urls.py
@@ -0,0 +1,5 @@
+from django.conf.urls.defaults import *
+
+urlpatterns = patterns('',
+ url(r'^(?P<object_id>[\d]+)/$', 'campaign.views.view_online', {}, name="campaign_view_online"),
+)
View
17 campaign/views.py
@@ -0,0 +1,17 @@
+from django import template, http
+from django.shortcuts import get_object_or_404
+from campaign.models import Campaign
+
+def view_online(request, object_id):
+ campaign = get_object_or_404(Campaign, pk=object_id)
+
+ if campaign.template.html is not None and campaign.template.html != u"":
+ tpl = template.Template(campaign.template.html)
+ content_type = 'text/html, charset=utf-8'
+ else:
+ tpl = template.Template(campaign.template.plain)
+ content_type = 'text/plain, charset=utf-8'
+
+ return http.HttpResponse(tpl.render(template.Context({})), content_type=content_type)
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.