Ejemplo n.º 1
0
class Course(models.Model):
    vendor = models.TextField()

    year_start = models.PositiveSmallIntegerField(help_text="YYYY")
    year_end = models.PositiveSmallIntegerField(help_text="YYYY",
                                                blank=True,
                                                null=True,
                                                default=None)

    is_expiration = models.BooleanField()

    title = models.TextField()
    description = tinymce.models.HTMLField(blank=True)
    link = models.URLField(blank=True, null=True, default=None)

    small_icon = models.ImageField(blank=True, null=True, default=None)

    tags = models.ManyToManyField('tags.Tag', null=True)

    class Meta:
        ordering = ('-year_start', )

    def year_range_str(self):
        if self.is_expiration:
            return "{} - {}".format(self.year_start, self.year_end)
        else:
            return self.year_start

    def __str__(self):
        return "{year} {vendor} - {title}".format(year=self.year_start,
                                                  vendor=self.vendor,
                                                  title=self.title)
Ejemplo n.º 2
0
class SocialMedia(models.Model):
    display_name = models.TextField()
    url = models.URLField()

    small_icon = models.ImageField(blank=True, null=True, default=None)

    def __str__(self):
        return self.display_name
Ejemplo n.º 3
0
class Experience(models.Model):
    company = models.TextField()
    company_small_logo = models.ImageField(blank=True, null=True, default=None)
    company_link = models.URLField(blank=True, null=True, default=None)

    month_start = models.PositiveSmallIntegerField()
    year_start = models.PositiveSmallIntegerField()

    is_current_job = models.BooleanField(default=False)

    month_end = models.PositiveSmallIntegerField(blank=True,
                                                 null=True,
                                                 default=None)
    year_end = models.PositiveSmallIntegerField(blank=True,
                                                null=True,
                                                default=None)

    title = models.TextField()
    description = tinymce.models.HTMLField()
    location = models.TextField()

    tags = models.ManyToManyField('tags.Tag', null=True)

    class Meta:
        ordering = ('-year_start', )

    def month_year_range_str(self):
        range = "{month_start:0>2d}/{year_start} - ".format(
            month_start=self.month_start, year_start=self.year_start)
        if self.is_current_job:
            range += "Present"
        else:
            range += "{month_end:0>2d}/{year_end}".format(
                month_end=self.month_end, year_end=self.year_end)

        return range

    month_year_range_str.short_description = "Dates"  # This is so the admin page has correct column header

    def __str__(self):
        return "{range} | {company} | {title}".format(
            range=self.month_year_range_str(),
            company=self.company,
            title=self.title)
Ejemplo n.º 4
0
class Project(models.Model):
    year_start = models.PositiveSmallIntegerField()
    year_end = models.PositiveSmallIntegerField(blank=True,
                                                null=True,
                                                default=None)
    is_wip = models.BooleanField()

    git_url = models.URLField(blank=True, null=True, default=None)
    title = models.TextField()
    title_slug = models.SlugField()

    # This is the full project page content
    full_content = tinymce.models.HTMLField()

    # This is the condensed version for the resume page
    resume_content = tinymce.models.HTMLField()

    project_logo = models.ImageField(blank=True, null=True, default=None)

    tags = models.ManyToManyField('tags.Tag', null=True)

    class Meta:
        ordering = ('-year_start', )

    def __str__(self):
        return "{year} - {title}".format(year=self.year_start,
                                         title=self.title)

    def get_date_range_str(self):
        range = "{year_start} - ".format(year_start=self.year_start)

        if self.is_wip:
            range += "Present"
        else:
            range += "{year_end}".format(year_end=self.year_end)

        return range
class Migration(migrations.Migration):
    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Blog',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title', models.CharField(max_length=255)),
                ('sub_title', models.CharField(max_length=255)),
                ('image', models.URLField()),
                ('body', tinymce.models.HTMLField()),
                ('slug', models.SlugField()),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
            ],
        ),
    ]
