Esempio n. 1
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='ECBDataCache',
            fields=[
                ('id', djongo.models.fields.ObjectIdField(auto_created=True, db_column='_id', primary_key=True, serialize=False)),
                ('size_in_bytes', models.IntegerField()),
                ('status', models.TextField()),
                ('tag', models.TextField()),
                ('dataframe_format', models.TextField()),
                ('field', models.TextField()),
                ('last_updated', models.DateTimeField()),
                ('market', models.TextField()),
                ('n_days', models.IntegerField()),
                ('n_stocks', models.IntegerField()),
                ('sha256', models.TextField()),
                ('scope', models.TextField()),
                ('dataframe', models.BinaryField()),
            ],
            options={
                'verbose_name': 'ECB Data Cache',
                'verbose_name_plural': 'ECB Data Cache',
                'db_table': 'ecb_data_cache',
            },
        ),
        migrations.CreateModel(
            name='ECBFlow',
            fields=[
                ('id', djongo.models.fields.ObjectIdField(auto_created=True, db_column='_id', primary_key=True, serialize=False)),
                ('name', models.TextField(db_column='flow_name')),
                ('description', models.TextField(db_column='flow_descr')),
                ('is_test_data', models.BooleanField()),
                ('last_updated', models.DateTimeField()),
                ('prepared', models.DateTimeField()),
                ('sender', models.TextField()),
                ('source', models.TextField()),
                ('data_available', models.BooleanField()),
            ],
            options={
                'verbose_name': 'ECB Flow',
                'verbose_name_plural': 'ECB Flow',
                'db_table': 'ecb_flow_index',
            },
        ),
        migrations.CreateModel(
            name='ECBMetadata',
            fields=[
                ('id', djongo.models.fields.ObjectIdField(auto_created=True, db_column='_id', primary_key=True, serialize=False)),
                ('metadata_type', models.TextField(db_column='metadata_type')),
                ('flow', models.TextField(db_column='flow_name')),
                ('code', models.TextField(db_column='item_name')),
                ('column_name', models.TextField(db_column='codelist_name')),
                ('printable_code', models.TextField(db_column='item_value')),
            ],
            options={
                'verbose_name': 'ECB Metadata',
                'verbose_name_plural': 'ECB Metadata',
                'db_table': 'ecb_metadata_index',
            },
        ),
    ]
Esempio n. 2
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Database',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=300, unique=True)),
                ('created_at', models.DateTimeField(auto_now=True)),
                ('last_update', models.DateTimeField(auto_now=True)),
                ('created_by',
                 models.ForeignKey(blank=True,
                                   null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   related_name='database_creator',
                                   to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Entity',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=300, unique=True)),
                ('created_at', models.DateTimeField(auto_now=True)),
                ('last_update', models.DateTimeField(auto_now=True)),
                ('created_by',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='entity_creator',
                                   to=settings.AUTH_USER_MODEL)),
                ('database',
                 models.ForeignKey(blank=True,
                                   null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   related_name='project_entity',
                                   to='graphicsdb.Database')),
                ('updated_by',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='entity_update_user',
                                   to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Attribute',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=150, unique=True)),
                ('type',
                 models.CharField(choices=[(1, 'BigInt'), (2, 'Int')],
                                  max_length=150)),
                ('is_null', models.BinaryField(default=False)),
                ('is_auto_increment', models.BinaryField(default=False)),
                ('is_unique', models.BinaryField(default=False)),
                ('is_primary_key', models.BinaryField(default=False)),
                ('is_index', models.BinaryField(default=False)),
                ('created_at', models.DateTimeField(auto_now=True)),
                ('last_update', models.DateTimeField(auto_now=True)),
                ('created_by',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='user_creation',
                                   to=settings.AUTH_USER_MODEL)),
                ('entity',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='entity_attribute',
                                   to='graphicsdb.Entity')),
                ('updated_by',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='user_update',
                                   to=settings.AUTH_USER_MODEL)),
            ],
        ),
    ]
Esempio n. 3
0
class BotTask(models.Model):
    added_date = models.DateTimeField(default=timezone.now)

    BOT_STATUS_WORKING = 'working'
    BOT_STATUS_FINISHING = 'finishing'
    BOT_STATUS_STOPPED = 'stopped'

    BOT_STATUS = ((BOT_STATUS_WORKING, 'Working'),
                  (BOT_STATUS_FINISHING, 'Finishing'), (BOT_STATUS_STOPPED,
                                                        'Stopped'))

    bot_status = models.CharField(max_length=200,
                                  choices=BOT_STATUS,
                                  default=BOT_STATUS_STOPPED)

    BOT_TASK_DOWNLOAD_2CH_WEBM = 'Download webms from 2ch'
    BOT_TASK_REMOVE_WEBM = 'Remove webms'
    BOT_TASK_INSPECT_BANNED = 'Insect banned'

    BOT_TASK = ((BOT_TASK_DOWNLOAD_2CH_WEBM, 'Download'),
                (BOT_TASK_REMOVE_WEBM, 'Remove'), (BOT_TASK_INSPECT_BANNED,
                                                   'Inspect'))

    bot_task = models.CharField(max_length=200,
                                choices=BOT_TASK,
                                default=BOT_TASK_DOWNLOAD_2CH_WEBM)

    task_data = models.BinaryField(default='{}')

    def start_bot(self):
        from .utils.bot_module import BotIsBusy, bot_task_1, bot_task_2, bot_task_3, TaskThread
        if filter(lambda x: x.getName() == 'Bot({})'.format(self.id),
                  threading.enumerate()):
            raise BotIsBusy('Bot (id={}) is working already!'.format(self.id))

        data = json.loads(str(self.task_data))
        task = None
        if self.bot_task == self.BOT_TASK_DOWNLOAD_2CH_WEBM:
            task = bot_task_1
        elif self.bot_task == self.BOT_TASK_REMOVE_WEBM:
            task = bot_task_2
        elif self.bot_task == self.BOT_TASK_INSPECT_BANNED:
            task = bot_task_3()

        thread = TaskThread('Bot({})'.format(self.id), task, data)
        thread.start()
        self.bot_status = self.BOT_STATUS_WORKING
        self.save()

    def stop_bot(self):
        for thread in [
                x for x in threading.enumerate()
                if x.getName() == 'Bot({})'.format(self.id)
        ]:
            thread.stop()

    @property
    def get_status(self):
        if not filter(lambda x: x.getName() == 'Bot({})'.format(self.id),
                      threading.enumerate()):
            from .utils.bot_module import TaskThread
            return TaskThread.STATUS_STOPPED

        return list(
            filter(lambda x: x.getName() == 'Bot({})'.format(self.id),
                   threading.enumerate()))[0].get_status()

    @property
    def get_process_status(self):
        if not filter(lambda x: x.getName() == 'Bot({})'.format(self.id),
                      threading.enumerate()):
            from .utils.bot_module import TaskThread
            return TaskThread.PROCESS_STATUS_RESTING

        return list(
            filter(lambda x: x.getName() == 'Bot({})'.format(self.id),
                   threading.enumerate()))[0].get_process_status()

    def pause_on(self):
        for thread in [
                x for x in threading.enumerate()
                if x.getName() == 'Bot({})'.format(self.id)
        ]:
            thread.pause_on()

    def pause_off(self):
        for thread in [
                x for x in threading.enumerate()
                if x.getName() == 'Bot({})'.format(self.id)
        ]:
            thread.pause_off()
