class UserData(BaseStudyUserData): """ Represents the user data for one PGP participant. """ class Meta: # noqa: D101 verbose_name = 'PGP user data' verbose_name_plural = verbose_name user = fields.AutoOneToOneField(settings.AUTH_USER_MODEL, related_name=label) def get_retrieval_params(self): try: return {'hu_id': HuId.objects.filter(user_data=self)[0].id} except IndexError: return {} @property def has_key_data(self): """ Return false if key data needed for data retrieval is not present. """ if self.is_connected: try: HuId.objects.get(user_data=self) return True except HuId.DoesNotExist: return False return False
class UserData(BaseStudyUserData): """ Represents the user data for one American Gut participant. """ class Meta: # noqa: D101 verbose_name = 'American Gut user data' verbose_name_plural = verbose_name user = fields.AutoOneToOneField(settings.AUTH_USER_MODEL, related_name=label) @property def survey_ids(self): try: return self.data.get('surveyIds', []) except AttributeError: return [] @property def has_key_data(self): """ Return false if key data needed for data retrieval is not present. """ return self.is_connected and self.survey_ids
class UserData(models.Model): """ Used as key when a User has DataFiles for Genome and Exome Data. """ class Meta: # noqa: D101 verbose_name = 'Genome and exome data' verbose_name_plural = verbose_name user = fields.AutoOneToOneField(settings.AUTH_USER_MODEL, related_name=label) def __unicode__(self): return '%s:%s' % (self.user, 'Genome and Exome data') def vcf_data(self): return self.vcfdata_set.all() @property def is_connected(self): return self.vcf_data() def disconnect(self): vcf_data = self.vcf_data() vcf_data.delete() def get_retrieval_params(self): return {'vcf_data': [s.as_dict() for s in self.vcf_data()]}
class UserData(models.Model): """ Used as key when a User has DataFiles for the AncestryDNA activity. """ class Meta: # noqa: D101 verbose_name = 'AncestryDNA user data' verbose_name_plural = verbose_name user = fields.AutoOneToOneField(settings.AUTH_USER_MODEL, related_name=label) genome_file = models.FileField(upload_to=get_upload_path, max_length=1024, null=True) def __unicode__(self): return '%s:%s' % (self.user, 'AncestryDNA') @property def file_url(self): try: return self.genome_file.url except ValueError: return '' @property def is_connected(self): return self.file_url def disconnect(self): self.genome_file.delete() def get_retrieval_params(self): return {'file_url': self.file_url}
class UserData(models.Model): """ Used as key when a User has DataFiles for the uBiome activity. """ class Meta: # noqa: D101 verbose_name = 'uBiome user data' verbose_name_plural = verbose_name user = fields.AutoOneToOneField(settings.AUTH_USER_MODEL, related_name=label) def __unicode__(self): return '%s:%s' % (self.user, 'uBiome') def samples(self): return self.ubiomesample_set.all() @property def is_connected(self): return self.samples() def disconnect(self): samples = self.samples() samples.delete() def get_retrieval_params(self): return {'samples': [s.as_dict() for s in self.samples()]}
class TestUserData(models.Model): """ Used for unit tests in public_data.tests; there's not currently a way to make test-specific model definitions in Django (a bug open since 2009, #7835) """ user = fields.AutoOneToOneField(settings.AUTH_USER_MODEL, related_name='test_user_data')
class UserData(BaseStudyUserData): """ Represents the user data for one Wildlife of Our Homes participant. """ class Meta: # noqa: D101 verbose_name = 'Wildlife of Our Homes user data' verbose_name_plural = verbose_name user = fields.AutoOneToOneField(settings.AUTH_USER_MODEL, related_name=label) @property def has_key_data(self): """ Return false if key data needed for data retrieval is not present. """ return self.is_connected and self.data
class UserData(models.Model): """ Used as key when a User has DataFiles for the data_selfie activity. """ class Meta: # noqa: D101 verbose_name = 'data selfie user data' verbose_name_plural = verbose_name user = fields.AutoOneToOneField(settings.AUTH_USER_MODEL, related_name=label) seen_page = models.BooleanField(default=False) def __unicode__(self): return '%s:%s' % (self.user, 'data_selfie') @property def is_connected(self): return DataSelfieDataFile.objects.filter(user=self.user).count() > 0 @staticmethod def get_retrieval_params(): return {}
class UserData(models.Model): """ Used as key when a User has DataFiles for the 23andme activity. """ class Meta: # noqa: D101 verbose_name = '23andMe user data' verbose_name_plural = verbose_name user = fields.AutoOneToOneField(settings.AUTH_USER_MODEL, related_name=label) # As of Feb 2016, DropzoneS3UploadFormView overrides the upload_to. # Maintaining with same path in case we someday get non-Dropzone files. genome_file = models.FileField(upload_to=get_upload_path, max_length=1024, null=True) def __unicode__(self): return '%s:%s' % (self.user, '23andme') @property def file_url(self): try: return self.genome_file.url except ValueError: return '' @property def is_connected(self): return self.file_url def disconnect(self): self.genome_file.delete() def get_retrieval_params(self): return {'file_url': self.file_url}