g214/page/models.py

74 lines
2.7 KiB
Python

#coding:utf-8
from __future__ import unicode_literals
import os
from django.db import models
import uuid
# Create your models here.
from g214 import settings
def content_file_name(instance, filename):
_, ext = os.path.splitext(filename)
instance.pdf_name = filename
filename = str(uuid.uuid4()) + ext
return os.path.join('pdf', filename)
class Page(models.Model):
CATEGORY_CHOICES = ((11, u'基地简介'),
(21, u'工地简报'),
(31, u'科普园地'))
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
name = models.IntegerField(u'标签', choices=CATEGORY_CHOICES)
title = models.CharField(u'标题', max_length=64)
content = models.TextField(u'内容', blank=True, null=True)
created = models.DateTimeField(u'发表时间')
updated = models.DateTimeField(u'更新时间', auto_now=True)
page_id = models.UUIDField(u'页面id', default=uuid.uuid4, blank=True, null=True)
pdf = models.FileField(u'pdf文件', upload_to=content_file_name, blank=True, null=True)
pdf_name = models.CharField(u'文件名', max_length=256, blank=True, null=True)
def __unicode__(self):
return self.title
class Meta:
verbose_name_plural=u'科普基地'
#学术委员
class Member(models.Model):
GENDER_CHOICES = ((1, u''),
(2, u''))
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
name = models.CharField(u'名字', max_length=256, blank=True, null=True)
gender = models.IntegerField(u'性别', choices=GENDER_CHOICES)
number = models.IntegerField(u'序号', blank=True, null=True)
title = models.CharField(u'职称', max_length=256, blank=True, null=True)
duty = models.CharField(u'学委会职位', max_length=256, blank=True, null=True)
specialty = models.CharField(u'专业', max_length=256, blank=True, null=True)
unit = models.CharField(u'工作单位', max_length=256, blank=True, null=True)
url = models.CharField(u'链接', max_length=256, blank=True, null=True)
def __unicode__(self):
return self.name
class Meta:
verbose_name_plural=u'学术委员会'
# 基地情况
class Introduction(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
title = models.CharField(u'标题', max_length=64, blank=True, null=True)
content = models.TextField(u'内容', blank=True, null=True)
created = models.DateTimeField(u'发表时间', blank=True, null=True)
updated = models.DateTimeField(u'更新时间', blank=True, null=True, auto_now=True)
def __unicode__(self):
return self.title
class Meta:
verbose_name_plural=u'基地情况'