class Migration(migrations.Migration):

    dependencies = [
        ('cred', '0001_initial'),
        ('cred', '0002_add_projects'),
    ]

    operations = [
        migrations.CreateModel(
            name='Attachment',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('filename',
                 models.CharField(max_length=256, verbose_name='Filename')),
                ('mime',
                 models.CharField(default=None,
                                  max_length=64,
                                  null=True,
                                  verbose_name='Mime')),
                ('content', models.BinaryField(default=None, null=True)),
                ('credential',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='cred.Cred')),
            ],
        ),
        migrations.AlterField(
            model_name='Cred',
            name='group',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to='auth.Group',
                verbose_name='Group'),
        ),
        migrations.AlterField(
            model_name='Cred',
            name='latest',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name='history',
                to='cred.Cred'),
        ),
        migrations.AddField(
            model_name='Cred',
            name='is_expired',
            field=models.BooleanField(db_index=True, default=False),
        ),
        migrations.AddField(
            model_name='cred',
            name='users',
            field=models.ManyToManyField(blank=True,
                                         default=None,
                                         related_name='child_creds',
                                         to=settings.AUTH_USER_MODEL,
                                         verbose_name='Users'),
        ),
        migrations.AlterField(
            model_name='CredChangeQ',
            name='cred',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE, to='cred.Cred'),
        ),
        migrations.AlterField(
            model_name='CredAudit',
            name='cred',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='logs',
                to='cred.Cred'),
        ),
        migrations.AlterField(
            model_name='CredAudit',
            name='user',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name='credlogs',
                to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterField(
            model_name='credaudit',
            name='audittype',
            field=models.CharField(choices=[('A', 'Added'), ('C', 'Changed'),
                                            ('M', 'Only Metadata Changed'),
                                            ('V', 'Only Details Viewed'),
                                            ('X', 'Exported'),
                                            ('D', 'Deleted'),
                                            ('S', 'Scheduled For Change'),
                                            ('P', 'Password Viewed'),
                                            ('AD', 'Attachment Added'),
                                            ('AV', 'Attachment Viewed'),
                                            ('AD', 'Attachment Deleted')],
                                   max_length=5),
        ),
        migrations.RunPython(migrate_attachments),
    ]
Esempio n. 5
0
class Session(BaseModel):

    TUNING_OPTIONS = OrderedDict([
        ("tuning_session", "Tuning Session"),
        ("no_tuning_session", "No Tuning"),
        ("randomly_generate", "Randomly Generate"),
        ("lhs", "Run LHS")
    ])

    user = models.ForeignKey(User)
    name = models.CharField(max_length=64, verbose_name="session name")
    description = models.TextField(null=True, blank=True)
    dbms = models.ForeignKey(DBMSCatalog)
    hardware = models.ForeignKey(Hardware)
    algorithm = models.IntegerField(choices=AlgorithmType.choices(),
                                    default=AlgorithmType.GPR)
    lhs_samples = models.TextField(default="[]")
    ddpg_actor_model = models.BinaryField(null=True, blank=True)
    ddpg_critic_model = models.BinaryField(null=True, blank=True)
    ddpg_reply_memory = models.BinaryField(null=True, blank=True)
    dnn_model = models.BinaryField(null=True, blank=True)

    project = models.ForeignKey(Project)
    creation_time = models.DateTimeField()
    last_update = models.DateTimeField()

    upload_code = models.CharField(max_length=30, unique=True)
    tuning_session = models.CharField(choices=TUNING_OPTIONS.items(),
                                      max_length=64, default='tuning_session',
                                      verbose_name='session type')

    target_objective = models.CharField(
        max_length=64, default=target_objectives.default())
    hyperparameters = models.TextField(default='''{
    "DDPG_ACTOR_HIDDEN_SIZES": [128, 128, 64],
    "DDPG_ACTOR_LEARNING_RATE": 0.02,
    "DDPG_CRITIC_HIDDEN_SIZES": [64, 128, 64],
    "DDPG_CRITIC_LEARNING_RATE": 0.001,
    "DDPG_BATCH_SIZE": 32,
    "DDPG_GAMMA": 0.0,
    "DDPG_SIMPLE_REWARD": true,
    "DDPG_UPDATE_EPOCHS": 30,
    "DDPG_USE_DEFAULT": false,
    "DNN_DEBUG": true,
    "DNN_DEBUG_INTERVAL": 100,
    "DNN_EXPLORE": false,
    "DNN_EXPLORE_ITER": 500,
    "DNN_GD_ITER": 100,
    "DNN_NOISE_SCALE_BEGIN": 0.1,
    "DNN_NOISE_SCALE_END": 0.0,
    "DNN_TRAIN_ITER": 100,
    "FLIP_PROB_DECAY": 0.5,
    "GPR_BATCH_SIZE": 3000,
    "GPR_DEBUG": true,
    "GPR_EPS": 0.001,
    "GPR_EPSILON": 1e-06,
    "GPR_LEARNING_RATE": 0.01,
    "GPR_LENGTH_SCALE": 2.0,
    "GPR_MAGNITUDE": 1.0,
    "GPR_MAX_ITER": 500,
    "GPR_MAX_TRAIN_SIZE": 7000,
    "GPR_MU_MULTIPLIER": 1.0,
    "GPR_MODEL_NAME": "BasicGP",
    "GPR_HP_LEARNING_RATE": 0.001,
    "GPR_HP_MAX_ITER": 5000,
    "GPR_RIDGE": 1.0,
    "GPR_SIGMA_MULTIPLIER": 1.0,
    "GPR_UCB_SCALE": 0.2,
    "GPR_USE_GPFLOW": true,
    "GPR_UCB_BETA": "get_beta_td",
    "IMPORTANT_KNOB_NUMBER": 10000,
    "INIT_FLIP_PROB": 0.3,
    "NUM_SAMPLES": 30,
    "TF_NUM_THREADS": 4,
    "TOP_NUM_CONFIG": 10}''')

    def clean(self):
        if self.target_objective is None:
            self.target_objective = target_objectives.default()

    def delete(self, using=DEFAULT_DB_ALIAS, keep_parents=False):
        SessionKnob.objects.get(session=self).delete()
        results = Result.objects.filter(session=self)
        for r in results:
            r.knob_data.delete()
            r.metric_data.delete()
            r.delete()
        super(Session, self).delete(using=DEFAULT_DB_ALIAS, keep_parents=False)

    class Meta:  # pylint: disable=no-init
        unique_together = ('user', 'project', 'name')
Esempio n. 6
0
class QueryRegionIndexVector(models.Model):
    event = models.ForeignKey(TEvent)
    query_region = models.ForeignKey(QueryRegion)
    vector = models.BinaryField()
    created = models.DateTimeField('date created', auto_now_add=True)
Esempio n. 7
0
class Binaries(models.Model):
    binary_file = models.BinaryField(blank=False, null=False)
    timestamp = models.DateTimeField(auto_now_add=True)
