# Generated by Django 6.1 on 2026-09-15 13:30

from django.db import migrations


def seed_books(apps, schema_editor):
    Language = apps.get_model("catalog", "Language")
    Genre = apps.get_model("catalog", "Genre")
    Author = apps.get_model("catalog", "Author")
    Book = apps.get_model("catalog", "Book")
    BookInstance = apps.get_model("catalog", "BookInstance")

    english, created = Language.objects.get_or_create(
        name__iexact="English", defaults={"name": "English"}
    )
    Language.objects.get_or_create(name__iexact="Español", defaults={"name": "Español"})
    Language.objects.get_or_create(
        name__iexact="Français", defaults={"name": "Français"}
    )
    Language.objects.get_or_create(name__iexact="Malti", defaults={"name": "Malti"})
    Language.objects.get_or_create(name__iexact="Deutsch", defaults={"name": "Deutsch"})
    Language.objects.get_or_create(
        name__iexact="Italiano", defaults={"name": "Italiano"}
    )
    Language.objects.get_or_create(
        name__iexact="Português", defaults={"name": "Português"}
    )
    Language.objects.get_or_create(
        name__iexact="Nederlands", defaults={"name": "Nederlands"}
    )
    Language.objects.get_or_create(name__iexact="中文", defaults={"name": "中文"})
    Language.objects.get_or_create(name__iexact="日本語", defaults={"name": "日本語"})
    Language.objects.get_or_create(name__iexact="한국어", defaults={"name": "한국어"})
    Language.objects.get_or_create(name__iexact="العربية", defaults={"name": "العربية"})
    Language.objects.get_or_create(name__iexact="हिन्दी", defaults={"name": "हिन्दी"})
    Language.objects.get_or_create(name__iexact="Polski", defaults={"name": "Polski"})

    history, genre_history_created = Genre.objects.get_or_create(
        name__iexact="History", defaults={"name": "History"}
    )
    computer_science, genre_computer_science_created = Genre.objects.get_or_create(
        name="Computer Science"
    )
    childrens_humor, genre_childrens_humor_created = Genre.objects.get_or_create(
        name="Children's Humor"
    )
    science_fiction, genre_science_fiction_created = Genre.objects.get_or_create(
        name="Science Fiction"
    )
    graphic_novels, genre_graphic_novels_created = Genre.objects.get_or_create(
        name="Graphic Novels"
    )
    politics, genre_politics_created = Genre.objects.get_or_create(
        name__iexact="Politics", defaults={"name": "Politics"}
    )
    food, genre_food_created = Genre.objects.get_or_create(
        name__iexact="Food Science", defaults={"name": "Food Science"}
    )
    kids, genre_kids_created = Genre.objects.get_or_create(
        name__iexact="Children's Literature", defaults={"name": "Children's Literature"}
    )

    snyder, author_snyder_created = Author.objects.get_or_create(
        first_name="Timothy", last_name="Snyder"
    )
    downey, author_downey_created = Author.objects.get_or_create(
        first_name="Allen", last_name="Downey"
    )
    novak, author_novak_created = Author.objects.get_or_create(
        first_name="B. J.", last_name="Novak"
    )
    adams, author_adams_created = Author.objects.get_or_create(
        first_name="Douglas", last_name="Adams"
    )
    stevenson, author_stevenson_created = Author.objects.get_or_create(
        first_name="N. D.", last_name="Stevenson"
    )
    hooks, author_hooks_created = Author.objects.get_or_create(
        first_name="bell", last_name="hooks"
    )
    frye, author_frye_created = Author.objects.get_or_create(
        first_name="Marilyn", last_name="Frye"
    )
    kenji, author_kenji_created = Author.objects.get_or_create(
        first_name="J. Kenji", last_name="López-Alt"
    )

    b_history, b_history_created = Book.objects.get_or_create(
        title="On Tyranny",
        author=snyder,
        summary="The Founding Fathers tried to protect us from the threat they knew, the tyranny that overcame ancient democracy. Today, our political order faces new threats, not unlike the totalitarianism of the twentieth century. We are no wiser than the Europeans who saw democracy yield to fascism, Nazism, or communism. Our one advantage is that we might learn from their experience.",
        isbn="0804190119",
        language=english,
    )
    b_history.genre.set([history])
    b_history.save()

    b_computer_science, b_computer_science_created = Book.objects.get_or_create(
        title="Think Python: How to Think Like a Computer Scientist",
        author=downey,
        summary="Python is an excellent way to get started in programming, and this clear, concise guide walks you through Python a step at a time--beginning with basic programming concepts before moving on to functions, data structures, and object-oriented design. This revised third edition reflects the growing role of large language models (LLMs) in programming and includes exercises on effective LLM prompts, testing code, and debugging skills.",
        isbn="1098155432",
        language=english,
    )
    b_computer_science.genre.set([computer_science])
    b_computer_science.save()

    b_childrens_humor, b_childrens_humor_created = Book.objects.get_or_create(
        title="The Book with No Pictures",
        author=novak,
        summary="You might think a book with no pictures seems boring and serious. Except... here's how books work. Everything written on the page has to be said by the person reading it aloud. Even if the words say... BLORK. Or BLUURF. Even if the words are a preposterous song about eating ants for breakfast, or just a list of astonishingly goofy sounds like BLAGGITY BLAGGITY and GLIBBITY GLOBBITY. Cleverly irreverent and irresistibly silly, The Book with No Pictures is one that kids will beg to hear again and again. (And parents will be happy to oblige.)",
        isbn="0803741715",
        language=english,
    )
    b_childrens_humor.genre.set([childrens_humor])
    b_childrens_humor.save()

    b_science_fiction, b_science_fiction_created = Book.objects.get_or_create(
        title="Hitchhiker's Guide to the Galaxy",
        author=adams,
        summary="Seconds before the Earth is demolished to make way for a galactic freeway, Arthur Dent is plucked off the planet by his friend Ford Prefect, a researcher for the revised edition of The Hitchhiker's Guide to the Galaxy who, for the last 15 years, has been posing as an out-of-work actor. Together this dynamic pair begin a journey through space aided by quotes from The Hitchhiker's Guide (\"A towel is about the most massively useful thing an interstellar hitchhiker can have.\") and a galaxy full of fellow travelers: Zaphod Beeblebrox, the two-headed, three-armed ex-hippie and totally out-to-lunch president of the galaxy; Trillian, Zaphod's girlfriend (formally Tricia McMillan), whom Arthur tried to pick up at a cocktail party once upon a time zone; Marvin, a paranoid, brilliant, and chronically depressed robot; and Veet Voojagig, a former graduate student who is obsessed with the disappearance of all the ballpoint pens he bought over the years.",
        isbn="0345418913",
        language=english,
    )
    b_science_fiction.genre.set([science_fiction])
    b_science_fiction.save()

    b_graphic_novels, b_graphic_novels_created = Book.objects.get_or_create(
        title="Nimona",
        author=stevenson,
        summary="Nimona is an impulsive young shapeshifter with a knack for villainy. Lord Ballister Blackheart is a villain with a vendetta. As sidekick and supervillain, Nimona and Lord Blackheart are about to wreak some serious havoc. Their mission: Prove to the kingdom that Sir Ambrosius Goldenloin and his buddies at the Institution of Law Enforcement and Heroics aren't the heroes everyone thinks they are. But as small acts of mischief escalate into a vicious battle, Lord Blackheart realizes that Nimona’s powers are as murky and mysterious as her past. And her unpredictable wild side might be more dangerous than he is willing to admit. Nemeses! Dragons! Science! Symbolism! After a decade, everyone's favorite shapeshifter continues to capture hearts.",
        isbn="0063434695",
        language=english,
    )
    b_graphic_novels.genre.set([graphic_novels])
    b_graphic_novels.save()

    b_politics, b_politics_created = Book.objects.get_or_create(
        title="Feminism Is for Everybody: Passionate Politic",
        author=hooks,
        summary="...[hooks's] is a vision of a beloved community that appeals to all those committed to equality, mutual respect, and justice. hooks applies her critical analysis to the most contentious and challenging issues facing feminists today, including reproductive rights, violence, race, class, and work. With her customary insight and unsparing honesty, hooks calls for a feminism free from divisive barriers but rich with rigorous debate. In language both eye-opening and optimistic, hooks encourages us to demand alternatives to patriarchal, racist, and homophobic culture, and to imagine a different future. hooks speaks to all those in search of true liberation, asking readers to take look at feminism in a new light, to see that it touches all lives. Issuing an invitation to participate fully in feminist movement and to benefit fully from it, hooks shows that feminism—far from being an outdated concept or one limited to an intellectual elite--is indeed for everybody.",
        isbn="0896086283",
        language=english,
    )
    b_politics.genre.set([politics])
    b_politics.save()
    b_frye, b_frye_created = Book.objects.get_or_create(
        title="The Politics of Reality: Essays in Feminist Theory",
        author=frye,
        summary="For anyone first coming to feminism, these essays serve as a backdrop ... for understanding the basic, early and continuing perspectives of feminists. And for all of us they provide a theoretical framework in which to read the present as well as the past.",
        language=english,
        isbn="9780895940995",
    )
    b_frye.genre.set([politics])
    b_frye.save()

    b_food_lab, b_food_lab_created = Book.objects.get_or_create(
        title="The Food Lab: Better Home Cooking Through Science",
        author=kenji,
        summary="Ever wondered how to pan-fry a steak with a charred crust and an interior that's perfectly medium-rare from edge to edge when you cut into it? How to make homemade mac 'n' cheese that is as satisfyingly gooey and velvety-smooth as the blue box stuff, but far tastier? How to roast a succulent, moist turkey (forget about brining!)—and use a foolproof method that works every time? As Serious Eats's culinary nerd-in-residence, J. Kenji López-Alt has pondered all these questions and more. In The Food Lab, Kenji focuses on the science behind beloved American dishes, delving into the interactions between heat, energy, and molecules that create great food. Kenji shows that often, conventional methods don't work that well, and home cooks can achieve far better results using new—but simple—techniques. In hundreds of easy-to-make recipes with over 1,000 full-color images, you will find out how to make foolproof Hollandaise sauce in just two minutes, how to transform one simple tomato sauce ...",
        isbn="0393081087",
        language=english,
    )
    b_food_lab.genre.set([food])
    b_food_lab.save()

    b_pizza_night, b_pizza_night_created = Book.objects.get_or_create(
        title="Every Night is Pizza Night",
        author=kenji,
        summary='Pipo thinks that pizza is the best. No, Pipo knows that pizza is the best. It is scientific fact. But when she sets out on a neighborhood-spanning quest to prove it, she discovers that "best" might not mean what she thought it meant.',
        isbn="1324005254",
        language=english,
    )
    b_pizza_night.genre.set([kids])
    b_pizza_night.save()

    for b in Book.objects.all():
        BookInstance.objects.create(
            book=b,
            imprint="Unlikely Imprint",
            status="a",
        )


class Migration(migrations.Migration):

    # FIXME: remove assert False and replace "000X_YOUR_MOST_RECENT_MIGRATION_NAME"
    # with the name of your most recent migration file in the dependencies list below
    # before running this migration
    assert False
    dependencies = [
        ("catalog", "000X_YOUR_MOST_RECENT_MIGRATION_NAME"),
    ]

    operations = [
        migrations.RunPython(seed_books),
    ]
