Skip to content

Commit

Permalink
Added source field to Thank You Note
Browse files Browse the repository at this point in the history
  • Loading branch information
edwoodward committed Nov 17, 2023
1 parent 8e62c07 commit 38be7ae
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 4 deletions.
18 changes: 18 additions & 0 deletions donations/migrations/0008_thankyounote_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-11-17 14:37

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('donations', '0007_auto_20220516_2113'),
]

operations = [
migrations.AddField(
model_name='thankyounote',
name='source',
field=models.CharField(blank=True, default='', max_length=255),
),
]
1 change: 1 addition & 0 deletions donations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ThankYouNote(models.Model):
created = models.DateField(auto_now_add=True)
consent_to_share_or_contact = models.BooleanField(default=False)
contact_email_address = models.EmailField(blank=True, null=True)
source = models.CharField(max_length=255, default="", blank=True)

class DonationPopup(models.Model):
download_image = models.ImageField(null=True, blank=True)
Expand Down
6 changes: 4 additions & 2 deletions donations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ class Meta:
'institution',
'created',
'consent_to_share_or_contact',
'contact_email_address')
'contact_email_address',
'source')
read_only_fields = ('thank_you_note',
'first_name',
'last_name',
'institution',
'created',
'consent_to_share_or_contact',
'contact_email_address')
'contact_email_address',
'source')


class DonationPopupSerializer(serializers.ModelSerializer):
Expand Down
2 changes: 1 addition & 1 deletion donations/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_donation_api_get(self):
class ThankYouNoteTest(APITestCase, TestCase):

def test_thank_you_note_api_post(self):
data = {"thank_you_note":"OpenStax is the best! Loved not paying for a book", "last_name": "Drew", "first_name": "Jessica", "institution": "Rice University", "consent_to_share_or_contact": "True", "contact_email_address": "[email protected]"}
data = {"thank_you_note":"OpenStax is the best! Loved not paying for a book", "last_name": "Drew", "first_name": "Jessica", "institution": "Rice University", "consent_to_share_or_contact": "True", "contact_email_address": "[email protected]", "source": "PDF download"}
response = self.client.post('/apps/cms/api/donations/thankyounote/', data, format='json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
tyn = ThankYouNote.objects.filter(last_name='Drew').values()
Expand Down
4 changes: 3 additions & 1 deletion donations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ def post(self, request):
institution = request.data['institution']
consent_to_share_or_contact = request.data.get('consent_to_share_or_contact', False)
contact_email_address = request.data.get('contact_email_address', '')
source = request.data.get('source', '')

ty_note = ThankYouNote.objects.create(thank_you_note=thank_you_note,
first_name=first_name,
last_name=last_name,
institution=institution,
consent_to_share_or_contact=consent_to_share_or_contact,
contact_email_address=contact_email_address)
contact_email_address=contact_email_address,
source=source)

serializer = ThankYouNoteSerializer(data=request.data)
if serializer.is_valid():
Expand Down
17 changes: 17 additions & 0 deletions errata/migrations/0056_alter_errata_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.1.7 on 2023-11-17 14:37

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('errata', '0055_remove_errata_accounts_user_email_and_more'),
]

operations = [
migrations.AlterModelOptions(
name='errata',
options={'verbose_name': 'erratum list', 'verbose_name_plural': 'errata list'},
),
]
14 changes: 14 additions & 0 deletions snippets/migrations/0032_merge_20231117_0830.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 4.1.7 on 2023-11-17 14:30

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('snippets', '0031_merge_20231101_1313'),
('snippets', '0031_merge_20231101_1438'),
]

operations = [
]

0 comments on commit 38be7ae

Please sign in to comment.