Esempio n. 8
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='GeneDetailed',
            fields=[
                ('uid',
                 models.IntegerField(blank=True,
                                     primary_key=True,
                                     serialize=False)),
                ('chrom', models.TextField(blank=True, null=True)),
                ('gene', models.TextField(blank=True, null=True)),
                ('is_hgnc', models.NullBooleanField()),
                ('ensembl_gene_id', models.TextField(blank=True, null=True)),
                ('transcript', models.TextField(blank=True, null=True)),
                ('biotype', models.TextField(blank=True, null=True)),
                ('transcript_status', models.TextField(blank=True, null=True)),
                ('ccds_id', models.TextField(blank=True, null=True)),
                ('hgnc_id', models.TextField(blank=True, null=True)),
                ('entrez_id', models.TextField(blank=True, null=True)),
                ('cds_length', models.TextField(blank=True, null=True)),
                ('protein_length', models.TextField(blank=True, null=True)),
                ('transcript_start', models.TextField(blank=True, null=True)),
                ('transcript_end', models.TextField(blank=True, null=True)),
                ('strand', models.TextField(blank=True, null=True)),
                ('synonym', models.TextField(blank=True, null=True)),
                ('rvis_pct', models.TextField(blank=True, null=True)),
                ('mam_phenotype_id', models.TextField(blank=True, null=True)),
            ],
            options={
                'db_table': 'gene_detailed',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='GeneSummary',
            fields=[
                ('uid',
                 models.IntegerField(blank=True,
                                     primary_key=True,
                                     serialize=False)),
                ('chrom', models.TextField(blank=True, null=True)),
                ('gene', models.TextField(blank=True, null=True)),
                ('is_hgnc', models.NullBooleanField()),
                ('ensembl_gene_id', models.TextField(blank=True, null=True)),
                ('hgnc_id', models.TextField(blank=True, null=True)),
                ('transcript_min_start', models.TextField(blank=True,
                                                          null=True)),
                ('transcript_max_end', models.TextField(blank=True,
                                                        null=True)),
                ('strand', models.TextField(blank=True, null=True)),
                ('synonym', models.TextField(blank=True, null=True)),
                ('rvis_pct', models.TextField(blank=True, null=True)),
                ('mam_phenotype_id', models.TextField(blank=True, null=True)),
                ('in_cosmic_census', models.NullBooleanField()),
            ],
            options={
                'db_table': 'gene_summary',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Resources',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.TextField(blank=True, null=True)),
                ('resource', models.TextField(blank=True, null=True)),
            ],
            options={
                'db_table': 'resources',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='SampleGenotypeCounts',
            fields=[
                ('sample_id',
                 models.IntegerField(blank=True,
                                     primary_key=True,
                                     serialize=False)),
                ('num_hom_ref', models.IntegerField(blank=True, null=True)),
                ('num_het', models.IntegerField(blank=True, null=True)),
                ('num_hom_alt', models.IntegerField(blank=True, null=True)),
                ('num_unknown', models.IntegerField(blank=True, null=True)),
            ],
            options={
                'db_table': 'sample_genotype_counts',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='SampleGenotypes',
            fields=[
                ('sample_id',
                 models.IntegerField(blank=True,
                                     primary_key=True,
                                     serialize=False)),
                ('gt_types', models.BinaryField(blank=True, null=True)),
            ],
            options={
                'db_table': 'sample_genotypes',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Samples',
            fields=[
                ('sample_id',
                 models.IntegerField(blank=True,
                                     primary_key=True,
                                     serialize=False)),
                ('family_id', models.TextField(blank=True, null=True)),
                ('name', models.TextField(blank=True, null=True, unique=True)),
                ('paternal_id', models.TextField(blank=True, null=True)),
                ('maternal_id', models.TextField(blank=True, null=True)),
                ('sex', models.TextField(blank=True, null=True)),
                ('phenotype', models.TextField(blank=True, null=True)),
            ],
            options={
                'db_table': 'samples',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Variants',
            fields=[
                ('chrom', models.TextField(blank=True)),
                ('start',
                 models.IntegerField(blank=True, db_column='start',
                                     null=True)),
                ('end', models.IntegerField(blank=True, null=True)),
                ('variant_id',
                 models.IntegerField(blank=True,
                                     primary_key=True,
                                     serialize=False)),
                ('ref', models.TextField(blank=True)),
                ('alt', models.TextField(blank=True)),
                ('quality',
                 models.FloatField(blank=True, db_column='qual', null=True)),
                ('pass_filter', models.TextField(blank=True,
                                                 db_column='filter')),
                ('gts_blob',
                 models.BinaryField(blank=True, db_column='gts', null=True)),
                ('gt_types_blob',
                 models.BinaryField(blank=True,
                                    db_column='gt_types',
                                    null=True)),
                ('in_dbsnp', models.NullBooleanField()),
                ('dbsnp', models.TextField(blank=True, db_column='rs_ids')),
                ('clinvar_sig', models.TextField(blank=True)),
                ('clinvar_disease_acc', models.TextField(blank=True)),
                ('gerp_bp_score', models.FloatField(blank=True, null=True)),
                ('gerp_element_pval', models.FloatField(blank=True,
                                                        null=True)),
                ('gene_symbol', models.TextField(blank=True,
                                                 db_column='gene')),
                ('transcript', models.TextField(blank=True)),
                ('exon', models.TextField(blank=True)),
                ('is_exonic', models.NullBooleanField()),
                ('is_coding', models.NullBooleanField()),
                ('is_lof', models.NullBooleanField()),
                ('codon_change', models.TextField(blank=True)),
                ('aa_change', models.TextField(blank=True)),
                ('impact', models.TextField(blank=True)),
                ('impact_so', models.TextField(blank=True)),
                ('impact_severity', models.TextField(blank=True)),
                ('polyphen_pred', models.TextField(blank=True)),
                ('polyphen_score', models.FloatField(blank=True)),
                ('sift_pred', models.TextField(blank=True, null=True)),
                ('sift_score', models.FloatField(blank=True, null=True)),
                ('read_depth',
                 models.IntegerField(blank=True, db_column='depth',
                                     null=True)),
                ('rms_map_qual', models.FloatField(blank=True, null=True)),
                ('qual_depth', models.FloatField(blank=True, null=True)),
                ('allele_count', models.IntegerField(blank=True, null=True)),
                ('cadd_raw', models.FloatField(blank=True, null=True)),
                ('cadd_scaled', models.FloatField(blank=True, null=True)),
                ('in_esp', models.NullBooleanField()),
                ('aaf_esp_all', models.DecimalField(blank=True, null=True)),
                ('in_1kg', models.NullBooleanField()),
                ('aaf_1kg_all', models.DecimalField(blank=True, null=True)),
                ('in_exac', models.NullBooleanField()),
                ('aaf_exac_all', models.DecimalField(blank=True, null=True)),
                ('allele_freq',
                 models.FloatField(blank=True, db_column='AF', null=True)),
                ('base_qual_rank_sum',
                 models.FloatField(blank=True,
                                   db_column='BaseQRankSum',
                                   null=True)),
                ('fisher_strand_bias',
                 models.FloatField(blank=True, db_column='FS', null=True)),
                ('map_qual_rank_sum',
                 models.FloatField(blank=True,
                                   db_column='MQRankSum',
                                   null=True)),
                ('read_pos_rank_sum',
                 models.FloatField(blank=True,
                                   db_column='ReadPosRankSum',
                                   null=True)),
                ('strand_bias_odds_ratio',
                 models.FloatField(blank=True, db_column='SOR', null=True)),
                ('hgvsp', models.TextField(blank=True, db_column='vep_hgvsp')),
                ('hgvsc', models.TextField(blank=True, db_column='vep_hgvsc')),
            ],
            options={
                'db_table': 'variants',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='VcfHeader',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('vcf_header', models.TextField(blank=True)),
            ],
            options={
                'db_table': 'vcf_header',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Version',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('version', models.TextField(blank=True)),
            ],
            options={
                'db_table': 'version',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Annotation',
            fields=[
                ('created_at',
                 models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('created_by', models.CharField(max_length=50, null=True)),
                ('updated_by', models.CharField(max_length=50, null=True)),
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('source', models.CharField(max_length=255, null=True)),
                ('source_version', models.CharField(max_length=255,
                                                    null=True)),
                ('annotation', models.CharField(max_length=255, null=True)),
                ('annotation_version',
                 models.CharField(max_length=255, null=True)),
            ],
            options={
                'db_table': 'annotation',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Bookmarks',
            fields=[
                ('created_at',
                 models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('created_by', models.CharField(max_length=50, null=True)),
                ('updated_by', models.CharField(max_length=50, null=True)),
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('query', models.TextField()),
                ('description', models.CharField(max_length=255)),
                ('long_description', models.TextField(default='')),
            ],
            options={
                'db_table': 'bookmarks',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='DbAccess',
            fields=[
                ('created_at',
                 models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('created_by', models.CharField(max_length=50, null=True)),
                ('updated_by', models.CharField(max_length=50, null=True)),
                ('id', models.AutoField(primary_key=True, serialize=False)),
            ],
            options={
                'db_table': 'db_accesses',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='History',
            fields=[
                ('created_at',
                 models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('created_by', models.CharField(max_length=50, null=True)),
                ('updated_by', models.CharField(max_length=50, null=True)),
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('session_start', models.DateTimeField()),
                ('url', models.TextField()),
                ('query', models.TextField(default='')),
                ('description', models.CharField(max_length=255)),
                ('long_description', models.TextField(default='')),
                ('ip_address', models.CharField(max_length=255)),
            ],
            options={
                'db_table': 'history',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='People',
            fields=[
                ('created_at',
                 models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('created_by', models.CharField(max_length=50, null=True)),
                ('updated_by', models.CharField(max_length=50, null=True)),
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('firstname', models.CharField(max_length=255)),
                ('lastname', models.CharField(max_length=255)),
                ('institution', models.CharField(max_length=255, null=True)),
                ('street', models.CharField(max_length=255, null=True)),
                ('city', models.CharField(max_length=255, null=True)),
                ('phone', models.CharField(max_length=30, null=True)),
                ('is_laboratory', models.IntegerField(null=True)),
                ('laboratory',
                 models.ForeignKey(null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='varapp.People')),
            ],
            options={
                'db_table': 'people',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Preferences',
            fields=[
                ('created_at',
                 models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('created_by', models.CharField(max_length=50, null=True)),
                ('updated_by', models.CharField(max_length=50, null=True)),
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('preferences', models.TextField(default='')),
                ('description', models.TextField(default='')),
            ],
            options={
                'db_table': 'preferences',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Roles',
            fields=[
                ('created_at',
                 models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('created_by', models.CharField(max_length=50, null=True)),
                ('updated_by', models.CharField(max_length=50, null=True)),
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=255)),
                ('rank', models.IntegerField(null=True)),
                ('can_validate_user', models.IntegerField()),
                ('can_delete_user', models.IntegerField()),
            ],
            options={
                'db_table': 'roles',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Users',
            fields=[
                ('created_at',
                 models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('created_by', models.CharField(max_length=50, null=True)),
                ('updated_by', models.CharField(max_length=50, null=True)),
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('username', models.CharField(max_length=25, unique=True)),
                ('password', models.CharField(max_length=255)),
                ('salt', models.CharField(default='', max_length=255)),
                ('email', models.CharField(max_length=255)),
                ('code', models.CharField(max_length=25)),
                ('activation_code', models.CharField(max_length=25,
                                                     null=True)),
                ('is_active', models.IntegerField(default=1)),
                ('is_password_reset', models.IntegerField(null=True)),
                ('person',
                 models.ForeignKey(null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='varapp.People')),
                ('role',
                 models.ForeignKey(null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='varapp.Roles')),
            ],
            options={
                'db_table': 'users',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='VariantsDb',
            fields=[
                ('created_at',
                 models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('created_by', models.CharField(max_length=50, null=True)),
                ('updated_by', models.CharField(max_length=50, null=True)),
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=255)),
                ('path', models.CharField(max_length=255, null=True)),
                ('description', models.TextField(null=True)),
                ('size', models.IntegerField(null=True)),
                ('parent_db',
                 models.ForeignKey(null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='varapp.VariantsDb')),
                ('is_active', models.IntegerField(default=1)),
            ],
            options={
                'db_table': 'variants_db',
                'managed': True,
            },
        ),
        migrations.AddField(
            model_name='preferences',
            name='user',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='varapp.Users'),
        ),
        migrations.AddField(
            model_name='history',
            name='user',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='varapp.Users'),
        ),
        migrations.AddField(
            model_name='dbaccess',
            name='user',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='varapp.Users'),
        ),
        migrations.AddField(
            model_name='dbaccess',
            name='variants_db',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='varapp.VariantsDb'),
        ),
        migrations.AddField(
            model_name='annotation',
            name='variants_db',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='varapp.VariantsDb'),
        ),
        migrations.CreateModel(
            name='Variant',
            fields=[],
            options={
                'proxy': True,
            },
            bases=('varapp.variants', ),
        ),
        migrations.AddField(
            model_name='annotation',
            name='is_active',
            field=models.IntegerField(default=1),
        ),
        migrations.AddField(
            model_name='bookmarks',
            name='db_access',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='varapp.DbAccess'),
        ),
        migrations.AddField(
            model_name='bookmarks',
            name='is_active',
            field=models.IntegerField(default=1),
        ),
        migrations.AddField(
            model_name='dbaccess',
            name='is_active',
            field=models.IntegerField(default=1),
        ),
        migrations.AddField(
            model_name='history',
            name='is_active',
            field=models.IntegerField(default=1),
        ),
        migrations.AddField(
            model_name='preferences',
            name='is_active',
            field=models.IntegerField(default=1),
        ),
        migrations.AlterField(
            model_name='roles',
            name='can_delete_user',
            field=models.IntegerField(default=0),
        ),
        migrations.AlterField(
            model_name='roles',
            name='can_validate_user',
            field=models.IntegerField(default=0),
        ),
    ]
Esempio n. 9
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Achievement',
            fields=[
                ('achievement_id',
                 models.AutoField(db_column='Achievement_id',
                                  primary_key=True,
                                  serialize=False)),
                ('events_name',
                 models.CharField(db_column='Events_name', max_length=64)),
                ('description_of_the_achievement',
                 models.TextField(db_column='Description_of_the_Achievement')),
                ('certificate', models.BinaryField(db_column='Certificate')),
            ],
            options={
                'db_table': 'Achievement',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='AuthGroup',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=80, unique=True)),
            ],
            options={
                'db_table': 'auth_group',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='AuthGroupPermissions',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
            ],
            options={
                'db_table': 'auth_group_permissions',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='AuthPermission',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('codename', models.CharField(max_length=100)),
            ],
            options={
                'db_table': 'auth_permission',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='AuthUser',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('password', models.CharField(max_length=128)),
                ('last_login', models.DateTimeField(blank=True, null=True)),
                ('is_superuser', models.BooleanField()),
                ('username', models.CharField(max_length=150, unique=True)),
                ('first_name', models.CharField(max_length=30)),
                ('last_name', models.CharField(max_length=150)),
                ('email', models.CharField(max_length=254)),
                ('is_staff', models.BooleanField()),
                ('is_active', models.BooleanField()),
                ('date_joined', models.DateTimeField()),
            ],
            options={
                'db_table': 'auth_user',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='AuthUserGroups',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
            ],
            options={
                'db_table': 'auth_user_groups',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='AuthUserUserPermissions',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
            ],
            options={
                'db_table': 'auth_user_user_permissions',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Company',
            fields=[
                ('company_id',
                 models.AutoField(db_column='Company_id',
                                  primary_key=True,
                                  serialize=False)),
                ('company_name',
                 models.CharField(db_column='Company_name', max_length=32)),
                ('description', models.TextField(db_column='Description')),
            ],
            options={
                'db_table': 'Company',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Direction',
            fields=[
                ('direction_id',
                 models.AutoField(db_column='Direction_id',
                                  primary_key=True,
                                  serialize=False)),
                ('direction_name',
                 models.CharField(db_column='Direction_name', max_length=64)),
            ],
            options={
                'db_table': 'Direction',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='DjangoAdminLog',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('action_time', models.DateTimeField()),
                ('object_id', models.TextField(blank=True, null=True)),
                ('object_repr', models.CharField(max_length=200)),
                ('action_flag', models.SmallIntegerField()),
                ('change_message', models.TextField()),
            ],
            options={
                'db_table': 'django_admin_log',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='DjangoContentType',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('app_label', models.CharField(max_length=100)),
                ('model', models.CharField(max_length=100)),
            ],
            options={
                'db_table': 'django_content_type',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='DjangoMigrations',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('app', models.CharField(max_length=255)),
                ('name', models.CharField(max_length=255)),
                ('applied', models.DateTimeField()),
            ],
            options={
                'db_table': 'django_migrations',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='DjangoSession',
            fields=[
                ('session_key',
                 models.CharField(max_length=40,
                                  primary_key=True,
                                  serialize=False)),
                ('session_data', models.TextField()),
                ('expire_date', models.DateTimeField()),
            ],
            options={
                'db_table': 'django_session',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Education',
            fields=[
                ('education_id',
                 models.AutoField(db_column='Education_id',
                                  primary_key=True,
                                  serialize=False)),
            ],
            options={
                'db_table': 'Education',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Employer',
            fields=[
                ('employer_id',
                 models.AutoField(db_column='Employer_id',
                                  primary_key=True,
                                  serialize=False)),
                ('surname', models.CharField(db_column='Surname',
                                             max_length=32)),
                ('employer_name',
                 models.CharField(db_column='Employer_name', max_length=32)),
                ('middlename',
                 models.CharField(db_column='Middlename', max_length=32)),
                ('login', models.CharField(db_column='Login', max_length=25)),
                ('password',
                 models.CharField(db_column='Password', max_length=15)),
            ],
            options={
                'db_table': 'Employer',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Events',
            fields=[
                ('events_id',
                 models.AutoField(db_column='Events_id',
                                  primary_key=True,
                                  serialize=False)),
                ('events_name',
                 models.CharField(db_column='Events_name', max_length=64)),
                ('events_type',
                 models.CharField(db_column='Events_type', max_length=32)),
                ('events_data', models.TextField(db_column='Events_data')),
            ],
            options={
                'db_table': 'Events',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Faculty',
            fields=[
                ('faculty_id',
                 models.AutoField(db_column='Faculty_id',
                                  primary_key=True,
                                  serialize=False)),
                ('faculty_name',
                 models.CharField(db_column='Faculty_name', max_length=64)),
            ],
            options={
                'db_table': 'Faculty',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Group',
            fields=[
                ('group_id',
                 models.AutoField(db_column='Group_id',
                                  primary_key=True,
                                  serialize=False)),
                ('group_name',
                 models.CharField(db_column='Group_name', max_length=32)),
            ],
            options={
                'db_table': 'Group_',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='ListOfAchievementsreferences',
            fields=[
                ('list_of_achievementsreferences_id',
                 models.AutoField(
                     db_column='List_of_Achievementsreferences_id',
                     primary_key=True,
                     serialize=False)),
            ],
            options={
                'db_table': 'List_of_Achievementsreferences',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='MainTask',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title', models.CharField(max_length=50)),
                ('task', models.TextField()),
            ],
            options={
                'db_table': 'main_task',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Profile',
            fields=[
                ('profile_id',
                 models.AutoField(db_column='Profile_id',
                                  primary_key=True,
                                  serialize=False)),
                ('profile_name',
                 models.CharField(db_column='Profile_name', max_length=64)),
            ],
            options={
                'db_table': 'Profile',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Project',
            fields=[
                ('project_id',
                 models.AutoField(db_column='Project_id',
                                  primary_key=True,
                                  serialize=False)),
                ('project_name',
                 models.CharField(db_column='Project_name', max_length=64)),
                ('project_description',
                 models.TextField(db_column='Project_description')),
                ('project_content',
                 models.TextField(db_column='Project_content')),
            ],
            options={
                'db_table': 'Project',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='ProjectList',
            fields=[
                ('project_list_id',
                 models.AutoField(db_column='Project_list_id',
                                  primary_key=True,
                                  serialize=False)),
            ],
            options={
                'db_table': 'Project_list',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Specialization',
            fields=[
                ('specialization_id',
                 models.AutoField(db_column='Specialization_id',
                                  primary_key=True,
                                  serialize=False)),
            ],
            options={
                'db_table': 'Specialization',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Student',
            fields=[
                ('student_id',
                 models.AutoField(db_column='Student_id',
                                  primary_key=True,
                                  serialize=False)),
                ('surname', models.CharField(db_column='Surname',
                                             max_length=32)),
                ('student_name',
                 models.CharField(db_column='Student_name', max_length=32)),
                ('middlename',
                 models.CharField(db_column='Middlename', max_length=32)),
                ('login', models.CharField(db_column='Login', max_length=25)),
                ('password',
                 models.CharField(db_column='Password', max_length=15)),
            ],
            options={
                'db_table': 'Student',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Vacancy',
            fields=[
                ('vacancy_id',
                 models.AutoField(db_column='Vacancy_id',
                                  primary_key=True,
                                  serialize=False)),
                ('vacancy_name',
                 models.CharField(db_column='Vacancy_name', max_length=32)),
                ('post', models.CharField(db_column='Post', max_length=32)),
                ('requirements', models.TextField(db_column='Requirements')),
            ],
            options={
                'db_table': 'Vacancy',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Work',
            fields=[
                ('work_id',
                 models.AutoField(db_column='Work_id',
                                  primary_key=True,
                                  serialize=False)),
            ],
            options={
                'db_table': 'Work',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='BlogCategory',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name',
                 models.CharField(max_length=255,
                                  verbose_name='Имя категории')),
                ('slug', models.SlugField(unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='BlogPost',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title',
                 models.CharField(max_length=255,
                                  verbose_name='Название поста')),
                ('slug', models.SlugField(unique=True)),
                ('content', models.TextField()),
                ('image',
                 models.ImageField(blank='True',
                                   null='True',
                                   upload_to='blog_posts/')),
                ('pud_date', models.DateTimeField(auto_now=True)),
                ('in_archive', models.BooleanField(default=False)),
                ('blog_category',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='mainapp.BlogCategory',
                                   verbose_name='Имя категории')),
            ],
        ),
    ]
Esempio n. 10
0
class Image(models.Model):
    """The source data fro an image displayed in a note."""
    class NotSniffable(CannotSniff):
        """Raised if cannot sniff. Args are file_name and returncode & message from ImageMagick."""
        def __str__(self):
            file_name, returncode, message = self.args
            return 'Could not identify %s: ImageMagick identify returned status %d: %r' % (
                file_name, returncode, message)

    MAX_DATA = 10 * 1024 * 1024

    data_url = models.URLField(
        max_length=MAX_LENGTH,
        unique=True,
    )
    media_type = models.CharField(
        max_length=MAX_LENGTH,
        validators=[
            RegexValidator(r'^(image|application)/[\w.+-]+(;\s*\w+=.*)?$'),
        ],
        null=True,
        blank=True,
    )
    cached_data = models.FileField(
        upload_to='cached-images',
        null=True,
        blank=True,
        help_text=
        'A copy of the image data from which we can generate scaled representations.',
    )
    width = models.PositiveIntegerField(
        null=True,
        blank=True,
    )
    height = models.PositiveIntegerField(
        null=True,
        blank=True,
    )
    etag = models.BinaryField(
        max_length=16,
        null=True,
        blank=True,
        editable=False,
        help_text='Hash of the image data when retrieved.',
    )
    retrieved = models.DateTimeField(
        null=True,
        blank=True,
    )

    created = models.DateTimeField(default=timezone.now)
    modified = models.DateTimeField(auto_now=True)

    def __str__(self):
        last_part = self.data_url.rsplit('/', 1)[-1]
        if len(last_part) > 60:
            return '%s…%s' % (last_part[:30], last_part[-20:])
        return last_part

    def retrieve_data_task(self):
        """Celery signature to arrange for async download of this image."""
        from . import tasks

        return tasks.retrieve_image_data.s(
            self.pk,
            if_not_retrieved_since=(self.retrieved.timestamp()
                                    if self.retrieved else None))

    def queue_retrieve_data(self):
        """Arrange for async download of this image."""
        # Queue after transaction committed to avoid a race with the Celery queue.
        transaction.on_commit(self.retrieve_data_task().delay)

    @transaction.atomic
    def retrieve_data(self, if_not_retrieved_since=None, save=False):
        """Download the image data if available."""
        if self.retrieved and (not if_not_retrieved_since
                               or if_not_retrieved_since < self.retrieved):
            return
        self.retrieved = timezone.now()
        self.save(
        )  # This will be rolled back in case of error but settingit now avoids some race conditons.

        if self.data_url.startswith('data:'):
            media_type, rest = self.data_url.split(';', 1)
            if rest.startswith('base64,'):
                data = b64decode(rest[7:])
            self.etag = md5(data).digest()
            file = ContentFile(data)
        else:
            r = requests.get(self.data_url)
            media_type = r.headers['Content-Type']
            buf = io.BytesIO()
            total_size = 0
            hasher = md5()
            for chunk in r.iter_content(chunk_size=10_240):
                total_size += len(chunk)
                buf.write(chunk)
                hasher.update(chunk)
            self.etag = hasher.digest()
            data = buf.getvalue()
            file = File(buf)

        if media_type:
            self.media_type = media_type
        try:
            self._sniff(input=data, media_type=media_type
                        )  # Needed to get file type for file name.
            file_name = file_name_from_etag(self.etag, self.media_type)
        except Image.NotSniffable as e:
            file_name = file_name_from_etag(self.etag, None)
            logger.warning(e)
        self.cached_data.save(file_name, file, save=save)

    def sniff(self, save=False):
        """Presuming already has image data, guess width, height, and media_type."""
        with self.cached_data.open() as f:
            if not self.etag:
                # GHappens if cached data is set outside of retrieve_data.
                hasher = md5()
                chunk = f.read(10_240)
                while chunk:
                    hasher.update(chunk)
                    chunk = f.read(10_240)
                self.etag = hasher.digest()
                f.seek(0)
            self._sniff(stdin=f.file)

    def _sniff(self, media_type=None, **kwargs):
        """Given a file-like object, guess width, height, and media_type.

        Arguments --
            kwargs -- how to get the input. Either stdin=REALFILE or input=BYTES
        """
        try:
            self.media_type, self.width, self.height = _sniff(
                media_type=media_type, **kwargs)
        except CannotSniff as e:
            rc, msg = e.args
            raise Image.NotSniffable(file_name_from_etag(self.etag, None), rc,
                                     msg)

    def create_square_representation(self, size):
        """Create a representation (probably cropped) of this image."""
        return self.create_representation(SizeSpec.of_square(size))

    @transaction.atomic
    def create_representation(self, spec):
        """Create a representation  of this image.

        Arguments --
            spec -- SizeSpec instance that specifies how to scale and crop
        """
        if not self.width or not self.height:
            # Image size not known, so probably not actually an image.
            return

        scaled, crop = spec.scale_and_crop_to_match(self.width, self.height)
        final_width, final_height = crop or scaled
        if self.representations.filter(width=final_width,
                                       height=final_height).exists():
            # Already done!
            return

        if final_width == self.width and final_height == self.height:
            # Want the original size of the image. Just copy the data directly.
            rep = self.representations.create(media_type=self.media_type,
                                              width=self.width,
                                              height=self.height,
                                              is_cropped=bool(crop),
                                              etag=self.etag)
            with self.cached_data.open() as f:
                rep.content.save(file_name_from_etag(rep.etag, rep.media_type),
                                 f)
            return

        if crop:
            cmd = [
                'convert', '-', '-resize',
                '^%dx%d>' % scaled, '-gravity', 'center', '-extent',
                '%dx%d' % crop, '-'
            ]
        else:
            cmd = ['convert', '-', '-resize', '%dx%d>' % scaled, '-']
        with self.cached_data.open() as f:
            output = subprocess.run(cmd,
                                    check=True,
                                    stdin=f.file,
                                    stdout=subprocess.PIPE).stdout
        etag = md5(output).digest()
        output_file = ContentFile(output)
        rep = self.representations.create(media_type=self.media_type,
                                          width=final_width,
                                          height=final_height,
                                          is_cropped=bool(crop),
                                          etag=etag)
        rep.content.save(file_name_from_etag(rep.etag, rep.media_type),
                         output_file)

    def representation_task(self, spec):
        """Celery signature to arrange for representarion to be created.

        Do not try to do this in the same transaction as creates the image,
        as this causes a race condition.
        """
        from . import tasks

        return tasks.create_image_representation.si(self.pk, spec.unparse())

    def queue_representation(self, spec):
        """Arrange for representation satisfying this spec to be created.

        Do not try to do this in the same transaction as creates the image,
        as this causes a race condition.
        """
        self.representation_task(spec).delay()

    @transaction.atomic
    def find_representation(self, spec):
        """Return the best match for a square area of this size.

        If there is no exact match, fires signal.
        """
        if self.width and self.height:
            final_width, final_height = spec.best_match(
                self.width, self.height)
            results = list(
                self.representations.filter(width__lte=final_width,
                                            height__lte=final_height).order_by(
                                                (F('width') *
                                                 F('height')).desc())[:1])
            result = results[0] if results else None
        else:
            result = None
        if not result or result.width != final_width or result.height != final_height:
            wants_representation.send(self.__class__, instance=self, spec=spec)
        return result

    def find_square_representation(self, size):
        """Return the best match for a square area of this size.

        If there is no exact match, fires signal.
        """
        return self.find_representation(SizeSpec.of_square(size))

    def wants_size(self):
        """Indicates size is wanted and not available."""
        if self.width and self.height:
            return
        wants_data.send(self.__class__, instance=self)
Esempio n. 11
0
 class Model(models.Model):
     field = models.BinaryField(default='test')
Esempio n. 12
0
 class Model(models.Model):
     field1 = models.BinaryField(default=b'test')
     field2 = models.BinaryField(default=None)
Esempio n. 13
0
class Video(models.Model):
    objects = VideoManager()

    video_views_id = models.IntegerField(default=-1)
    video_likes_id = models.IntegerField(default=-1)
    video_reports_id = models.IntegerField(default=-1)

    video_views = models.IntegerField(default=0)
    video_likes = models.IntegerField(default=0)
    video_reports = models.IntegerField(default=0)

    title = models.CharField(max_length=200, default='Default title')

    added_date = models.DateTimeField(default=timezone.now)

    description_json = models.BinaryField(default=''.encode())

    storage_path = models.CharField(max_length=200, default='')
    storage_name = models.CharField(max_length=200, default='')
    storage_path_url = models.CharField(max_length=200, default='')

    source_path = models.CharField(max_length=200, default='')
    source_thread_number = models.CharField(max_length=200, default='')
    source_thread_path = models.CharField(max_length=200, default='')
    is_thread_alive = models.BooleanField(max_length=1, default=True)

    preview_storage_path = models.CharField(max_length=200, default='')
    preview_storage_name = models.CharField(max_length=200, default='')
    preview_storage_path_url = models.CharField(max_length=200, default='')

    video_width = models.CharField(max_length=200, default='300')
    video_height = models.CharField(max_length=200, default='300')

    video_size = models.CharField(max_length=200, default='0')

    video_size_str = models.CharField(max_length=200, default='0')
    video_duration_str = models.CharField(max_length=200, default='0')

    is_adult = models.BooleanField(max_length=1, default=False)
    is_music = models.BooleanField(max_length=1, default=False)
    is_hot = models.BooleanField(max_length=1, default=False)
    is_webm = models.BooleanField(max_length=1, default=False)
    is_mp4 = models.BooleanField(max_length=1, default=False)

    is_deleted = models.BooleanField(max_length=1, default=False)

    is_source_object_deleted = models.BooleanField(max_length=1, default=False)
    is_source_thread_deleted = models.BooleanField(max_length=1, default=False)

    STATUS_ERROR = 'Video status error'
    STATUS_NOTSET = 'Video status not set'
    STATUS_DOWNLOADING = 'Video is downloading'
    STATUS_DOWNLOADED = 'Video is downloaded'
    STATUS_DELETED = 'Video is deleted'
    STATUS_HIDDEN = 'Video is hidden'

    VIDEO_STATUS = (
        (STATUS_DOWNLOADING, 'Downloading'),
        (STATUS_DOWNLOADED, 'Downloaded'),
        (STATUS_NOTSET, 'Notset'),
        (STATUS_ERROR, 'Error'),
        (STATUS_HIDDEN, 'Hidden'),
        (STATUS_DELETED, 'Deleted'),
    )

    video_status = models.CharField(max_length=200,
                                    choices=VIDEO_STATUS,
                                    default=STATUS_NOTSET)

    FORMAT_MP4 = '.mp4'
    FORMAT_WEBM = '.webm'

    VIDEO_FORMATS = (
        (FORMAT_MP4, 'mp4'),
        (FORMAT_WEBM, 'webm'),
    )

    video_format = models.CharField(max_length=200,
                                    choices=VIDEO_FORMATS,
                                    default=FORMAT_WEBM)

    def __str__(self):
        return self.title

    def set_description(self, data):
        self.description_json = json.dumps(data)
        self.save()

    def get_description(self):
        return json.loads(str(self.description_json))

    """@property
    def get_views(self):
        views = get_object_or_404(VideoViews, pk=self.video_views_id)
        hit_count = HitCount.objects.get_for_object(views)
        return hit_count.hits

    @property
    def get_likes(self):
        likes = get_object_or_404(VideoLikes, pk=self.video_likes_id)
        hit_count = HitCount.objects.get_for_object(likes)
        return hit_count.hits

    @property
    def get_reports(self):
        reports = get_object_or_404(VideoReports, pk=self.video_reports_id)
        hit_count = HitCount.objects.get_for_object(reports)
        return hit_count.hits"""

    def view_video(self, request):
        result = False
        views = get_object_or_404(VideoViews, pk=self.video_views_id)
        hit_count = HitCount.objects.get_for_object(views)
        hits_before = hit_count.hits
        hit_count_response = HitCountMixin.hit_count(request, hit_count)
        result = hit_count_response.hit_counted

        if result:
            self.video_views = hits_before + 1
            self.save()

        return result

    def like_video(self, request):
        result = False
        likes = get_object_or_404(VideoLikes, pk=self.video_likes_id)
        hit_count = HitCount.objects.get_for_object(likes)
        hits_before = hit_count.hits
        hit_count_response = HitCountMixin.hit_count(request, hit_count)
        result = hit_count_response.hit_counted
        print('kek')
        if result:
            self.video_likes = hits_before + 1
            print('kek')
            if self.video_likes > 3 and not self.is_adult and not self.is_hot:
                self.is_webm = False
                self.is_mp4 = False
                self.is_adult = False
                self.is_hot = True

            self.save()

        return result

    def check_if_liked(self, request):
        likes = get_object_or_404(VideoLikes, pk=self.video_likes_id)
        hit_count = HitCount.objects.get_for_object(likes)
        hit_count_response = hitcount_module.is_hit(request, hit_count)
        return not hit_count_response.hit_counted

    def report_video(self, request):
        result = False
        reports = get_object_or_404(VideoReports, pk=self.video_reports_id)
        hit_count = HitCount.objects.get_for_object(reports)
        hits_before = hit_count.hits
        hit_count_response = HitCountMixin.hit_count(request, hit_count)
        result = hit_count_response.hit_counted

        if result:
            self.video_reports = hits_before + 1

            if self.video_reports > 3:
                self.is_reported = True

            self.save()

        return result

    def check_if_reported(self, request):
        reports = get_object_or_404(VideoReports, pk=self.video_reports_id)
        hit_count = HitCount.objects.get_for_object(reports)
        hit_count_response = hitcount_module.is_hit(request, hit_count)
        return not hit_count_response.hit_counted

    def reset_reports(self):
        new_reports = VideoReports()
        new_reports.save()

        try:
            reports = get_object_or_404(VideoReports, pk=self.video_reports_id)
            reports.delete()
        except Exception as e:
            logging.error(e)

        self.is_reported = False
        self.video_reports_id = new_reports.id
        self.video_reports = 0
        self.save()

    is_reported = models.BooleanField(max_length=1, default=False)

    def delete(self):
        try:
            likes = get_object_or_404(VideoLikes, pk=self.video_likes_id)
        except Exception as e:
            logging.error(e)
            likes = None
        try:
            views = get_object_or_404(VideoViews, pk=self.video_views_id)
        except Exception as e:
            logging.error(e)
            views = None
        try:
            reports = get_object_or_404(VideoReports, pk=self.video_reports_id)
        except Exception as e:
            logging.error(e)
            reports = None

        super(Video, self).delete()

        if likes:
            likes.delete()
        if views:
            views.delete()
        if reports:
            reports.delete()

    """
Esempio n. 14
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Authors',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField()),
                ('sort', models.TextField(blank=True, null=True)),
                ('link', models.TextField()),
            ],
            options={
                'db_table': 'authors',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Books',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.TextField()),
                ('sort', models.TextField(blank=True, null=True)),
                ('timestamp', models.TextField(blank=True, null=True)),
                ('pubdate', models.TextField(blank=True, null=True)),
                ('series_index', models.FloatField()),
                ('author_sort', models.TextField(blank=True, null=True)),
                ('isbn', models.TextField(blank=True, null=True)),
                ('lccn', models.TextField(blank=True, null=True)),
                ('path', models.TextField()),
                ('flags', models.IntegerField()),
                ('uuid', models.TextField(blank=True, null=True)),
                ('has_cover', models.BooleanField(blank=True, null=True)),
                ('last_modified', models.TextField()),
            ],
            options={
                'db_table': 'books',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='BooksAuthorsLink',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ],
            options={
                'db_table': 'books_authors_link',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='BooksCustomColumn1Link',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField()),
                ('value', models.IntegerField()),
            ],
            options={
                'db_table': 'books_custom_column_1_link',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='BooksLanguagesLink',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField()),
                ('lang_code', models.IntegerField()),
                ('item_order', models.IntegerField()),
            ],
            options={
                'db_table': 'books_languages_link',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='BooksPluginData',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField()),
                ('name', models.TextField()),
                ('val', models.TextField()),
            ],
            options={
                'db_table': 'books_plugin_data',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='BooksPublishersLink',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField()),
                ('publisher', models.IntegerField()),
            ],
            options={
                'db_table': 'books_publishers_link',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='BooksRatingsLink',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField()),
                ('rating', models.IntegerField()),
            ],
            options={
                'db_table': 'books_ratings_link',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='BooksSeriesLink',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField()),
                ('series', models.IntegerField()),
            ],
            options={
                'db_table': 'books_series_link',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='BooksTagsLink',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField()),
                ('tag', models.IntegerField()),
            ],
            options={
                'db_table': 'books_tags_link',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Comments',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField()),
                ('text', models.TextField()),
            ],
            options={
                'db_table': 'comments',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='ConversionOptions',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('format', models.TextField()),
                ('book', models.IntegerField(blank=True, null=True)),
                ('data', models.BinaryField()),
            ],
            options={
                'db_table': 'conversion_options',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='CustomColumn1',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('value', models.TextField()),
            ],
            options={
                'db_table': 'custom_column_1',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='CustomColumn2',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField(blank=True, null=True)),
                ('value', models.IntegerField()),
            ],
            options={
                'db_table': 'custom_column_2',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='CustomColumns',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('label', models.TextField()),
                ('name', models.TextField()),
                ('datatype', models.TextField()),
                ('mark_for_delete', models.BooleanField()),
                ('editable', models.BooleanField()),
                ('display', models.TextField()),
                ('is_multiple', models.BooleanField()),
                ('normalized', models.BooleanField()),
            ],
            options={
                'db_table': 'custom_columns',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Data',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField()),
                ('format', models.TextField()),
                ('uncompressed_size', models.IntegerField()),
                ('name', models.TextField()),
            ],
            options={
                'db_table': 'data',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Feeds',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.TextField()),
                ('script', models.TextField()),
            ],
            options={
                'db_table': 'feeds',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Identifiers',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField()),
                ('type', models.TextField()),
                ('val', models.TextField()),
            ],
            options={
                'db_table': 'identifiers',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Languages',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('lang_code', models.TextField()),
            ],
            options={
                'db_table': 'languages',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='LastReadPositions',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField()),
                ('format', models.TextField()),
                ('user', models.TextField()),
                ('device', models.TextField()),
                ('cfi', models.TextField()),
                ('epoch', models.FloatField()),
                ('pos_frac', models.FloatField()),
            ],
            options={
                'db_table': 'last_read_positions',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='LibraryId',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.TextField()),
            ],
            options={
                'db_table': 'library_id',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='MetadataDirtied',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('book', models.IntegerField()),
            ],
            options={
                'db_table': 'metadata_dirtied',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Preferences',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.TextField()),
                ('val', models.TextField()),
            ],
            options={
                'db_table': 'preferences',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Publishers',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField()),
                ('sort', models.TextField(blank=True, null=True)),
            ],
            options={
                'db_table': 'publishers',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Ratings',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('rating', models.IntegerField(blank=True, null=True)),
            ],
            options={
                'db_table': 'ratings',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Series',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField()),
                ('sort', models.TextField(blank=True, null=True)),
            ],
            options={
                'db_table': 'series',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Tags',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField()),
            ],
            options={
                'db_table': 'tags',
                'managed': False,
            },
        ),
    ]
Esempio n. 15
0
 def test_binary_field(self):
     field = models.BinaryField()
     name, path, args, kwargs = field.deconstruct()
     self.assertEqual(path, "django.db.models.BinaryField")
     self.assertEqual(args, [])
     self.assertEqual(kwargs, {})
Esempio n. 16
0
class Token(models.Model):
    token = models.CharField(verbose_name='token',
                             max_length=255,
                             primary_key=True)
    value = models.BinaryField(verbose_name='值', max_length=2555)
    expiration = models.DateTimeField(verbose_name='过期时间')
Esempio n. 17
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('organizacionalApp', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Colaborador',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('nome', models.CharField(max_length=60, unique=True)),
                ('nascimento', models.DateField()),
                ('rg', models.CharField(max_length=12)),
                ('cpf', models.CharField(max_length=12)),
                ('telefone', models.CharField(max_length=13)),
                ('cnh', models.CharField(max_length=12)),
                ('cnh_tipo',
                 models.CharField(default='Não Possui', max_length=12)),
                ('sexo_choices', models.CharField(max_length=2)),
                ('foto_colaborador', models.BinaryField(editable=True)),
                ('departamento',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='organizacionalApp.Departamento')),
                ('funcao',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='organizacionalApp.Funcao')),
            ],
            options={
                'db_table': 'Colaborador',
            },
        ),
        migrations.CreateModel(
            name='TipoFormacao',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('tipo_formacao', models.CharField(max_length=15,
                                                   unique=True)),
            ],
            options={
                'db_table': 'Tipo_Formacao',
            },
        ),
        migrations.CreateModel(
            name='Formacao',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('nome_curso', models.CharField(max_length=50)),
                ('instituicao', models.CharField(max_length=50)),
                ('dt_inicio', models.DateField()),
                ('dt_termino', models.DateField()),
                ('colaborador',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='core.Colaborador',
                                   to_field='nome')),
                ('tipo_formacao',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='core.TipoFormacao',
                                   to_field='tipo_formacao')),
            ],
            options={
                'db_table': 'Formacao',
            },
        ),
    ]
Esempio n. 18
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Beneficiary',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('beneficiary_name',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('father_name',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('age', models.IntegerField(blank=True, null=True)),
                ('gender',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('signature', models.BooleanField(default=True)),
                ('remarks',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('create_date', models.DateTimeField(blank=True, null=True)),
                ('edit_date', models.DateTimeField(blank=True, null=True)),
            ],
            options={
                'ordering': ('beneficiary_name', ),
            },
        ),
        migrations.CreateModel(
            name='BinaryField',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('data', models.BinaryField()),
            ],
        ),
        migrations.CreateModel(
            name='CustomForm',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(blank=True,
                                          max_length=255,
                                          null=True)),
                ('description', models.TextField(blank=True, null=True)),
                ('validations',
                 models.CharField(blank=True, max_length=500, null=True)),
                ('fields',
                 django.contrib.postgres.fields.jsonb.JSONField(null=True)),
                ('is_public', models.BooleanField(default=0)),
                ('default_global', models.BooleanField(default=0)),
                ('create_date', models.DateTimeField(blank=True, null=True)),
                ('edit_date', models.DateTimeField(blank=True, null=True)),
            ],
            options={
                'ordering': ('name', ),
            },
        ),
        migrations.CreateModel(
            name='CustomFormField',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(blank=True,
                                          max_length=255,
                                          null=True)),
                ('label',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('validations',
                 models.CharField(blank=True, max_length=500, null=True)),
                ('order', models.IntegerField(default=0)),
                ('required', models.BooleanField(default=0)),
                ('create_date', models.DateTimeField(blank=True, null=True)),
                ('edit_date', models.DateTimeField(blank=True, null=True)),
            ],
            options={
                'ordering': ('name', ),
            },
        ),
        migrations.CreateModel(
            name='Distribution',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('distribution_name', models.CharField(max_length=255)),
                ('distribution_implementer',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('reporting_period',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('total_beneficiaries_received_input',
                 models.IntegerField(blank=True, null=True)),
                ('distribution_location',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('input_type_distributed',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('distributor_name_and_affiliation',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('distributor_contact_number',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('start_date', models.DateTimeField(blank=True, null=True)),
                ('end_date', models.DateTimeField(blank=True, null=True)),
                ('form_filled_by',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('form_filled_by_position',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('form_filled_by_contact_num',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('form_filled_date',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('form_verified_by',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('form_verified_by_position',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('form_verified_by_contact_num',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('form_verified_date',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('create_date', models.DateTimeField(blank=True, null=True)),
                ('edit_date', models.DateTimeField(blank=True, null=True)),
            ],
            options={
                'ordering': ('distribution_name', ),
            },
        ),
        migrations.CreateModel(
            name='FieldType',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(blank=True,
                                          max_length=255,
                                          null=True)),
                ('create_date', models.DateTimeField(blank=True, null=True)),
                ('edit_date', models.DateTimeField(blank=True, null=True)),
            ],
            options={
                'ordering': ('name', ),
            },
        ),
        migrations.CreateModel(
            name='TrainingAttendance',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('training_name', models.CharField(max_length=255)),
                ('implementer',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('reporting_period',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('total_participants',
                 models.IntegerField(blank=True, null=True)),
                ('location',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('community',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('training_duration',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('start_date',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('end_date',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('trainer_name',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('trainer_contact_num',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('form_filled_by',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('form_filled_by_contact_num',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('create_date', models.DateTimeField(blank=True, null=True)),
                ('edit_date', models.DateTimeField(blank=True, null=True)),
            ],
            options={
                'ordering': ('training_name', ),
            },
        ),
    ]
Esempio n. 19
0
class Testtt(models.Model):
    "Generated Model"
    testt = models.BinaryField()
Esempio n. 20
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('Users', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Auction_Bidder',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
            ],
        ),
        migrations.CreateModel(
            name='Auction_Details',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('auction_id', models.IntegerField(db_index=True,
                                                   unique=True)),
                ('scheduled_date', models.DateTimeField()),
                ('creator_id',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='Users.Profile')),
            ],
        ),
        migrations.CreateModel(
            name='Item_Details',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('item_id', models.IntegerField()),
                ('description', models.TextField()),
                ('item_name', models.CharField(max_length=20)),
                ('status', models.BinaryField(default=0)),
                ('base_price', models.FloatField()),
                ('updated_price', models.FloatField()),
                ('auction_id',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='Auctions.Auction_Details')),
                ('bidder_id',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='Users.Profile')),
            ],
        ),
        migrations.CreateModel(
            name='Keywords',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('keyword', models.CharField(max_length=20)),
                ('item_id',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='Auctions.Item_Details')),
            ],
        ),
        migrations.AddField(
            model_name='auction_bidder',
            name='auction_id',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='Auctions.Auction_Details'),
        ),
        migrations.AddField(
            model_name='auction_bidder',
            name='bidder_id',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='Users.Profile'),
        ),
    ]
Esempio n. 21
0
class Migration(migrations.Migration):

    replaces = [(b'frontend',
                 '0017_emailmessage_maillog_squashed_0021_auto_20170301_1627'),
                (b'frontend', '0018_auto_20170302_1533')]

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('frontend', '0016_remove_prescription_chemical'),
    ]

    operations = [
        migrations.CreateModel(
            name='EmailMessage',
            fields=[
                ('message_id',
                 models.CharField(max_length=998,
                                  primary_key=True,
                                  serialize=False)),
                ('pickled_message', models.BinaryField()),
                ('subject', models.CharField(max_length=200)),
                ('tags',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.CharField(db_index=True,
                                                 max_length=100),
                     null=True,
                     size=None)),
                ('created_at',
                 models.DateTimeField(auto_now_add=True, db_index=True)),
                ('send_count', models.SmallIntegerField(default=0)),
                ('user',
                 models.ForeignKey(blank=True,
                                   null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
                ('to',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.CharField(db_index=True,
                                                 max_length=254),
                     size=None)),
            ],
        ),
        migrations.CreateModel(
            name='MailLog',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('metadata',
                 django.contrib.postgres.fields.jsonb.JSONField(blank=True,
                                                                null=True)),
                ('recipient', models.CharField(db_index=True, max_length=254)),
                ('tags',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.CharField(db_index=True,
                                                 max_length=100),
                     null=True,
                     size=None)),
                ('reject_reason',
                 models.CharField(blank=True, max_length=15, null=True)),
                ('message_id', models.CharField(db_index=True,
                                                max_length=998)),
                ('event_type',
                 models.CharField(choices=[
                     (b'complained', b'complained'),
                     (b'delivered', b'delivered'),
                     (b'inbound_failed', b'inbound_failed'),
                     (b'clicked', b'clicked'), (b'opened', b'opened'),
                     (b'subscribed', b'subscribed'),
                     (b'deferred', b'deferred'), (b'inbound', b'inbound'),
                     (b'unknown', b'unknown'), (b'rejected', b'rejected'),
                     (b'queued', b'queued'), (b'failed', b'failed'),
                     (b'autoresponded', b'autoresponded'),
                     (b'unsubscribed', b'unsubscribed'),
                     (b'bounced', b'bounced'), (b'sent', b'sent')
                 ],
                                  db_index=True,
                                  max_length=15)),
                ('timestamp', models.DateTimeField(blank=True, null=True)),
            ],
        ),
    ]
Esempio n. 22
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="Client",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "ip_address",
                    models.BinaryField(db_index=True,
                                       max_length=16,
                                       unique=True),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Post",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "pub_date",
                    models.DateTimeField(auto_now_add=True,
                                         verbose_name="date published"),
                ),
                ("title", models.CharField(max_length=128)),
                ("code", models.TextField()),
                ("note", models.TextField(null=True)),
                (
                    "client",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        to="posts.client",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Vote",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_bad", posts.models.VoteField(db_index=True)),
                (
                    "client",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="posts.client"),
                ),
                (
                    "post",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="posts.post"),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Suggestion",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "pub_date",
                    models.DateTimeField(auto_now_add=True,
                                         verbose_name="date published"),
                ),
                ("code", models.TextField()),
                ("description", models.TextField()),
                (
                    "client",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="posts.client"),
                ),
                (
                    "post",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="posts.post"),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
    ]
Esempio n. 23
0
class Person(models.Model):
    name = models.CharField(max_length=100)
    cars = models.ManyToManyField(Car, through='PossessedCar')
    data = models.BinaryField(null=True)