Ejemplo n.º 6
0
class Migration(migrations.Migration):

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Goods',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  primary_key=True,
                                  auto_created=True)),
                ('create_time',
                 models.DateTimeField(verbose_name='创建时间', auto_now_add=True)),
                ('update_time',
                 models.DateTimeField(verbose_name='更新时间', auto_now=True)),
                ('is_delete',
                 models.BooleanField(verbose_name='删除标记', default=False)),
                ('name', models.CharField(verbose_name='商品SPU名称',
                                          max_length=20)),
                ('detail',
                 tinymce.models.HTMLField(verbose_name='商品详情', blank=True)),
            ],
            options={
                'verbose_name': '商品SPU',
                'db_table': 'df_goods',
                'verbose_name_plural': '商品SPU',
            },
        ),
        migrations.CreateModel(
            name='GoodsImage',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  primary_key=True,
                                  auto_created=True)),
                ('create_time',
                 models.DateTimeField(verbose_name='创建时间', auto_now_add=True)),
                ('update_time',
                 models.DateTimeField(verbose_name='更新时间', auto_now=True)),
                ('is_delete',
                 models.BooleanField(verbose_name='删除标记', default=False)),
                ('image',
                 models.ImageField(verbose_name='图片路径', upload_to='goods')),
            ],
            options={
                'verbose_name': '商品图片',
                'db_table': 'df_goods_image',
                'verbose_name_plural': '商品图片',
            },
        ),
        migrations.CreateModel(
            name='GoodsSKU',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  primary_key=True,
                                  auto_created=True)),
                ('create_time',
                 models.DateTimeField(verbose_name='创建时间', auto_now_add=True)),
                ('update_time',
                 models.DateTimeField(verbose_name='更新时间', auto_now=True)),
                ('is_delete',
                 models.BooleanField(verbose_name='删除标记', default=False)),
                ('name', models.CharField(verbose_name='商品名称', max_length=20)),
                ('desc', models.CharField(verbose_name='商品简介',
                                          max_length=256)),
                ('price',
                 models.DecimalField(verbose_name='商品价格',
                                     max_digits=10,
                                     decimal_places=2)),
                ('unite', models.CharField(verbose_name='商品单位',
                                           max_length=20)),
                ('image',
                 models.ImageField(verbose_name='商品图片', upload_to='goods')),
                ('stock', models.IntegerField(verbose_name='商品库存', default=1)),
                ('sales', models.IntegerField(verbose_name='商品销量', default=0)),
                ('status',
                 models.SmallIntegerField(verbose_name='商品状态',
                                          default=1,
                                          choices=[(0, '下线'), (1, '上线')])),
                ('goods',
                 models.ForeignKey(verbose_name='商品SPU',
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='goods.Goods')),
            ],
            options={
                'verbose_name': '商品',
                'db_table': 'df_goods_sku',
                'verbose_name_plural': '商品',
            },
        ),
        migrations.CreateModel(
            name='GoodsType',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  primary_key=True,
                                  auto_created=True)),
                ('create_time',
                 models.DateTimeField(verbose_name='创建时间', auto_now_add=True)),
                ('update_time',
                 models.DateTimeField(verbose_name='更新时间', auto_now=True)),
                ('is_delete',
                 models.BooleanField(verbose_name='删除标记', default=False)),
                ('name', models.CharField(verbose_name='种类名称', max_length=20)),
                ('logo', models.CharField(verbose_name='标识', max_length=20)),
                ('image',
                 models.ImageField(verbose_name='商品类型图片', upload_to='type')),
            ],
            options={
                'verbose_name': '商品种类',
                'db_table': 'df_goods_type',
                'verbose_name_plural': '商品种类',
            },
        ),
        migrations.CreateModel(
            name='IndexGoodsBanner',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  primary_key=True,
                                  auto_created=True)),
                ('create_time',
                 models.DateTimeField(verbose_name='创建时间', auto_now_add=True)),
                ('update_time',
                 models.DateTimeField(verbose_name='更新时间', auto_now=True)),
                ('is_delete',
                 models.BooleanField(verbose_name='删除标记', default=False)),
                ('image',
                 models.ImageField(verbose_name='图片', upload_to='banner')),
                ('index',
                 models.SmallIntegerField(verbose_name='展示顺序', default=0)),
                ('sku',
                 models.ForeignKey(verbose_name='商品',
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='goods.GoodsSKU')),
            ],
            options={
                'verbose_name': '首页轮播商品',
                'db_table': 'df_index_banner',
                'verbose_name_plural': '首页轮播商品',
            },
        ),
        migrations.CreateModel(
            name='IndexPromotionBanner',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  primary_key=True,
                                  auto_created=True)),
                ('create_time',
                 models.DateTimeField(verbose_name='创建时间', auto_now_add=True)),
                ('update_time',
                 models.DateTimeField(verbose_name='更新时间', auto_now=True)),
                ('is_delete',
                 models.BooleanField(verbose_name='删除标记', default=False)),
                ('name', models.CharField(verbose_name='活动名称', max_length=20)),
                ('url', models.URLField(verbose_name='活动链接')),
                ('image',
                 models.ImageField(verbose_name='活动图片', upload_to='banner')),
                ('index',
                 models.SmallIntegerField(verbose_name='展示顺序', default=0)),
            ],
            options={
                'verbose_name': '主页促销活动',
                'db_table': 'df_index_promotion',
                'verbose_name_plural': '主页促销活动',
            },
        ),
        migrations.CreateModel(
            name='IndexTypeGoodsBanner',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  primary_key=True,
                                  auto_created=True)),
                ('create_time',
                 models.DateTimeField(verbose_name='创建时间', auto_now_add=True)),
                ('update_time',
                 models.DateTimeField(verbose_name='更新时间', auto_now=True)),
                ('is_delete',
                 models.BooleanField(verbose_name='删除标记', default=False)),
                ('display_type',
                 models.SmallIntegerField(verbose_name='展示类型',
                                          default=1,
                                          choices=[(0, '标题'), (1, '图片')])),
                ('index',
                 models.SmallIntegerField(verbose_name='展示顺序', default=0)),
                ('sku',
                 models.ForeignKey(verbose_name='商品SKU',
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='goods.GoodsSKU')),
                ('type',
                 models.ForeignKey(verbose_name='商品类型',
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='goods.GoodsType')),
            ],
            options={
                'verbose_name': '主页分类展示商品',
                'db_table': 'df_index_type_goods',
                'verbose_name_plural': '主页分类展示商品',
            },
        ),
        migrations.AddField(
            model_name='goodssku',
            name='type',
            field=models.ForeignKey(
                verbose_name='商品种类',
                on_delete=django.db.models.deletion.CASCADE,
                to='goods.GoodsType'),
        ),
        migrations.AddField(
            model_name='goodsimage',
            name='sku',
            field=models.ForeignKey(
                verbose_name='商品',
                on_delete=django.db.models.deletion.CASCADE,
                to='goods.GoodsSKU'),
        ),
    ]