diff options
Diffstat (limited to 'alphabetlearning/resources')
26 files changed, 90 insertions, 467 deletions
diff --git a/alphabetlearning/resources/factories.py b/alphabetlearning/resources/factories.py index 4075ab1..0f0194b 100644 --- a/alphabetlearning/resources/factories.py +++ b/alphabetlearning/resources/factories.py @@ -1,12 +1,10 @@ import itertools import factory +from alphabetlearning.payments.models import Price -from .models import PDFPageSnapshot -from .models import PDFResource -from .models import Resource -from .models import ResourceCategory -from .models import ResourceType +from .models import (PDFPageSnapshot, PDFResource, Resource, ResourceCategory, + ResourceType) class ResourceTypeModelFactory(factory.django.DjangoModelFactory): @@ -39,10 +37,11 @@ class ResourceModelFactory(factory.django.DjangoModelFactory): model = Resource name = factory.Sequence(lambda n: f"Default Resource {n}") - price = factory.Faker("pydecimal", left_digits=4, right_digits=2, positive=True) + # price = factory.Faker("pydecimal", left_digits=4, right_digits=2, positive=True) thumbnail_filenames = factory.List( [factory.Faker("file_name", extension="jpg") for _ in range(3)] ) + # price_obj = factory.RelatedFactoryList("alphabetlearning.payments.factories.PriceFactory", size=1) resource_type = factory.SubFactory(ResourceTypeModelFactory) main_resource_category = factory.SubFactory(ResourceCategoryModelFactory) subcategories = factory.RelatedFactoryList(ResourceCategoryModelFactory, size=2) diff --git a/alphabetlearning/resources/migrations/0001_initial.py b/alphabetlearning/resources/migrations/0001_initial.py index 812c98f..9112f51 100644 --- a/alphabetlearning/resources/migrations/0001_initial.py +++ b/alphabetlearning/resources/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 5.0.4 on 2024-05-13 21:41 +# Generated by Django 5.1.4 on 2024-12-31 15:26 import django.db.models.deletion from django.db import migrations, models @@ -19,16 +19,22 @@ class Migration(migrations.Migration): ('file_name', models.CharField(max_length=255)), ('file_size', models.IntegerField()), ], + options={ + 'verbose_name_plural': 'PDF Resources', + }, ), migrations.CreateModel( name='Resource', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=255)), + ('stripe_product_id', models.CharField(max_length=100)), ('thumbnail_filenames', models.JSONField(default=list, verbose_name='Thumbnail filenames')), - ('description', models.TextField(max_length=1000)), - ('age_range', models.CharField(choices=[('3-5', '3-5'), ('5-7', '5-7'), ('7-11', '7-11'), ('11-14', '11-14'), ('14-16', '14-16'), ('16+', '16+'), ('Age not applicable', 'Age not applicable')], default='5-7', max_length=20)), + ('description', models.TextField(help_text='\n <strong>Markdown acceptable here!</strong>This is your opportunity to clearly explain what\n your resource is all about! It’s worth remembering that you are using the space to\n communicate to two different audiences. Firstly, think about what fellow teachers\n would like to know, such as exactly what the resource contains and how it could be used in\n the classroom. Secondly, the words you include on this page are also talking to internal and\n external search engines. External search engines, like Google, show the first 155 characters\n of the resource description, so make sure you take advantage\n of these characters by using lots of relevant keywords as part of an enticing pitch.\n', max_length=5000)), + ('card_description', models.TextField(blank=True, default='', help_text="If you enter text here, it will be used in the 'card' description box on the home page. Max 1000 characters.", max_length=1000)), + ('age_range', models.CharField(choices=[('Preschool (3-4yrs)', 'Preschool (3-4yrs)'), ('Nursery (2-5yrs)', 'Nursery (2-5yrs)'), ('Reception (4-5yrs)', 'Reception (4-5yrs)'), ('Year 1 (5-6yrs)', 'Year 1 (5-6yrs)'), ('Year 2 (6-7yrs)', 'Year 2 (6-7yrs)'), ('Early Years (0-5yrs)', 'Early Years (0-5yrs)'), ('Keystage 1 (5-7yrs)', 'Keystage 1 (5-7yrs)'), ('Keystage 2 (7-11yrs)', 'Keystage 2 (7-11yrs)'), ('Age not applicable', 'Age not applicable')], default='5-7', max_length=20)), ('curriculum', models.CharField(blank=True, choices=[('No curriculum', 'No curriculum'), ('English', 'English'), ('Scottish', 'Scottish')], default='English', max_length=20, null=True)), + ('feature_slot', models.IntegerField(blank=True, choices=[(1, 1), (2, 2), (3, 3)], default=0, null=True, unique=True)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ], @@ -40,12 +46,26 @@ class Migration(migrations.Migration): ('name', models.CharField(max_length=255)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), + ('colour_css_class', models.CharField(blank=True, max_length=56, null=True)), + ('badge_foreground_colour', models.CharField(blank=True, max_length=56, null=True)), ], options={ 'verbose_name_plural': 'Resource Categories', }, ), migrations.CreateModel( + name='ResourceSubcategory', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ], + options={ + 'verbose_name_plural': 'Resource Subcategories', + }, + ), + migrations.CreateModel( name='ResourceType', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), @@ -53,6 +73,9 @@ class Migration(migrations.Migration): ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ], + options={ + 'verbose_name_plural': 'Resource Types', + }, ), migrations.CreateModel( name='PDFPageSnapshot', @@ -62,6 +85,9 @@ class Migration(migrations.Migration): ('file_name', models.CharField(max_length=255)), ('pdf_file', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pdf_page_snapshots', to='resources.pdfresource')), ], + options={ + 'verbose_name_plural': 'PDF Page Snapshots', + }, ), migrations.AddField( model_name='pdfresource', @@ -70,13 +96,13 @@ class Migration(migrations.Migration): ), migrations.AddField( model_name='resource', - name='additional_resource_category', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='additional_resource_category', to='resources.resourcecategory'), + name='main_resource_category', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='main_resource_category', to='resources.resourcecategory'), ), migrations.AddField( model_name='resource', - name='main_resource_category', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='main_resource_category', to='resources.resourcecategory'), + name='subcategories', + field=models.ManyToManyField(blank=True, related_name='additional_resource_category', to='resources.resourcesubcategory'), ), migrations.AddField( model_name='resource', diff --git a/alphabetlearning/resources/migrations/0002_alter_resource_additional_resource_category_and_more.py b/alphabetlearning/resources/migrations/0002_alter_resource_additional_resource_category_and_more.py deleted file mode 100644 index 3b70450..0000000 --- a/alphabetlearning/resources/migrations/0002_alter_resource_additional_resource_category_and_more.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 5.0.4 on 2024-05-15 20:00 - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('resources', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='resource', - name='additional_resource_category', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='additional_resource_category', to='resources.resourcecategory'), - ), - migrations.AlterField( - model_name='resource', - name='curriculum', - field=models.CharField(blank=True, choices=[('No curriculum', 'No curriculum'), ('English', 'English'), ('Scottish', 'Scottish')], default='English', max_length=20), - ), - ] diff --git a/alphabetlearning/resources/migrations/0002_resource_price.py b/alphabetlearning/resources/migrations/0002_resource_price.py new file mode 100644 index 0000000..899be2c --- /dev/null +++ b/alphabetlearning/resources/migrations/0002_resource_price.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.4 on 2025-01-06 17:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('resources', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='resource', + name='price', + field=models.DecimalField(decimal_places=2, default=0.0, max_digits=6), + ), + ] diff --git a/alphabetlearning/resources/migrations/0003_alter_resource_description.py b/alphabetlearning/resources/migrations/0003_alter_resource_description.py deleted file mode 100644 index f0ed99c..0000000 --- a/alphabetlearning/resources/migrations/0003_alter_resource_description.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.0.4 on 2024-05-16 11:33 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('resources', '0002_alter_resource_additional_resource_category_and_more'), - ] - - operations = [ - migrations.AlterField( - model_name='resource', - name='description', - field=models.TextField(help_text='\n <strong>Markdown acceptable here!</strong>This is your opportunity to clearly explain what\n your resource is all about! It’s worth remembering that you are using the space to\n communicate to two different audiences. Firstly, think about what fellow teachers\n would like to know, such as exactly what the resource contains and how it could be used in\n the classroom. Secondly, the words you include on this page are also talking to internal and\n external search engines. External search engines, like Google, show the first 155 characters\n of the resource description, so make sure you take advantage\n of these characters by using lots of relevant keywords as part of an enticing pitch.\n', max_length=5000), - ), - ] diff --git a/alphabetlearning/resources/migrations/0003_remove_resource_price.py b/alphabetlearning/resources/migrations/0003_remove_resource_price.py new file mode 100644 index 0000000..3bcd707 --- /dev/null +++ b/alphabetlearning/resources/migrations/0003_remove_resource_price.py @@ -0,0 +1,17 @@ +# Generated by Django 5.1.4 on 2025-01-06 19:40 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('resources', '0002_resource_price'), + ] + + operations = [ + migrations.RemoveField( + model_name='resource', + name='price', + ), + ] diff --git a/alphabetlearning/resources/migrations/0004_resource_feature_slot_1_resource_feature_slot_2_and_more.py b/alphabetlearning/resources/migrations/0004_resource_feature_slot_1_resource_feature_slot_2_and_more.py deleted file mode 100644 index d595b62..0000000 --- a/alphabetlearning/resources/migrations/0004_resource_feature_slot_1_resource_feature_slot_2_and_more.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by Django 5.0.4 on 2024-05-22 19:24 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('resources', '0003_alter_resource_description'), - ] - - operations = [ - migrations.AddField( - model_name='resource', - name='feature_slot_1', - field=models.IntegerField(choices=[(1, 1), (2, 2), (3, 3)], null=True, unique=True), - ), - migrations.AddField( - model_name='resource', - name='feature_slot_2', - field=models.IntegerField(choices=[(1, 1), (2, 2), (3, 3)], null=True, unique=True), - ), - migrations.AddField( - model_name='resource', - name='feature_slot_3', - field=models.IntegerField(choices=[(1, 1), (2, 2), (3, 3)], null=True, unique=True), - ), - ] diff --git a/alphabetlearning/resources/migrations/0005_rename_feature_slot_1_resource_feature_slot_and_more.py b/alphabetlearning/resources/migrations/0005_rename_feature_slot_1_resource_feature_slot_and_more.py deleted file mode 100644 index 2937c50..0000000 --- a/alphabetlearning/resources/migrations/0005_rename_feature_slot_1_resource_feature_slot_and_more.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Django 5.0.4 on 2024-05-22 19:26 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('resources', '0004_resource_feature_slot_1_resource_feature_slot_2_and_more'), - ] - - operations = [ - migrations.RenameField( - model_name='resource', - old_name='feature_slot_1', - new_name='feature_slot', - ), - migrations.RemoveField( - model_name='resource', - name='feature_slot_2', - ), - migrations.RemoveField( - model_name='resource', - name='feature_slot_3', - ), - ] diff --git a/alphabetlearning/resources/migrations/0006_resource_card_description_and_more.py b/alphabetlearning/resources/migrations/0006_resource_card_description_and_more.py deleted file mode 100644 index d343e76..0000000 --- a/alphabetlearning/resources/migrations/0006_resource_card_description_and_more.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 5.0.4 on 2024-05-26 15:09 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('resources', '0005_rename_feature_slot_1_resource_feature_slot_and_more'), - ] - - operations = [ - migrations.AddField( - model_name='resource', - name='card_description', - field=models.TextField(blank=True, help_text="If you enter text here, it will be used in the 'card' description box on the home page. Max 1000 characters.", max_length=1000, null=True), - ), - migrations.AlterField( - model_name='resource', - name='feature_slot', - field=models.IntegerField(blank=True, choices=[(1, 1), (2, 2), (3, 3)], null=True, unique=True), - ), - ] diff --git a/alphabetlearning/resources/migrations/0007_alter_resource_feature_slot.py b/alphabetlearning/resources/migrations/0007_alter_resource_feature_slot.py deleted file mode 100644 index c5c17c7..0000000 --- a/alphabetlearning/resources/migrations/0007_alter_resource_feature_slot.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.0.4 on 2024-05-26 15:23 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('resources', '0006_resource_card_description_and_more'), - ] - - operations = [ - migrations.AlterField( - model_name='resource', - name='feature_slot', - field=models.IntegerField(blank=True, choices=[(0, 0), (1, 1), (2, 2), (3, 3)], default=0, null=True, unique=True), - ), - ] diff --git a/alphabetlearning/resources/migrations/0008_alter_resource_card_description.py b/alphabetlearning/resources/migrations/0008_alter_resource_card_description.py deleted file mode 100644 index 18e5739..0000000 --- a/alphabetlearning/resources/migrations/0008_alter_resource_card_description.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.0.4 on 2024-05-26 15:42 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('resources', '0007_alter_resource_feature_slot'), - ] - - operations = [ - migrations.AlterField( - model_name='resource', - name='card_description', - field=models.TextField(blank=True, default='', help_text="If you enter text here, it will be used in the 'card' description box on the home page. Max 1000 characters.", max_length=1000), - ), - ] diff --git a/alphabetlearning/resources/migrations/0009_alter_resource_feature_slot.py b/alphabetlearning/resources/migrations/0009_alter_resource_feature_slot.py deleted file mode 100644 index ca082d4..0000000 --- a/alphabetlearning/resources/migrations/0009_alter_resource_feature_slot.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.0.4 on 2024-05-26 18:17 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('resources', '0008_alter_resource_card_description'), - ] - - operations = [ - migrations.AlterField( - model_name='resource', - name='feature_slot', - field=models.IntegerField(blank=True, choices=[(1, 1), (2, 2), (3, 3)], default=0, null=True, unique=True), - ), - ] diff --git a/alphabetlearning/resources/migrations/0010_alter_resource_age_range.py b/alphabetlearning/resources/migrations/0010_alter_resource_age_range.py deleted file mode 100644 index 49c7a2c..0000000 --- a/alphabetlearning/resources/migrations/0010_alter_resource_age_range.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.0.4 on 2024-07-11 14:47 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('resources', '0009_alter_resource_feature_slot'), - ] - - operations = [ - migrations.AlterField( - model_name='resource', - name='age_range', - field=models.CharField(choices=[('Preschool (3-4yrs)', 'Preschool (3-4yrs)'), ('Nursery (2-5yrs)', 'Nursery (2-5yrs)'), ('Reception (4-5yrs)', 'Reception (4-5yrs)'), ('Year 1 (5-6yrs)', 'Year 1 (5-6yrs)'), ('Year 2 (6-7yrs)', 'Year 2 (6-7yrs)'), ('Early Years (0-5yrs)', 'Early Years (0-5yrs)'), ('Keystage 1 (5-7yrs)', 'Keystage 1 (5-7yrs)'), ('Keystage 2 (7-11yrs)', 'Keystage 2 (7-11yrs)'), ('Age not applicable', 'Age not applicable')], default='5-7', max_length=20), - ), - ] diff --git a/alphabetlearning/resources/migrations/0011_alter_resource_curriculum.py b/alphabetlearning/resources/migrations/0011_alter_resource_curriculum.py deleted file mode 100644 index 5e1b193..0000000 --- a/alphabetlearning/resources/migrations/0011_alter_resource_curriculum.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.0.4 on 2024-07-11 14:50 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('resources', '0010_alter_resource_age_range'), - ] - - operations = [ - migrations.AlterField( - model_name='resource', - name='curriculum', - field=models.CharField(blank=True, choices=[('No curriculum', 'No curriculum'), ('English', 'English'), ('Scottish', 'Scottish')], default='English', max_length=20, null=True), - ), - ] diff --git a/alphabetlearning/resources/migrations/0012_resourcecategory_colour_css_class.py b/alphabetlearning/resources/migrations/0012_resourcecategory_colour_css_class.py deleted file mode 100644 index b48ba61..0000000 --- a/alphabetlearning/resources/migrations/0012_resourcecategory_colour_css_class.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.0.4 on 2024-07-11 15:47 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('resources', '0011_alter_resource_curriculum'), - ] - - operations = [ - migrations.AddField( - model_name='resourcecategory', - name='colour_css_class', - field=models.CharField(blank=True, max_length=56, null=True), - ), - ] diff --git a/alphabetlearning/resources/migrations/0013_resourcecategory_badge_foreground_colour.py b/alphabetlearning/resources/migrations/0013_resourcecategory_badge_foreground_colour.py deleted file mode 100644 index 7644a5c..0000000 --- a/alphabetlearning/resources/migrations/0013_resourcecategory_badge_foreground_colour.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.0.4 on 2024-07-28 15:12 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("resources", "0012_resourcecategory_colour_css_class"), - ] - - operations = [ - migrations.AddField( - model_name="resourcecategory", - name="badge_foreground_colour", - field=models.CharField(blank=True, max_length=56, null=True), - ), - ] diff --git a/alphabetlearning/resources/migrations/0014_remove_resource_additional_resource_category_and_more.py b/alphabetlearning/resources/migrations/0014_remove_resource_additional_resource_category_and_more.py deleted file mode 100644 index 7573bf2..0000000 --- a/alphabetlearning/resources/migrations/0014_remove_resource_additional_resource_category_and_more.py +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by Django 5.0.4 on 2024-07-29 14:52 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("resources", "0013_resourcecategory_badge_foreground_colour"), - ] - - operations = [ - migrations.RemoveField( - model_name="resource", - name="additional_resource_category", - ), - migrations.AddField( - model_name="resource", - name="additional_resource_category", - field=models.ManyToManyField( - blank=True, - null=True, - related_name="additional_resource_category", - to="resources.resourcecategory", - ), - ), - ] diff --git a/alphabetlearning/resources/migrations/0015_resourcesubcategory.py b/alphabetlearning/resources/migrations/0015_resourcesubcategory.py deleted file mode 100644 index 3eaada4..0000000 --- a/alphabetlearning/resources/migrations/0015_resourcesubcategory.py +++ /dev/null @@ -1,30 +0,0 @@ -# Generated by Django 5.0.4 on 2024-07-29 14:55 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("resources", "0014_remove_resource_additional_resource_category_and_more"), - ] - - operations = [ - migrations.CreateModel( - name="ResourceSubcategory", - fields=[ - ( - "id", - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ("name", models.CharField(max_length=255)), - ("created_at", models.DateTimeField(auto_now_add=True)), - ("updated_at", models.DateTimeField(auto_now=True)), - ], - ), - ] diff --git a/alphabetlearning/resources/migrations/0016_alter_resourcesubcategory_options_and_more.py b/alphabetlearning/resources/migrations/0016_alter_resourcesubcategory_options_and_more.py deleted file mode 100644 index 77a3f27..0000000 --- a/alphabetlearning/resources/migrations/0016_alter_resourcesubcategory_options_and_more.py +++ /dev/null @@ -1,31 +0,0 @@ -# Generated by Django 5.0.4 on 2024-07-29 15:36 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("resources", "0015_resourcesubcategory"), - ] - - operations = [ - migrations.AlterModelOptions( - name="resourcesubcategory", - options={"verbose_name_plural": "Resource Subcategories"}, - ), - migrations.AlterModelOptions( - name="resourcetype", - options={"verbose_name_plural": "Resource Types"}, - ), - migrations.AlterField( - model_name="resource", - name="additional_resource_category", - field=models.ManyToManyField( - blank=True, - null=True, - related_name="additional_resource_category", - to="resources.resourcesubcategory", - ), - ), - ] diff --git a/alphabetlearning/resources/migrations/0017_rename_additional_resource_category_resource_subcategories.py b/alphabetlearning/resources/migrations/0017_rename_additional_resource_category_resource_subcategories.py deleted file mode 100644 index bc4d1e4..0000000 --- a/alphabetlearning/resources/migrations/0017_rename_additional_resource_category_resource_subcategories.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 5.0.4 on 2024-08-01 14:29 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ("resources", "0016_alter_resourcesubcategory_options_and_more"), - ] - - operations = [ - migrations.RenameField( - model_name="resource", - old_name="additional_resource_category", - new_name="subcategories", - ), - ] diff --git a/alphabetlearning/resources/migrations/0018_alter_resource_subcategories.py b/alphabetlearning/resources/migrations/0018_alter_resource_subcategories.py deleted file mode 100644 index c981512..0000000 --- a/alphabetlearning/resources/migrations/0018_alter_resource_subcategories.py +++ /dev/null @@ -1,25 +0,0 @@ -# Generated by Django 5.0.4 on 2024-08-01 15:08 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ( - "resources", - "0017_rename_additional_resource_category_resource_subcategories", - ), - ] - - operations = [ - migrations.AlterField( - model_name="resource", - name="subcategories", - field=models.ManyToManyField( - blank=True, - related_name="additional_resource_category", - to="resources.resourcesubcategory", - ), - ), - ] diff --git a/alphabetlearning/resources/migrations/0019_alter_pdfpagesnapshot_options_and_more.py b/alphabetlearning/resources/migrations/0019_alter_pdfpagesnapshot_options_and_more.py deleted file mode 100644 index 511d747..0000000 --- a/alphabetlearning/resources/migrations/0019_alter_pdfpagesnapshot_options_and_more.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Django 5.0.4 on 2024-09-03 19:21 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("resources", "0018_alter_resource_subcategories"), - ] - - operations = [ - migrations.AlterModelOptions( - name="pdfpagesnapshot", - options={"verbose_name_plural": "PDF Page Snapshots"}, - ), - migrations.AlterModelOptions( - name="pdfresource", - options={"verbose_name_plural": "PDF Resources"}, - ), - migrations.AddField( - model_name="resource", - name="price", - field=models.DecimalField(decimal_places=2, default=0.0, max_digits=6), - ), - ] diff --git a/alphabetlearning/resources/migrations/0020_remove_resource_price_resource_stripe_product_id.py b/alphabetlearning/resources/migrations/0020_remove_resource_price_resource_stripe_product_id.py deleted file mode 100644 index 088556b..0000000 --- a/alphabetlearning/resources/migrations/0020_remove_resource_price_resource_stripe_product_id.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 5.0.4 on 2024-10-19 15:11 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('resources', '0019_alter_pdfpagesnapshot_options_and_more'), - ] - - operations = [ - migrations.RemoveField( - model_name='resource', - name='price', - ), - migrations.AddField( - model_name='resource', - name='stripe_product_id', - field=models.CharField(default='baws', max_length=100), - preserve_default=False, - ), - ] diff --git a/alphabetlearning/resources/models.py b/alphabetlearning/resources/models.py index 6881483..3f4ee8c 100644 --- a/alphabetlearning/resources/models.py +++ b/alphabetlearning/resources/models.py @@ -39,11 +39,11 @@ class Resource(models.Model): name = models.CharField(max_length=255, null=False) stripe_product_id = models.CharField(max_length=100) # price = models.DecimalField( - # max_digits=6, - # decimal_places=2, - # default=0.00, - # null=False, - # blank=False, + # max_digits=6, + # decimal_places=2, + # default=0.00, + # null=False, + # blank=False, # ) thumbnail_filenames = models.JSONField( null=False, diff --git a/alphabetlearning/resources/tests/test_forms.py b/alphabetlearning/resources/tests/test_forms.py index aebc110..465dc58 100644 --- a/alphabetlearning/resources/tests/test_forms.py +++ b/alphabetlearning/resources/tests/test_forms.py @@ -1,14 +1,12 @@ import pytest +from alphabetlearning.resources.factories import ResourceModelFactory +from alphabetlearning.resources.forms import ResourceCreateForm +from alphabetlearning.resources.models import ResourceCategory, ResourceType from django.core.files.uploadedfile import SimpleUploadedFile from django.db import IntegrityError from django.test import TestCase from django.utils.datastructures import MultiValueDict -from alphabetlearning.resources.factories import ResourceModelFactory -from alphabetlearning.resources.forms import ResourceCreateForm -from alphabetlearning.resources.models import ResourceCategory -from alphabetlearning.resources.models import ResourceType - class ResourceCreateFormTest(TestCase): def setUp(self): @@ -55,7 +53,7 @@ class ResourceCreateFormTest(TestCase): @pytest.mark.django_db() def test_featured_slots_must_be_unique(self): - r1 = ResourceModelFactory(feature_slot=1) + _ = ResourceModelFactory(feature_slot=1) with pytest.raises(IntegrityError): ResourceModelFactory(feature_slot=1) diff --git a/alphabetlearning/resources/views.py b/alphabetlearning/resources/views.py index 8b0f8c5..508c187 100644 --- a/alphabetlearning/resources/views.py +++ b/alphabetlearning/resources/views.py @@ -9,26 +9,16 @@ from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import login_required from django.core.paginator import Paginator -from django.db import IntegrityError -from django.db import transaction -from django.shortcuts import get_object_or_404 -from django.shortcuts import redirect -from django.shortcuts import render +from django.db import IntegrityError, transaction +from django.shortcuts import get_object_or_404, redirect, render from . import services -from .forms import ResourceCreateForm -from .forms import ResourceUpdateMetadataForm -from .forms import ResourceUpdatePDFsForm -from .forms import ResourceUpdateThumbnailsForm -from .models import PDFPageSnapshot -from .models import PDFResource -from .models import Resource -from .models import ResourceCategory -from .models import ResourceSubcategory -from .s3 import get_presigned_obj_url -from .s3 import upload_files_to_s3 -from .s3 import upload_snapshotted_pages_to_s3 -from .s3 import upload_to_s3 +from .forms import (ResourceCreateForm, ResourceUpdateMetadataForm, + ResourceUpdatePDFsForm, ResourceUpdateThumbnailsForm) +from .models import (PDFPageSnapshot, PDFResource, Resource, ResourceCategory, + ResourceSubcategory) +from .s3 import (get_presigned_obj_url, upload_files_to_s3, + upload_snapshotted_pages_to_s3, upload_to_s3) logger = logging.getLogger(__name__) |