Add a permission to view speaker contact details in conference.json

This commit is contained in:
Scott Bragg 2016-12-30 19:21:36 +11:00
parent 765e80765c
commit dbb4ebbb70
3 changed files with 22 additions and 2 deletions

View file

@ -242,7 +242,7 @@ def schedule_json(request):
"authors": [s.name for s in slot.content.speakers()],
"contact": [
s.email for s in slot.content.speakers()
] if request.user.is_staff else ["redacted"],
] if request.user.has_perm('symposion_speakers.can_view_contact_details') or request.user.is_staff else ["redacted"],
"abstract": slot.content.abstract,
"conf_url": "%s://%s%s" % (
protocol,
@ -258,7 +258,7 @@ def schedule_json(request):
data.append(slot_data)
return HttpResponse(
json.dumps({"schedule": data}),
json.dumps({"schedule": data}, indent=2),
content_type="application/json"
)

View file

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-12-30 08:09
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('symposion_speakers', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='speaker',
options={'ordering': ['name'], 'permissions': (('can_view_contact_details', 'Can View Contact Details'),), 'verbose_name': 'Speaker', 'verbose_name_plural': 'Speakers'},
),
]

View file

@ -105,6 +105,7 @@ class Speaker(models.Model):
ordering = ['name']
verbose_name = _("Speaker")
verbose_name_plural = _("Speakers")
permissions = (('can_view_contact_details', 'Can View Contact Details'),)
def save(self, *args, **kwargs):
self.biography_html = parse(self.biography)