示例#1
0
class Migration(migrations.Migration):
    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Location',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title',
                 models.CharField(max_length=200,
                                  verbose_name='Название для боковой панели')),
                ('short_description',
                 models.TextField(blank=True,
                                  verbose_name='Краткое описание')),
                ('long_description',
                 tinymce.models.HTMLField(blank=True,
                                          verbose_name='Полное описание')),
                ('lng', models.FloatField(verbose_name='Долгота')),
                ('lat', models.FloatField(verbose_name='Широта')),
                ('properties_title',
                 models.CharField(default='',
                                  max_length=200,
                                  verbose_name='Название точки на карте')),
                ('properties_placeId',
                 models.UUIDField(
                     default=uuid.uuid4,
                     editable=False,
                     verbose_name='Уникальный идентификатор локации')),
            ],
        ),
        migrations.CreateModel(
            name='Image',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('order',
                 models.SmallIntegerField(default=0,
                                          verbose_name='Позиция в списке')),
                ('image', models.ImageField(upload_to='',
                                            verbose_name='Файл')),
                ('location',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='images',
                                   to='places.location',
                                   verbose_name='Место')),
            ],
            options={
                'ordering': ['order'],
            },
        ),
    ]
示例#2
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)
示例#3
0
class Books(BaseModel):
    books_type_choices = ((k, v) for k, v in BOOKS_TYPE.items())
    status_choices = ((k, v) for k, v in STATUS_CHOICE.items())
    type_id = models.SmallIntegerField(default=PYTHON,
                                       choices=books_type_choices,
                                       verbose_name="商品种类")
    name = models.CharField(max_length=20, verbose_name="商品名称")
    desc = models.CharField(max_length=128, verbose_name="商品简介")
    price = models.DecimalField(max_digits=10,
                                decimal_places=2,
                                verbose_name="商品价格")
    unit = models.CharField(max_length=20, verbose_name="商品单位")
    stock = models.IntegerField(default=1, verbose_name="商品库存")
    sales = models.IntegerField(default=0, verbose_name="商品销量")
    detail = tinymce.models.HTMLField(verbose_name="商品详情")
    image = models.ImageField(upload_to='books', verbose_name="商品图片")
    status = models.SmallIntegerField(default=ONLINE,
                                      choices=status_choices,
                                      verbose_name="商品状态")

    objects = BooksManager()

    def __str__(self):
        return self.name

    class Meta:
        db_table = 's_books'
        verbose_name = '书籍'
        verbose_name_plural = '书籍'
示例#4
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
示例#5
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='GoodsInfo',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('gtitle', models.CharField(max_length=20, verbose_name='商品名称')),
                ('gpic', models.ImageField(blank=True, null=True, upload_to='df_goods', verbose_name='商品图片')),
                ('gprice', models.DecimalField(decimal_places=2, max_digits=7, verbose_name='商品价格')),
                ('gunit', models.CharField(default='500g', max_length=20, verbose_name='商品单位')),
                ('gclick', models.IntegerField(verbose_name='点击量')),
                ('isDelete', models.BooleanField(default=False, verbose_name='是否删除')),
                ('gjianjie', models.CharField(max_length=200, verbose_name='简介')),
                ('gkucun', models.IntegerField(verbose_name='库存')),
                ('gcontent', tinymce.models.HTMLField(verbose_name='详细介绍')),
            ],
            options={
                'verbose_name': '商品信息',
                'verbose_name_plural': '商品信息',
            },
        ),
        migrations.CreateModel(
            name='TypeInfo',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('ttitle', models.CharField(max_length=20, verbose_name='类型名称')),
                ('isDelete', models.BooleanField(default=False, verbose_name='是否删除')),
            ],
            options={
                'verbose_name': '分类信息',
                'verbose_name_plural': '分类信息',
            },
        ),
        migrations.AddField(
            model_name='goodsinfo',
            name='gtype',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='df_goods.TypeInfo', verbose_name='所属分类'),
        ),
    ]
示例#6
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)
示例#7
0
class Education(models.Model):
    year_start = models.PositiveSmallIntegerField()
    year_end = models.PositiveSmallIntegerField()

    degree = models.TextField(help_text="e.g. Associates of Arts, or AA")

    major = models.TextField()
    minor = models.TextField(blank=True, default='')

    school_name_full = models.TextField()
    school_name_acronym = models.CharField(default='', max_length=10)

    description = models.TextField(blank=True, default='')
    gpa = models.FloatField(
        blank=True,
        null=True,
        default=None,
        validators=[MinValueValidator(0.0),
                    MaxValueValidator(4.0)])

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

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

    def year_range_str(self):
        return "{start} - {end}".format(
            start=self.year_start,
            end=self.year_end if self.year_end else "Present")

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

    def __str__(self):
        return "{years} : {school} - {major}".format(
            years=self.year_range_str(),
            school=self.school_name_acronym,
            major=self.major)
示例#8
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
示例#9
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("accounts", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="Category",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("title", models.CharField(max_length=50,
                                           verbose_name="Title")),
            ],
            options={
                "verbose_name": "Category",
                "verbose_name_plural": "Categories",
            },
        ),
        migrations.CreateModel(
            name="Newsletter",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("email",
                 models.EmailField(max_length=254, verbose_name="Email")),
                (
                    "timestamp",
                    models.DateTimeField(auto_now=True,
                                         verbose_name="Timestamp"),
                ),
            ],
            options={
                "verbose_name": "newsletter",
                "verbose_name_plural": "newsletters",
            },
        ),
        migrations.CreateModel(
            name="Post",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("title", models.CharField(max_length=100,
                                           verbose_name="Title")),
                ("overview",
                 models.TextField(default="", verbose_name="Overview")),
                (
                    "timestamp",
                    models.DateTimeField(auto_now=True,
                                         verbose_name="Timestamp"),
                ),
                ("content",
                 tinymce.models.HTMLField(default="<p>Hello World</p>")),
                (
                    "featured",
                    models.BooleanField(default=False,
                                        verbose_name="Featured"),
                ),
                (
                    "thumbnail",
                    models.ImageField(
                        blank=True,
                        default="testing.jpeg",
                        upload_to="thumbnail",
                        verbose_name="Thumbnail",
                    ),
                ),
                ("slug",
                 models.SlugField(blank=True, null=True, verbose_name="Slug")),
                (
                    "author",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="accounts.author",
                        verbose_name="Author",
                    ),
                ),
                (
                    "category",
                    models.ManyToManyField(related_name="post",
                                           to="blog.Category",
                                           verbose_name="Category"),
                ),
            ],
            options={
                "verbose_name": "Post",
                "verbose_name_plural": "Posts",
            },
        ),
        migrations.CreateModel(
            name="Comment",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "timestamp",
                    models.DateTimeField(auto_now=True,
                                         verbose_name="Timestamp"),
                ),
                ("content", models.TextField(verbose_name="Content")),
                (
                    "post",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="comment",
                        to="blog.post",
                        verbose_name="post",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="accounts.author",
                        verbose_name="user",
                    ),
                ),
            ],
            options={
                "verbose_name": "comment",
                "verbose_name_plural": "comments",
            },
        ),
    ]
示例#10
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'),
        ),
    ]