Commit 10a94452 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Fix newsletters send permission and change tests to use non-superuser

parent 95373005
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-12-11 20:45
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('newsletters', '0003_auto_20161109_2257'),
]
operations = [
migrations.AlterModelOptions(
name='newsletter',
options={'permissions': (('send_newsletter', 'Can send newsletter'),)},
),
]
......@@ -42,6 +42,11 @@ class Newsletter(models.Model, metaclass=ModelTranslateMeta):
def get_absolute_url(self):
return reverse('newsletters:preview', args=(self.pk,))
class Meta:
permissions = (
("send_newsletter", "Can send newsletter"),
)
class NewsletterContent(models.Model, metaclass=ModelTranslateMeta):
title = MultilingualField(
......
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth.models import User, Permission
from django.core import mail
from django.core.exceptions import ValidationError
from django.test import TestCase
......@@ -11,9 +11,15 @@ from newsletters.models import Newsletter, NewsletterEvent
class NewslettersTest(TestCase):
def setUp(self):
self.user = User.objects.create_superuser(username='jacob',
email='jacob@test.com',
password='top_secret')
self.user = User.objects.create_user(username='jacob',
email='jacob@test.com',
password='top_secret',
is_staff=True)
self.user.user_permissions.set(
Permission.objects.filter(content_type__app_label="newsletters")
)
self.user.backend = 'django.contrib.auth.backends.ModelBackend'
self.user.save()
......
......@@ -52,7 +52,7 @@ def legacy_redirect(request, year, week):
@staff_member_required
@permission_required('newsletters.change_event')
@permission_required('newsletters.send_newsletter')
def admin_send(request, pk):
newsletter = get_object_or_404(Newsletter, pk=pk)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment