Skip to content

Commit

Permalink
added ability to include safe HTML in the election description
Browse files Browse the repository at this point in the history
  • Loading branch information
benadida committed Mar 11, 2014
1 parent dbd0886 commit d7f07bd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions helios/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from django.core.mail import send_mail

import datetime, logging, uuid, random, io
import bleach

from crypto import electionalgs, algs, utils
from helios import utils as heliosutils
Expand Down Expand Up @@ -189,6 +190,10 @@ def encrypted_tally_hash(self):
def is_archived(self):
return self.archived_at != None

@property
def description_bleached(self):
return bleach.clean(self.description)

@classmethod
def get_featured(cls):
return cls.objects.filter(featured_p = True).order_by('short_name')
Expand Down
3 changes: 1 addition & 2 deletions helios/templates/election_view.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends TEMPLATE_BASE %}

{% block title %}{{election.name}}{% endblock %}
{% block content %}
<div style="float: left; margin-right: 50px;">
Expand Down Expand Up @@ -47,7 +46,7 @@ <h3 class="title">{{ election.name }}
<br clear="left" />

<div style="margin-bottom: 25px;margin-left: 15px; border-left: 1px solid #aaa; padding-left: 5px; font-size:1.3em; ">
{{election.description}}
{{election.description_bleached|safe}}
</div>

{% if election.election_info_url %}
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ django_webtest==1.7.5
webtest==2.0.7
django-db-pool==0.0.10
django-secure==0.1.2
bleach==1.4

0 comments on commit d7f07bd

Please sign in to comment.