diff --git a/testimonials/fixtures/avatars/Anesha Santhanam.png b/testimonials/fixtures/avatars/Anesha Santhanam.png new file mode 100644 index 0000000000..dda9ec5b2f Binary files /dev/null and b/testimonials/fixtures/avatars/Anesha Santhanam.png differ diff --git a/testimonials/fixtures/avatars/Arthur Julio Nelson.png b/testimonials/fixtures/avatars/Arthur Julio Nelson.png new file mode 100644 index 0000000000..9a52a69362 Binary files /dev/null and b/testimonials/fixtures/avatars/Arthur Julio Nelson.png differ diff --git a/testimonials/fixtures/avatars/Brenda Patel.png b/testimonials/fixtures/avatars/Brenda Patel.png new file mode 100644 index 0000000000..20ff30b7af Binary files /dev/null and b/testimonials/fixtures/avatars/Brenda Patel.png differ diff --git a/testimonials/fixtures/avatars/Chansa Kabwe.png b/testimonials/fixtures/avatars/Chansa Kabwe.png new file mode 100644 index 0000000000..0eb29691b3 Binary files /dev/null and b/testimonials/fixtures/avatars/Chansa Kabwe.png differ diff --git a/testimonials/fixtures/avatars/Claudio Mirti.png b/testimonials/fixtures/avatars/Claudio Mirti.png new file mode 100644 index 0000000000..3e73e51d7f Binary files /dev/null and b/testimonials/fixtures/avatars/Claudio Mirti.png differ diff --git a/testimonials/fixtures/avatars/Emily R. Wright.png b/testimonials/fixtures/avatars/Emily R. Wright.png new file mode 100644 index 0000000000..55f9b092cf Binary files /dev/null and b/testimonials/fixtures/avatars/Emily R. Wright.png differ diff --git a/testimonials/fixtures/avatars/Emmanuel Kasigazi.png b/testimonials/fixtures/avatars/Emmanuel Kasigazi.png new file mode 100644 index 0000000000..7924fb05ba Binary files /dev/null and b/testimonials/fixtures/avatars/Emmanuel Kasigazi.png differ diff --git a/testimonials/fixtures/avatars/Jasmine Latham.png b/testimonials/fixtures/avatars/Jasmine Latham.png new file mode 100644 index 0000000000..8d1d8275a7 Binary files /dev/null and b/testimonials/fixtures/avatars/Jasmine Latham.png differ diff --git a/testimonials/fixtures/avatars/John Goodloe.png b/testimonials/fixtures/avatars/John Goodloe.png new file mode 100644 index 0000000000..6607038ab1 Binary files /dev/null and b/testimonials/fixtures/avatars/John Goodloe.png differ diff --git a/testimonials/fixtures/avatars/Lauren Moscioni.png b/testimonials/fixtures/avatars/Lauren Moscioni.png new file mode 100644 index 0000000000..9c1c14199f Binary files /dev/null and b/testimonials/fixtures/avatars/Lauren Moscioni.png differ diff --git a/testimonials/fixtures/avatars/Linda Obregon.png b/testimonials/fixtures/avatars/Linda Obregon.png new file mode 100644 index 0000000000..a2ebab302b Binary files /dev/null and b/testimonials/fixtures/avatars/Linda Obregon.png differ diff --git a/testimonials/fixtures/avatars/Maria Eduarda.png b/testimonials/fixtures/avatars/Maria Eduarda.png new file mode 100644 index 0000000000..a604b08520 Binary files /dev/null and b/testimonials/fixtures/avatars/Maria Eduarda.png differ diff --git a/testimonials/fixtures/avatars/Murali Thyagarajan.png b/testimonials/fixtures/avatars/Murali Thyagarajan.png new file mode 100644 index 0000000000..f30c105bda Binary files /dev/null and b/testimonials/fixtures/avatars/Murali Thyagarajan.png differ diff --git a/testimonials/fixtures/avatars/Sebastian Bello.png b/testimonials/fixtures/avatars/Sebastian Bello.png new file mode 100644 index 0000000000..8e40ca5aef Binary files /dev/null and b/testimonials/fixtures/avatars/Sebastian Bello.png differ diff --git a/testimonials/fixtures/avatars/Stephen Okiya.png b/testimonials/fixtures/avatars/Stephen Okiya.png new file mode 100644 index 0000000000..a3e7a0e998 Binary files /dev/null and b/testimonials/fixtures/avatars/Stephen Okiya.png differ diff --git a/testimonials/migrations/0005_load_fixtures.py b/testimonials/migrations/0005_load_fixtures.py new file mode 100644 index 0000000000..c9408ecc6c --- /dev/null +++ b/testimonials/migrations/0005_load_fixtures.py @@ -0,0 +1,256 @@ +# Generated by Django 4.2.13 on 2024-06-25 15:30 + +import logging +from pathlib import Path + +from django.core.files import File +from django.db import migrations + +""" +Fix an issue with PIL's logger when running in test +https://github.com/camptocamp/pytest-odoo/issues/15 +""" +pil_logger = logging.getLogger("PIL") +pil_logger.setLevel(logging.INFO) + +fixtures = [ + { + "attestant_name": "Maria Eduarda", + "title": "Independent Learner, Brazil", + "quote": ( + "I am not exaggerating when I say MIT OpenCourseWare " + "has changed my life significantly for the better… " + "I would never have had the opportunity to " + "take Calculus during high school, let alone Solid State Chemistry. " + "These courses have greatly expanded my " + "interests and opportunities and I'm forever grateful for that." + ), + "position": 1, + "offerors": ["ocw"], + }, + { + "attestant_name": "Chansa Kabwe", + "title": "Independent Learner, Zambia", + "quote": ( + "OpenCourseWare continues to be a big part of my career." + " My foundation is linked to it — I don't know if " + "I would be the same engineer today if not for OpenCourseWare." + ), + "position": 1, + "offerors": ["ocw"], + }, + { + "attestant_name": "Emmanuel Kasigazi", + "title": "Entrepreneur, Uganda", + "quote": ( + "This is what OpenCourseWare has enabled me to do: " + "I get the chance to not only watch the " + "future happen, but I can actually be a part of it and create it." + ), + "position": 1, + "offerors": ["ocw"], + }, + { + "attestant_name": "Arthur Julio Nelson", + "title": "Brand Strategy Lead, Google", + "quote": ( + "The Bootcamp is, well, it's an accelerator " + "meets a creativity incubator. " + "It's all of these things mashed into one. " + "If you come into the Bootcamp with a " + "purpose and desire for impact and where you want " + "to channel it, the Bootcamp will help you unleash it." + ), + "position": 1, + "offerors": ["bootcamps"], + }, + { + "attestant_name": "Jasmine Latham", + "title": "Lead Data Scientist, Office for National Statistics", + "quote": ( + "I am very pleased with the course content, " + "it is exactly the level I am looking for. " + "Each professor/course presenter has packed " + "a lot of information and has explained complex " + "algorithms in good detail. " + "Some with good sense of humor. Thank you very much." + ), + "position": 1, + "offerors": ["xpro"], + }, + { + "attestant_name": "Lauren Moscioni", + "title": "Associate, Morgan Stanley", + "quote": ( + "Coming from the finance sector, " + "I wanted to learn more about real estate as an " + "alternative investment for ultra-high-net-worth clients. " + "What I got from MIT was a well-rounded, " + "holistic view of the state of the field." + ), + "position": 1, + "offerors": ["mitpe"], + }, + { + "attestant_name": "Sebastian Bello", + "title": "MicroMasters learner", + "quote": ( + "I did the Micromaster in supply chain, " + "what motivated me the most to finish it was " + "to have a certificate in supply chain " + "from MIT to improve my career. I was so engaged with " + "the courses that I wanted to continue learning, " + "now I'm doing the Supply Chain Management Master's at MIT." + ), + "position": 1, + "offerors": ["mitx"], + }, + { + "attestant_name": "John Goodloe", + "title": ( + "Senior Director for Society Business Solutions, " + "American Chemical Society (ACS)" + ), + "quote": ( + "The courses at MIT Sloan Executive Education brought together " + "true leaders from across the world. You're in classes with diplomats, " + "CEOs, heads of family businesses and " + "Fortune 500s—every course is a different mix." + ), + "position": 1, + "offerors": ["see"], + }, + { + "attestant_name": "Linda Obregon", + "title": "Founder and CEO", + "quote": ( + "The program experience was 10-fold compared to what I expected. " + "They not only taught me how to create " + "a company in a week, but they gave me a " + "supportive network of the best " + "and brightest minds. After I left the Bootcamp, " + "I founded a startup that uses science and" + " plants to develop high-protein and tasty new foods." + ), + "position": 1, + "offerors": ["bootcamps"], + }, + { + "attestant_name": "Murali Thyagarajan", + "title": "DBA & Application Support, NASDAQ", + "quote": ( + "The course was easy to understand and had depth. " + "All the concepts were clearly laid out and explained. " + "This is the best course I have come across on this topic." + ), + "position": 2, + "offerors": ["xpro"], + }, + { + "attestant_name": "Claudio Mirti", + "title": "Senior Advanced Analytics and AI Specialist, Microsoft", + "quote": ( + "The Certificate Program in Machine Learning and AI is a great experience. " + "You get a lot of powerful insights during " + "exchanges with the professors and other " + "students—and you learn how to incorporate the " + "material into your daily work." + ), + "position": 2, + "offerors": ["mitpe"], + }, + { + "attestant_name": "Stephen Okiya", + "title": "MITx Learner", + "quote": ( + "I am really grateful for the efforts by MIT in coming up with innovative " + "ways of making quality education affordable " + "and accessible to everyone all over the world. " + "I am sure that the programs impact the lives of millions of " + "people either directly or indirectly " + "hence making the world a better place." + ), + "position": 2, + "offerors": ["mitx"], + }, + { + "attestant_name": "Brenda Patel", + "title": "CEO, Bonova Advisory", + "quote": ( + "You're a part of an ecosystem that is a life-long community of " + "people with the same goal to create something new and valuable. " + "It's an investment of five days, but it stays with you forever." + ), + "position": 2, + "offerors": ["see"], + }, + { + "attestant_name": "Emily R. Wright", + "title": "Versatile Technologist", + "quote": ( + "This is an awesome program for emerging leaders " + "and for those currently in leadership positions. " + "The knowledge, tools, and techniques " + "are very useful to companies worldwide. " + "I would highly recommend this program to all levels of employees." + ), + "position": 3, + "offerors": ["xpro"], + }, + { + "attestant_name": "Anesha Santhanam", + "title": "MITx Learner", + "quote": ( + "I recently completed an MITx course in Python, " + "and it was phenomenal. I looked into this course to " + "give me a better foundation and a deeper " + "understanding so I could use Python " + "in other settings and applications. " + "I'm using what I learned everyday to further my passion, " + "so thank you for providing me with this opportunity!" + ), + "position": 3, + "offerors": ["mitx"], + }, +] + + +def load_fixtures(apps, schema_editor): + """ + Load fixtures for testimonials + """ + Attestation = apps.get_model("testimonials", "Attestation") + LearningResourceOfferor = apps.get_model( + "learning_resources", "LearningResourceOfferor" + ) + + for fixture in fixtures: + offerors = fixture.pop("offerors") + testimonial, _ = Attestation.objects.get_or_create( + attestant_name=fixture["attestant_name"], + title=fixture["title"], + defaults=fixture, + ) + # make sure related offerors exists in system before setting + if LearningResourceOfferor.objects.filter(pk__in=offerors).count() == len( + offerors + ): + testimonial.offerors.set(offerors) + if not testimonial.avatar: + """ + Save the image from fixture so alternate sizes are generated + """ + with Path.open( + f"testimonials/fixtures/avatars/{fixture["attestant_name"]}.png", "rb" + ) as imagefile: + testimonial.avatar.save("avatar.png", File(imagefile), save=True) + + +class Migration(migrations.Migration): + dependencies = [ + ("testimonials", "0004_update_attestation_avatar_make_optional"), + ] + + operations = [ + migrations.RunPython(load_fixtures, migrations.RunPython.noop), + ] diff --git a/testimonials/views_test.py b/testimonials/views_test.py index 0c58d0a583..e412bbfe46 100644 --- a/testimonials/views_test.py +++ b/testimonials/views_test.py @@ -18,7 +18,7 @@ def test_attestation_list(client): """Test that attestations can be listed""" - + Attestation.objects.all().delete() attestation_batch = sorted(AttestationFactory.create_batch(5), key=lambda a: a.id) list_url = reverse("testimonials:v0:testimonials_api-list") @@ -49,6 +49,7 @@ def test_attestation_filters( last attestation; otherwise, it'll be for the channel and the offeror added to the 4th attestation. """ + Attestation.objects.all().delete() attestation_batch = sorted(AttestationFactory.create_batch(6), key=lambda a: a.id) api_params = {} @@ -108,6 +109,7 @@ def test_attestation_filters( def test_attestation_published(client): """Test that just published attestations are listed""" + Attestation.objects.all().delete() attestation_batch = sorted(AttestationFactory.create_batch(4), key=lambda a: a.id) @@ -151,6 +153,7 @@ def test_attestation_order(client): - In the case where more than one row has the same position, they should be displayed in order of `updated_on` for that position. """ + Attestation.objects.all().delete() attestation_batch = [AttestationFactory.create(position=i) for i in range(1, 6)]