def handle(self, *args, **options): user = User.objects.get(id=1) diccio_f = open(os.path.abspath(os.path.join(os.path.dirname(__file__), 'data', 'regionalismos.json'))) diccio = json.load(diccio_f) with transaction.commit_on_success(): st = Study (title = 'Regionalismos', user = user, authors = "Javier De la Rosa y Roberto Ulloa") st.save() self.create_location(user,name=u'Área del Río de la Plata') self.create_location(user,name=u'América') self.create_location(user,name=u'América Central') self.create_location(user,name=u'América Meridional') print "loading the objects into a dictionary..." grs = dict ((o.title, o) for o in GeospatialReference.objects.all()) i=0 for entry in diccio: #grs = GeospatialReference.objects.filter(title=entry['user']) #if len(grs) > 0: #gr = grs[0] if entry['user'] in grs: gr = grs[entry['user']] elif entry['user'] in [u'Ciudad de México', u'Guadalajara']: gr = grs['Mexico'] #gr = GeospatialReference.objects.get(title='Mexico') else: gr = grs['Spain'] #gr = GeospatialReference.objects.get(title='Spain') spkrs = Speaker.objects.filter(location=gr) if len(spkrs) > 0: spkr = spkrs[0] else: spkr = self.create_speaker(user, st ,gr, entry['user']) self.create_production(user, spkr, entry['word'], entry['ipa'], entry['rfe'], gr, entry['definition']) i+=1 if i%100 == 0: print str(i) + ' productions'
def create_studies(study_settings): """ Create Study entries in the database for the supplied study_settings """ try: study = Study.objects.get(name=study_settings.name) except Study.DoesNotExist: study = Study(name=study_settings.name) study.stub = study_settings.name_stub study.description = study_settings.description #study.start_date = Date #study.end_date = Date study.started = True study.consent = study_settings.informed_consent study.instructions = study_settings.instructions study.eligibility = study_settings.eligibility study.reward = study_settings.reward study.task_session_dur = 1 study.assess_blocks = 1 study.assess_trials = 1 study.save() return study