-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #239 from Duke-GCB/email-template-endpoints
Adds email templates API v2 endpoints
- Loading branch information
Showing
10 changed files
with
315 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.28 on 2020-06-15 13:38 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('d4s2_api', '0038_auto_20200327_1857'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='emailtemplatetype', | ||
name='help_text', | ||
field=models.TextField(blank=True), | ||
), | ||
migrations.AddField( | ||
model_name='emailtemplatetype', | ||
name='sequence', | ||
field=models.IntegerField(help_text='determines order', null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='emailtemplate', | ||
name='template_set', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='email_templates', to='d4s2_api.EmailTemplateSet'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.28 on 2020-06-17 15:45 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('d4s2_api', '0039_auto_20200615_1338'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='emailtemplateset', | ||
name='group_name', | ||
field=models.CharField(blank=True, help_text='group manager group assigned to this set', max_length=64), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,12 @@ | |
from rest_framework.exceptions import APIException, ValidationError | ||
from rest_framework.decorators import detail_route | ||
from rest_framework.response import Response | ||
from d4s2_api.models import DDSDelivery, Share, State, UserEmailTemplateSet | ||
from d4s2_api.models import DDSDelivery, Share, State, UserEmailTemplateSet, EmailTemplateSet | ||
from d4s2_api_v1.serializers import DeliverySerializer, ShareSerializer | ||
from switchboard.dds_util import DDSUtil, DDSMessageFactory | ||
from django.core.urlresolvers import reverse | ||
from django_filters.rest_framework import DjangoFilterBackend | ||
from django.db.models import Q | ||
EMAIL_TEMPLATES_NOT_SETUP_MSG = """Email templates need to be setup for your account. | ||
Please contact [email protected].""" | ||
CANNOT_PASS_EMAIL_TEMPLATE_SET = """You cannot create this item by passing email_template_set, | ||
|
@@ -46,6 +47,9 @@ def get_email_template_for_request(self): | |
:return: EmailTemplateSet | ||
""" | ||
try: | ||
email_template_set_id = self.request.data.get('email_template_set_id') | ||
if email_template_set_id: | ||
return EmailTemplateSet.get_for_user(self.request.user).get(pk=email_template_set_id) | ||
user_email_template_set = UserEmailTemplateSet.objects.get(user=self.request.user) | ||
return user_email_template_set.email_template_set | ||
except UserEmailTemplateSet.DoesNotExist: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.