Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.

Commit 69f3956

Browse files
authored
Wrap methods returning raw HTML in mark_safe (#1382)
* initial * renamed to something more sensible * Add a required checkbox to the CfP proposal submission page. The checkbox content is not stored in the database, but submission will fail unless checked. * added test to verify that speakers do have to agree to the speaker release agreement * initial * renamed to something more sensible * Added a template simple_tag to list a user tickets for the current conference. Uses functionality already implemented. * Added documentation * Added a template simple_tag to list a user tickets for the current conference. Uses functionality already implemented. * Upgraded jquery-flot to v0.8.3 for compatibility with django admin jquery version - v3.5.1 * Wrapping methods using the old allow_tags attribute in mark_safe, making them compatible with later versions of Django
1 parent 06a7a91 commit 69f3956

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

assopy/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ def changelist_view(self, request, extra_context=None):
392392
request.META['QUERY_STRING'] = request.GET.urlencode()
393393
return super(CouponAdmin,self).changelist_view(request, extra_context=extra_context)
394394

395+
@mark_safe
395396
def _user(self, o):
396397
if not o.user:
397398
return ''
@@ -552,6 +553,7 @@ def _order(self, o):
552553
return mark_safe('<a href="%s">%s</a>' % (url, order.code))
553554
_order.admin_order_field = 'order'
554555

556+
@mark_safe
555557
def _user(self, o):
556558
u = o.order.user.user
557559
name = '%s %s' % (u.first_name, u.last_name)

conference/admin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ def __init__(self, *args, **kw):
8383
class ConferenceAdmin(admin.ModelAdmin):
8484
list_display = ('code', 'name', '_schedule_view', '_attendee_stats')
8585

86+
@mark_safe
8687
def _schedule_view(self, o):
8788
u = reverse('admin:conference-conference-schedule', args=(o.code,))
8889
return '<a href="%s">schedule</a>' % u
8990
_schedule_view.allow_tags = True
9091

92+
@mark_safe
9193
def _attendee_stats(self, o):
9294
u = reverse('admin:conference-ticket-stats', args=(o.code,))
9395
return '<a href="%s">Attendee Stats</a>' % u
@@ -480,6 +482,7 @@ def stats_list(self, request):
480482
},
481483
)
482484

485+
@mark_safe
483486
def _user(self, o):
484487
if o.user.attendeeprofile:
485488
p = reverse('profiles:profile', kwargs={'profile_slug': o.user.attendeeprofile.slug})
@@ -498,6 +501,7 @@ def _email(self, o):
498501
return o.user.email
499502
_user.admin_order_field = 'user__email'
500503

504+
@mark_safe
501505
def _avatar(self, o):
502506
try:
503507
img = o.user.attendeeprofile.image
@@ -956,6 +960,7 @@ def _ticket(self, o):
956960
return o.fare.code
957961
_ticket.admin_order_field = 'fare__code'
958962

963+
@mark_safe
959964
def _order(self, obj):
960965
url = reverse('admin:assopy_order_change',
961966
args=(obj.orderitem.order.id,))
@@ -966,6 +971,7 @@ def _order_date(self, o):
966971
return o.orderitem.order.created
967972
_order_date.admin_order_field = 'orderitem__order__created'
968973

974+
@mark_safe
969975
def _assigned(self, ticket):
970976
if ticket.p3_conference:
971977
assigned_to = ticket.p3_conference.assigned_to
@@ -1068,6 +1074,7 @@ def _python_experience(self, o):
10681074
return p3c.python_experience
10691075
_python_experience.admin_order_field = 'p3_conference__python_experience'
10701076

1077+
@mark_safe
10711078
def _tagline(self, o):
10721079
try:
10731080
p3c = o.p3_conference

p3/admin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from django.contrib import admin
33
from django.db import models
44
from django.forms import TextInput, Textarea
5+
from django.utils.safestring import mark_safe
56

67
from taggit.forms import TagField
78
from taggit_labels.widgets import LabelWidget
@@ -21,6 +22,7 @@ class VotoTalkAdmin(admin.ModelAdmin):
2122
]
2223
ordering = ("-talk__conference", "talk")
2324

25+
@mark_safe
2426
def _name(self, o):
2527
url = reverse(
2628
"profiles:profile", kwargs={"profile_slug": o.user.attendeeprofile.slug}
@@ -50,6 +52,7 @@ class AttendeeProfileAdmin(admin.ModelAdmin):
5052
"location",
5153
]
5254

55+
@mark_safe
5356
def _name(self, o):
5457
url = reverse("profiles:profile", kwargs={"profile_slug": o.slug})
5558
return '<a href="%s">%s %s</a>' % (
@@ -61,6 +64,7 @@ def _name(self, o):
6164
_name.allow_tags = True
6265
_name.admin_order_field = "user__first_name"
6366

67+
@mark_safe
6468
def _user(self, o):
6569
url = reverse("admin:auth_user_change", args=(o.user.id,))
6670
return '<a href="%s">%s</a>' % (url, o.user.username)
@@ -126,6 +130,7 @@ class TalkAdmin(admin.ModelAdmin):
126130
def _tags(self, obj):
127131
return ", ".join(sorted(str(tag) for tag in obj.tags.all()))
128132

133+
@mark_safe
129134
def _speakers(self, obj):
130135
"""Warnings – this is de-optimised version of previous cached query,
131136
however much easier to work with and much easier to debug"""

0 commit comments

Comments
 (0)