text: # Generated by Django 2.1.1 on 2018-10-26 03:41
  import sys
  from django.db import migrations
  
  def seed_data(apps, schema_editor):
      Article = apps.get_model('curate', 'Article')
      Author = apps.get_model('curate', 'Author')
      Journal = apps.get_model('curate', 'Journal')
      ArticleAuthor = apps.get_model('curate', 'ArticleAuthor')
      RelatedArticle = apps.get_model('curate', 'RelatedArticle')
      Study = apps.get_model('curate', 'Study')
      Effect = apps.get_model('curate', 'Effect')
      Collection = apps.get_model('curate', 'Collection')
      Construct = apps.get_model('curate', 'Construct')
      Hypothesis = apps.get_model('curate', 'Hypothesis')
      KeyFigure = apps.get_model('curate', 'KeyFigure')
      StatisticalResult = apps.get_model('curate', 'StatisticalResult')
      Method = apps.get_model('curate', 'Method')
      VariableRelationship = apps.get_model('curate', 'VariableRelationship')
      Transparency = apps.get_model('curate', 'Transparency')
  
      j_soc_psych = Journal.objects.create(
          name='Journal of Experimental Social Psychology',
          issn='0022-4545'
      )
  
      kenrick_et_al_1989 = Article.objects.create(
          title='Influence of popular erotica on judgments of strangers and mates',
          year=1989,
          journal=j_soc_psych, # associates the article to the journal
          doi='10.1016/0022-1031(89)90010-3',
          abstract="Two studies were done to investigate the influence of exposure to centerfold erotica on sexual attraction judgments. In Experiment 1, college students judged a photograph of a nude female after being exposed either to control stimuli (abstract art or other average nudes) or to photographs taken from popular erotic magazines. The target was judged as less sexually attractive after subjects had been exposed to popular erotica. Male and female subjects showed parallel patterns of attraction ratings. In Experiment 2, male and female subjects were exposed to opposite sex erotica. In the second study, there was an interaction of subject sex with stimulus condition upon sexual attraction ratings. Decremental effects of centerfold exposure were found only for male subjects exposed to female nudes. Males who found the Playboy-type centerfolds more pleasant rated themselves as less in love with their wives. Results are discussed in light of general gender differences in sexual behavior, and are related to the current controversy about pornography.",
          pdf_url='https://github.com/eplebel/science-commons/blob/master/curated/kgg1989/Kenrick%2C%20Gutierres%2C%20%26%20Goldbergs%20(1989)%20Study%202%20playboy%20effect.pdf',
          research_area='SOCIAL_SCIENCE',
          article_type='ORIGINAL'
      )
  
      kenrick = Author.objects.create(
          first_name='Douglas',
          last_name='Kenrick',
      )
      guiterres = Author.objects.create(
          first_name='Sara',
          last_name='Guiterres',
      )
      goldberg = Author.objects.create(
          first_name='Laurie',
          last_name='Goldberg'
      )
  
      # Because Author-Article relationship is a many-to-many with a "through model",
      # We cannot directly assign it, we need to create the ArticleAuthor as its own object
      ArticleAuthor.objects.create(
          author=kenrick,
          article=kenrick_et_al_1989,
          order=1
      )
      ArticleAuthor.objects.create(
          author=guiterres,
          article=kenrick_et_al_1989,
          order=2
      )
      ArticleAuthor.objects.create(
          author=goldberg,
          article=kenrick_et_al_1989,
          order=3
      )
  
      balzarini_et_al_2016 = Article.objects.create(
          title='Does exposure to erotica reduce attraction and love for romantic partners in men? Independent replications of Kenrick, Gutierres, and Goldberg (1989) Study 2',
          journal=j_soc_psych,
          doi='10.1016/j.jesp.2016.11.003',
          year=2016,
          article_type='REPLICATION',
          research_area='SOCIAL_SCIENCE',
          reporting_standards_type='BASIC_4_RETROACTIVE',
          pdf_url="https://www.researchgate.net/profile/Rhonda_Balzarini/publication/310488568_Does_exposure_to_erotica_reduce_attraction_and_love_for_romantic_partners_in_men_Independent_replications_of_Kenrick_Gutierres_and_Goldberg_1989_study_2/links/59cfdd434585150177ee21fd/Does-exposure-to-erotica-reduce-attraction-and-love-for-romantic-partners-in-men-Independent-replications-of-Kenrick-Gutierres-and-Goldberg-1989-study-2.pdf",
          abstract="Kenrick, Gutierres, and Goldberg (1989; Study 2) demonstrated that men, but not women, in committed relationships exposed to erotic images of opposite-sex others reported lower ratings for their partner's sexual attractiveness (d = 0.91) and less love for their partner (d = 0.69) than men exposed to images of abstract art. This research has implications for understanding the possible effects of erotica on men in relationships, but has not been replicated. We conducted three preregistered, high-powered close replications, and meta-analyzed the effects of the original and replication studies. We did not find support for the original finding that exposure to attractive images of opposite-sex others affects males' ratings of their partners' sexual attractiveness or love for their partner."
      )
  
      balzarini = Author.objects.create(
          first_name='Rhonda',
          last_name='Balzarini'
      )
      dobson = Author.objects.create(
          first_name='Kiersten',
          last_name='Dobson'
      )
      campbell = Author.objects.create(
          first_name='Lorne',
          last_name='Campbell'
      )
  
      ArticleAuthor.objects.create(
          article=balzarini_et_al_2016,
          author=balzarini,
          order=1
      )
      ArticleAuthor.objects.create(
          article=balzarini_et_al_2016,
          author=dobson,
          order=2
      )
      ArticleAuthor.objects.create(
          article=balzarini_et_al_2016,
          author=campbell,
          order=3
      )
      #
      # If you really want to add Brian Earp as an author, this is how you do it.
      # You just call .get instead of .create to look up an existing Author by name.
      # earp = Author.objects.get(
      #     first_name='Brian',
      #     last_name='Earp'
      # )
      # ArticleAuthor.objects.create(
      #     article=balzarini_et_al_2016,
      #     author=earp,
      #     order=4
      # )
  
      Transparency.objects.create(
          article=balzarini_et_al_2016,
          transparency_type='PREREG',
          url='https://osf.io/6xqju/'
      )
      Transparency.objects.create(
          article=balzarini_et_al_2016,
          transparency_type='MATERIALS',
          url='https://osf.io/nrkej/'
      )
  
      Transparency.objects.create(
          article=balzarini_et_al_2016,
          transparency_type='DATA',
          url='https://osf.io/w648b/'
      )
      Transparency.objects.create(
          article=balzarini_et_al_2016,
          transparency_type='DATA',
          url='https://osf.io/rqhjk/'
      )
      Transparency.objects.create(
          article=balzarini_et_al_2016,
          transparency_type='DATA',
          url='https://osf.io/f4n7b/'
      )
  
      kenrick_study_2 = Study.objects.create(
          article=kenrick_et_al_1989,
          study_number=2
      )
  
      playboy = Effect.objects.create(
          name='Playboy Effect'
      )
  
      hypo = Hypothesis.objects.create(
          name='Exposure to opposite-sex erotica decreases romantic partner attraction for men, but not women.',
          effect=playboy
      )
  
      erotica_exposure = Construct.objects.create(
          name='Erotica Exposure'
      )
  
      participant_sex = Construct.objects.create(
          name='Participant sex'
      )
  
      love_for_partner = Construct.objects.create(
          name='Love for Partner'
      )
  
      playboy_centerfolds = Method.objects.create(
          construct=erotica_exposure,
          name='Playboy centerfolds vs. control'
      )
  
      m_participant_sex = Method.objects.create(
          construct=participant_sex,
          name='Participant sex'
      )
  
      rubin_love_scale = Method.objects.create(
          construct=love_for_partner,
          name='Rubin Love-scale'
      )
  
      balzarini_study_1 = Study.objects.create(
          article=balzarini_et_al_2016,
          study_number=1,
          replication_of=kenrick_study_2,
          reporting_standards_type='BASIC_4_RETROACTIVE',
          auxiliary_hypo_evidence=["Nudes rated as more pleasant than abstract art"]
      )
  
      balzarini_study_1.effects.add(playboy)
      balzarini_study_1.ind_vars.add(erotica_exposure)
      balzarini_study_1.ind_vars.add(participant_sex)
      balzarini_study_1.dep_vars.add(love_for_partner)
      balzarini_study_1.ind_var_methods.add(playboy_centerfolds)
      balzarini_study_1.ind_var_methods.add(m_participant_sex)
      balzarini_study_1.dep_var_methods.add(rubin_love_scale)
  
      balzarini_study_2 = Study.objects.create(
          article=balzarini_et_al_2016,
          study_number=2,
          replication_of=kenrick_study_2,
          auxiliary_hypo_evidence=["Nudes rated as more pleasant than abstract art"]
      )
  
      balzarini_study_2.effects.add(playboy)
      balzarini_study_2.ind_vars.add(erotica_exposure)
      balzarini_study_2.ind_vars.add(participant_sex)
      balzarini_study_2.dep_vars.add(love_for_partner)
      balzarini_study_2.ind_var_methods.add(playboy_centerfolds)
      balzarini_study_2.ind_var_methods.add(m_participant_sex)
      balzarini_study_2.dep_var_methods.add(rubin_love_scale)
  
      balzarini_study_3 = Study.objects.create(
          article=balzarini_et_al_2016,
          study_number=3,
          replication_of=kenrick_study_2,
          auxiliary_hypo_evidence=["Nudes rated as more pleasant than abstract art"]
      )
  
      balzarini_study_3.effects.add(playboy)
      balzarini_study_3.ind_vars.add(erotica_exposure)
      balzarini_study_3.ind_vars.add(participant_sex)
      balzarini_study_3.dep_vars.add(love_for_partner)
      balzarini_study_3.ind_var_methods.add(playboy_centerfolds)
      balzarini_study_3.ind_var_methods.add(m_participant_sex)
      balzarini_study_3.dep_var_methods.add(rubin_love_scale)
  
      Transparency.objects.create(
          article=balzarini_et_al_2016,
          study=balzarini_study_1,
          transparency_type='DATA',
          url='https://osf.io/w648b/'
      )
  
      Transparency.objects.create(
          article=balzarini_et_al_2016,
          study=balzarini_study_2,
          transparency_type='DATA',
          url='https://osf.io/rqhjk/'
      )
  
      Transparency.objects.create(
          article=balzarini_et_al_2016,
          study=balzarini_study_2,
          transparency_type='MATERIALS',
          url='https://osf.io/nrkej/'
      )
  
      kf = KeyFigure.objects.create(
          article=balzarini_et_al_2016,
          study=balzarini_study_2,
          figure_number=1,
          image_url='http://www.curatescience.org/logos/interactions-popup2.png',
          is_figure=True,
          is_table=False
      )
  
  def delete_data(apps, schema_editor):
      Article = apps.get_model('curate', 'Article')
      Author = apps.get_model('curate', 'Author')
      Journal = apps.get_model('curate', 'Journal')
      ArticleAuthor = apps.get_model('curate', 'ArticleAuthor')
      RelatedArticle = apps.get_model('curate', 'RelatedArticle')
      Study = apps.get_model('curate', 'Study')
      Effect = apps.get_model('curate', 'Effect')
      Collection = apps.get_model('curate', 'Collection')
      Construct = apps.get_model('curate', 'Construct')
      Hypothesis = apps.get_model('curate', 'Hypothesis')
      KeyFigure = apps.get_model('curate', 'KeyFigure')
      StatisticalResult = apps.get_model('curate', 'StatisticalResult')
      Method = apps.get_model('curate', 'Method')
      VariableRelationship = apps.get_model('curate', 'VariableRelationship')
      Transparency = apps.get_model('curate', 'Transparency')
      
      kenrick_et_al_1989 = Article.objects.get(doi='10.1016/0022-1031(89)90010-3')
      balzarini_et_al_2016 = Article.objects.get(doi='10.1016/j.jesp.2016.11.003')
  
      KeyFigure.objects.all().delete()
  
      Transparency.objects.filter(article=balzarini_et_al_2016).delete()
  
      balzarini_et_al_2016.studies.all().delete()
      kenrick_et_al_1989.studies.all().delete()
  
      Hypothesis.objects.filter(name='Exposure to opposite-sex erotica decreases romantic partner attraction for men, but not women.').delete()
  
      Effect.objects.filter(name='Playboy Effect').delete()
  
      Method.objects.filter(name='Playboy centerfolds vs. control').delete()
      Method.objects.filter(name='Participant sex').delete()
      Method.objects.filter(name='Rubin Love-scale').delete()
  
      Construct.objects.filter(name='Erotica Exposure').delete()
      Construct.objects.filter(name='Participant sex').delete()
      Construct.objects.filter(name='Love for Partner').delete()
  
      kenrick = Author.objects.get(
          first_name='Douglas',
          last_name='Kenrick',
      )
      guiterres = Author.objects.get(
          first_name='Sara',
          last_name='Guiterres',
      )
      goldberg = Author.objects.get(
          first_name='Laurie',
          last_name='Goldberg'
      )
  
      balzarini = Author.objects.get(
          first_name='Rhonda',
          last_name='Balzarini'
      )
      dobson = Author.objects.get(
          first_name='Kiersten',
          last_name='Dobson'
      )
      campbell = Author.objects.get(
          first_name='Lorne',
          last_name='Campbell'
      )
      # earp = Author.objects.get(
      #     first_name='Brian',
      #     last_name='Earp'
      # )
  
      ArticleAuthor.objects.filter(author=kenrick).delete()
      ArticleAuthor.objects.filter(author=guiterres).delete()
      ArticleAuthor.objects.filter(author=goldberg).delete()
      ArticleAuthor.objects.filter(author=balzarini).delete()
      ArticleAuthor.objects.filter(author=dobson).delete()
      ArticleAuthor.objects.filter(author=campbell).delete()
      #ArticleAuthor.objects.filter(article=balzarini_et_al_2016,author=earp).delete()
  
      kenrick.delete()
      guiterres.delete()
      goldberg.delete()
      balzarini.delete()
      dobson.delete()
      campbell.delete()
  
      j = Journal.objects.get(issn='0022-4545')
      j.articles.remove(kenrick_et_al_1989)
      j.articles.remove(balzarini_et_al_2016)
      kenrick_et_al_1989.delete()
      balzarini_et_al_2016.delete()
  
      j.delete()
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('curate', '0018_auto_20181026_0341'),
      ]
  
      if 'test' not in sys.argv:
          operations = [
              migrations.RunPython(seed_data, delete_data),
          ]
  