From 66c02249f0a7ca0d47f6509482c3aa19ff296f62 Mon Sep 17 00:00:00 2001 From: "Nico Pfiffner (nipfif)" Date: Tue, 21 May 2024 18:07:17 +0200 Subject: [PATCH] feat(delete): Prepare deletion of ddm_pooled. --- config/settings/base.py | 1 + ddm_pooled/admin.py | 10 -- .../migrations/0007_delete_pooledproject.py | 16 +++ ddm_pooled/models.py | 12 -- ddm_pooled/tests.py | 105 ------------------ 5 files changed, 17 insertions(+), 127 deletions(-) create mode 100644 ddm_pooled/migrations/0007_delete_pooledproject.py diff --git a/config/settings/base.py b/config/settings/base.py index a32de4f..1259aed 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -43,6 +43,7 @@ 'wagtail', 'modelcluster', 'taggit', + 'ddm_pooled' ] MIDDLEWARE = [ diff --git a/ddm_pooled/admin.py b/ddm_pooled/admin.py index 0433d8c..c6fe108 100644 --- a/ddm_pooled/admin.py +++ b/ddm_pooled/admin.py @@ -1,12 +1,2 @@ from django.contrib import admin -from ddm_pooled.models import PooledProject - -class PooledProjectAdmin(admin.ModelAdmin): - """ - Provides an overview of all Pooled Donation Projects. - """ - list_display = ['project'] - - -admin.site.register(PooledProject, PooledProjectAdmin) diff --git a/ddm_pooled/migrations/0007_delete_pooledproject.py b/ddm_pooled/migrations/0007_delete_pooledproject.py new file mode 100644 index 0000000..f302b3a --- /dev/null +++ b/ddm_pooled/migrations/0007_delete_pooledproject.py @@ -0,0 +1,16 @@ +# Generated by Django 3.2.17 on 2024-05-21 16:04 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('ddm_pooled', '0006_delete_poolparticipant'), + ] + + operations = [ + migrations.DeleteModel( + name='PooledProject', + ), + ] diff --git a/ddm_pooled/models.py b/ddm_pooled/models.py index e323698..0047796 100644 --- a/ddm_pooled/models.py +++ b/ddm_pooled/models.py @@ -2,15 +2,3 @@ from django.db import models -class PooledProject(models.Model): - project = models.OneToOneField('ddm.DonationProject', on_delete=models.CASCADE) - external_id = models.CharField(max_length=50, null=False, unique=True) - - get_donation_consent = models.BooleanField(default=True) - donation_briefing = RichTextUploadingField( - null=True, blank=True, - verbose_name='Donation Briefing Text', - help_text='If "get donation consent" is enabled, will be displayed before ' - 'the debriefing page.', - config_name='ddm_ckeditor' - ) diff --git a/ddm_pooled/tests.py b/ddm_pooled/tests.py index daee202..e69de29 100644 --- a/ddm_pooled/tests.py +++ b/ddm_pooled/tests.py @@ -1,105 +0,0 @@ -from django.contrib.auth import get_user_model -from django.urls import reverse -from django.utils import timezone -from rest_framework import status -from rest_framework.test import APITestCase - -from ddm.models.core import Participant, ResearchProfile, DonationProject -from ddm.tests.test_participation_flow import ParticipationFlowBaseTestCase -from ddm_pooled.models import PooledProject -from ddm_pooled.settings import POOL_KW, PROJECT_KW - - -User = get_user_model() - - -class ParticipantAPITests(APITestCase): - @classmethod - def setUpTestData(cls): - cls.user = User.objects.create_user(**{ - 'username': 'u', 'password': '123', 'email': 'owner@mail.com' - }) - profile = ResearchProfile.objects.create(user=cls.user) - project = DonationProject.objects.create( - name='Base Project', slug='base', owner=profile) - cls.pooled_project = PooledProject.objects.create( - project=project, external_id='external_id') - Participant.objects.create( - project=project, - external_id='abc', - start_time=timezone.now(), - extra_data={'pool_id': 'test_pool'} - ) - - def test_get_participants(self): - """ - Ensure the correct participant information is retrieved. - """ - url = reverse('participant-list') - data = { - 'extra_data': {'pool_id': 'test_pool'}, - 'external_id': '1', - 'completed': False - } - self.client.force_authenticate(user=self.user) - response = self.client.get( - url, {POOL_KW: 'test_pool', PROJECT_KW: 'external_id'}, format='json') - self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(len(response.data), 1) - self.assertCountEqual(dict(response.data[0]), data) - - def test_get_participants_without_poolid(self): - """ - Ensure query without pool_id raises 400. - """ - url = reverse('participant-list') - self.client.force_authenticate(user=self.user) - response = self.client.get(url, format='json') - self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) - - -class TestPoolDonateView(ParticipationFlowBaseTestCase): - - @classmethod - def setUpTestData(cls): - super().setUpTestData() - cls.pooled_project = PooledProject.objects.create( - project=cls.project_base, external_id='abc') - - def setUp(self): - super().setUp() - self.initialize_project_and_session() - self.participant = self.get_participant(self.project_base.pk) - self.participant.current_step = 3 - self.participant.save() - - def test_redirect_to_donation_question(self): - response = self.client.get(self.debriefing_url) - self.assertEqual(response.status_code, 302) - self.assertRedirects( - response, reverse('ddm-pool-donate', args=[self.project_base.slug])) - - def test_post_valid_form(self): - response = self.client.post( - reverse('ddm-pool-donate', args=[self.project_base.slug]), - {'donation_consent': '1'} - ) - self.assertRedirects(response, reverse('debriefing', args=[self.project_base.slug])) - self.assertEqual(response.status_code, 302) - self.participant.refresh_from_db() - self.assertEqual(self.participant.extra_data['pool_donate'], True) - - def test_post_invalid_form(self): - response = self.client.post( - reverse('ddm-pool-donate', args=[self.project_base.slug]), - {'donation_consent': 'fubar'} - ) - self.assertEqual(response.status_code, 200) - self.assertTemplateUsed(response, 'ddm_pooled/pool_donation_consent.html') - - def test_skip_donation_question(self): - self.pooled_project.get_donation_consent = False - self.pooled_project.save() - response = self.client.get(self.debriefing_url) - self.assertEqual(response.status_code, 200) - self.assertTemplateUsed(response, 'ddm/public/debriefing.html')