示例#1
0
文件: models.py 项目: panla/kesousou
class Achievement(AbstractModel):
    original_id = models.CharField('源数据id', max_length=100, null=True, unique=True, db_index=True)
    sn = models.CharField('项目年度编号', max_length=100, null=True, db_index=True)
    title = models.CharField('标题', max_length=100, db_index=True)
    organizations = JSONField(verbose_name='完成单位', null=True)
    creators = JSONField(verbose_name='完成人', null=True)
    published_year = models.CharField('公布年份', max_length=20, null=True)
    category = models.CharField('中图分类', max_length=40, null=True)
    keywords = JSONField(verbose_name='关键词', null=True)
    abstract = models.TextField('简介', null=True)
    province = models.CharField('省市', max_length=20, null=True)
    trade_name = JSONField(verbose_name='应用行业名称', null=True)
    level = models.CharField('成果水平', max_length=20, null=True)
    contact_unit = models.CharField('联系单位', max_length=200, null=True)
    contact_address = models.CharField('联系单位地址', max_length=200, null=True)
    experts = models.ManyToManyField(Expert, related_name='achievements', db_index=True)

    class Meta:
        db_table = 'achievements'

    @classmethod
    def filter_by_expert_id(cls, expert_id):
        expert = Expert.objects.filter(id=expert_id).first()
        if expert:
            return expert.achievements.all()
        else:
            return None
示例#2
0
class SeekerProfile(Model):
    user_account_id = models.OneToOneField(UserAccount, related_name='user_account_seeker_id', on_delete=models.CASCADE)
    current_salary = models.IntegerField(null=True)
    is_annually_monthly = models.BooleanField(default=0)
    is_fresher = models.BooleanField(default=0)
    currency = models.CharField(max_length=50,null=True)
    resume_document1 = models.FileField(upload_to='documents/%Y/%m/%D/',null=True,blank=True)
    resume_video1 = models.FileField(upload_to='video/%Y/%m/%D/',null=True,blank=True)
    resume_document2 = models.FileField(upload_to='documents/%Y/%m/%D/',null=True,blank=True)
    resume_video2 = models.FileField(upload_to='video/%Y/%m/%D/',null=True,blank=True)
    notice_period = models.CharField(max_length=20,null=True)
    break_reason = models.CharField(max_length=50,null=True)
    break_duration = models.CharField(max_length=50,null=True)
    address = models.CharField(max_length=1000,null=True)
    pincode = models.IntegerField(null=True)
    martial_status= models.CharField(max_length=20,null=True)
    differently_abled= JSONField(default='{}')
    work_permit_usa= models.CharField(max_length=40,null=True)
    work_permit_other= models.CharField(max_length=100,null=True)
    desired_career_profile= JSONField(default='{}')
    #aadhar_path= models.ImageField(upload_to='aadhar/%Y/%m/%D/', null=True, blank=True)
    aadhar_url = models.CharField(max_length=400, null=True)
    resume_headline = models.CharField(max_length=300, null=True)
    photo_path = models.FileField(upload_to='photo/%Y/%m/%D/',null=True,blank=True)
    skill_name = models.CharField(max_length=300,null=True)
    technologies = models.CharField(max_length=40, null=True)
    profile_summery = models.CharField(max_length=1000, null=True)
    project_title = models.CharField(max_length=50, null=True)
    role = JSONField(default='{}')
    client = JSONField(default='{}')
    details_of_project = models.CharField(max_length=1000, null=True)
    #team_size = models.JSONField()
    role_description = models.CharField(max_length=250, null=True)
示例#3
0
文件: models.py 项目: panla/kesousou
class Periodical(AbstractModel):
    original_id = models.CharField('源数据id', max_length=100, null=True, unique=True, db_index=True)
    title = models.CharField('期刊标题', max_length=100, db_index=True)
    doi = models.CharField('doi', max_length=100, null=True, db_index=True)
    abstract = models.TextField('期刊简介', null=True)
    publish_date = models.DateField('发布日期', null=True)
    keywords = JSONField(verbose_name='关键词', null=True)
    creators = JSONField(verbose_name='作者')
    first_creator = models.CharField('第一作者', max_length=30, null=True)
    organizations = JSONField(verbose_name='作者机构')
    periodical_name = models.CharField('期刊名称', max_length=100, null=True)
    periodical_number = models.CharField('卷', max_length=30, null=True)
    periodical_column = models.CharField('栏目', max_length=50, null=True)
    page_numbers = models.CharField('页码', max_length=20, null=True)
    page_count = models.CharField('总页数', max_length=20, null=True)
    foundations = JSONField(verbose_name='基金项目', null=True)
    classification = JSONField(verbose_name='分类号', null=True)
    experts = models.ManyToManyField(Expert, related_name='periodicals', db_index=True)

    class Meta:
        db_table = 'periodicals'

    @classmethod
    def filter_by_expert_id(cls, expert_id):
        expert = Expert.objects.filter(id=expert_id).first()
        if expert:
            return expert.periodicals.all()
        else:
            return None
class JobInstall(models.Model):
    device_name = models.CharField(max_length=50)  # 设备名称
    sn = models.CharField(max_length=50)  # 设备编号
    status = models.CharField(max_length=20, default="WAITING")  # 装机状态
    ip = models.CharField(max_length=50)  # 设备需修改成的ip地址
    gateway = models.CharField(max_length=50)  # 网关
    netmask = models.CharField(max_length=50)  # 子网掩码
    hostname = models.CharField(max_length=50)  # 主机hostname
    usage = models.CharField(max_length=50)  # 设备用途
    location = models.CharField(max_length=50)  # 物理机位置
    type = models.CharField(max_length=10)  # Vm/rhev/rhel/exi
    console_ip = models.CharField(max_length=50)  # ip
    console_user = models.CharField(max_length=50)  # 名称
    console_password = models.CharField(max_length=50)  # user密码
    ipmi_server_ip = models.CharField(max_length=50)  # 堡垒机:ipmitool机器
    os_name = models.CharField(max_length=50)  # os名称
    os_version = models.CharField(max_length=50)  # os版本
    ks_name = models.CharField(max_length=50)  # ks文件名称
    profile = models.CharField(max_length=50)  # os信息
    pxe_server_ip = models.CharField(max_length=50)
    install = models.IntegerField(null=True)  # 安装状态
    # vlanid = models.CharField(max_length=20, null=True)
    mac = JSONField()  # 与pxe绑定的mac地址
    ifname = JSONField()  # 接口名称
    install_ip = models.CharField(max_length=50, null=True)  # 安装操作系统时的私网ip
    update_time = models.DateTimeField(auto_now=True)  # 创建时间和更新时间

    class Meta:
        db_table = "job_install"
示例#5
0
class Candidate(models.Model):
    name = models.CharField(max_length=50)
    email = models.EmailField()
    phone = models.CharField(max_length=15)
    career = JSONField()
    training = JSONField()
    cv_ref = models.FileField()
示例#6
0
class Organization(models.Model):
    """This is to classify help seekers in to Regions"""
    name = models.CharField(max_length=256, null=True, blank=True)
    contact_name = models.CharField(max_length=256, null=True, blank=True)
    contact_phone = models.CharField(max_length=256, null=True, blank=True)
    endorsed_by = models.CharField(max_length=4096, null=True, blank=True)
    total_endorsed = models.BigIntegerField(blank=True, null=True, default=0)
    has_12A = models.BooleanField(default=False)
    has_FCRA = models.BooleanField(default=False)
    has_GST = models.BooleanField(default=False)
    districts = JSONField(null=True,
                          blank=True)  # requires Django-Mysql package
    data_json = JSONField(null=True,
                          blank=True)  # requires Django-Mysql package
    prefill_json = JSONField(null=True,
                             blank=True)  # requires Django-Mysql package
    extra_fields = JSONField(null=True,
                             blank=True)  # requires Django-Mysql package
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        """To define meta data attributes"""
        db_table = 'organization'

    def __str__(self):
        """Default str method for the class"""
        return f"{self.name}"
示例#7
0
文件: models.py 项目: panla/kesousou
class Patent(AbstractModel):
    original_id = models.CharField('源数据id', max_length=100, null=True, unique=True, db_index=True)
    name = models.CharField('专利名称', max_length=100, db_index=True)
    abstract = models.TextField('专利简介', null=True)
    patent_type = models.CharField('专利类型', max_length=20, null=True)
    patent_code = models.CharField('专利申请号', max_length=50, unique=True, db_index=True)
    application_date = models.DateField('专利申请日期', null=True)
    publication_number = models.CharField('专利公开号', max_length=50, unique=True, db_index=True)
    publication_date = models.DateField('专利公告日期', null=True)
    main_classifications = JSONField(verbose_name='主分类号', null=True)
    classifications = JSONField(verbose_name='分类号', null=True)
    applicants = JSONField(verbose_name='申请人', null=True)
    inventors = JSONField(verbose_name='发明人', null=True)
    applicant_address = models.CharField('主发明人地址', max_length=200, null=True)
    claim = models.TextField('主权项', null=True)
    region_code = models.CharField('国别省市代码', max_length=20, null=True)
    legal_status = models.CharField('法律状态', max_length=10, null=True)
    experts = models.ManyToManyField(Expert, related_name='patents', db_index=True)

    class Meta:
        db_table = 'patents'

    @classmethod
    def filter_by_expert_id(cls, expert_id):
        expert = Expert.objects.filter(id=expert_id).first()
        if expert:
            return expert.patents.all()
        else:
            return None
示例#8
0
class New(models.Model):
    new_title = models.CharField(max_length=80, null=False)
    headline1 = models.CharField(max_length=100, null=True, blank=True)
    headline2 = models.CharField(max_length=100, null=True, blank=True)
    headline3 = models.CharField(max_length=100, null=True, blank=True)
    content = models.TextField(max_length=605, null=False)
    tables = JSONField(null=True, blank=True)
    charts = JSONField(null=True, blank=True)
    time_stamp = models.DateField(default=timezone.now)
    created_by = models.ForeignKey(User,
                                   related_name='user_created_new',
                                   null=True)

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

    def __str__(self):
        class_name = type(self).__name__
        return '{class_name} {title}'.format(class_name=class_name,
                                             title=self.new_title)

    def __repr__(self):
        class_name = type(self).__name__
        return '{class_name} {title}'.format(class_name=class_name,
                                             title=self.new_title)
示例#9
0
class SpuAttribute(Model):
    # 如 "color"
    name = models.CharField("属性名", max_length=64)
    # 如 ["red", "yellow", "green"]
    data = JSONField("属性值")
    # 如 red
    default = JSONField("默认值", null=True, blank=True)
    description = models.CharField(max_length=255, null=True, blank=True)
    # 如 select, checkbox, inputString, inputEmail, inputDate 等
    display_type = models.CharField("显示方式", max_length=32, default="checkbox")
    show_as_img = models.BooleanField("是否以图片的方式显示", default=False)
    is_required = models.SmallIntegerField("是否必填值", default=True)
    enable = models.BooleanField("可用", default=True)
    created_at = models.DateTimeField("创建时间", auto_now_add=True)
    updated_at = models.DateTimeField("更新时间", auto_now=True, null=True)

    group = models.ForeignKey("SpuAttributeGroup",
                              verbose_name="分组",
                              on_delete=models.CASCADE)
    created_user = models.ForeignKey(User,
                                     verbose_name='创建者',
                                     null=True,
                                     on_delete=models.SET_NULL)

    class Meta:
        verbose_name = 'SPU属性'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
示例#10
0
文件: models.py 项目: hjh188/tflow
class User(AbstractUser):
    phone = models.CharField(max_length=20, blank=True)
    bio = models.TextField(max_length=500, blank=True)
    location = models.CharField(max_length=30, blank=True)
    birth_date = models.DateField(null=True, blank=True)
    sidebar_menu_top = JSONField()
    sidebar_menu_bottom = JSONField()
示例#11
0
class MatchesBulkData(models.Model):
    current_matchday_data = JSONField(default=default_val)
    all_season_matches = JSONField(default=default_val)
    last_update = models.DateTimeField(default=timezone.now)

    def recently_updated(self):
        return timezone.now() - self.last_update >= 2
示例#12
0
class Standing(Model):
    contest = models.ForeignKey(Contest, models.CASCADE)
    AC_times = JSONField(blank=True, help_text="problem_id:AC_time(unit: s) mapping")
    wrong_numbers = JSONField(blank=True, help_text="problem_id:wrong_submission_number mapping")
    total_penalty = models.FloatField(default=0, help_text="unit: s")
    user = models.ForeignKey(get_user_model(), models.CASCADE)

    class Meta:
        constraints = [
            models.UniqueConstraint(fields=['contest', 'user'], name='unique_contest_user'),
        ]

    @property
    def real_AC_times(self):
        """:return problem_no:AC_time mapping"""
        AC_times = {}
        for problem_id, time in self.AC_times.items():
            order = ContestProblem.objects.get(contest=self.contest, problem_id=problem_id).problem_order
            AC_times[chr(ord('A') + order - 1)] = time

        return AC_times

    @property
    def real_wrong_numbers(self):
        """:return problem_no:wrong_number mapping"""
        wrong_numbers = {}
        for problem_id, number in self.wrong_numbers.items():
            order = ContestProblem.objects.get(contest=self.contest, problem_id=problem_id).problem_order
            wrong_numbers[chr(ord('A') + order - 1)] = number

        return wrong_numbers
示例#13
0
class ApiLog(models.Model):
    """
    记录 调用 告警组API
    """
    __cname__ = 'API日志'

    apiType = models.CharField('API类型',
                               max_length=24,
                               help_text={
                                   **Table().init(),
                               })
    requestIp = models.CharField('请求IP',
                                 max_length=24,
                                 help_text={
                                     **Table().init(),
                                 })
    request = JSONField('请求参数', help_text={
        **Table().init(),
    })
    response = JSONField('响应结果', help_text={
        **Table().init(),
    })
    requestTime = models.DateTimeField('请求时间',
                                       auto_now_add=True,
                                       help_text={
                                           **Table().init(),
                                       })

    def __str__(self):
        return '{}-{}'.format(self.requestIp, self.requestTime)
示例#14
0
class Profile(ExtraModel):
    teach = models.ForeignKey(DataSet, on_delete=models.PROTECT)
    algorithm = models.ForeignKey(Algorithm, on_delete=models.PROTECT)
    created_date = models.DateTimeField(auto_now_add=True)
    feature_importance = models.CharField(max_length=100, blank=False)
    profile_name = models.CharField(max_length=100, blank=False)
    profile_params = JSONField()
    factors = JSONField()

    def get_drop_columns(self):
        drop_columns = []
        for k, v in self.factors.items():
            if v == 0 or k == 'status':
                drop_columns.append(k)
        return drop_columns

    def get_used_factor_list(self):
        return sorted([k for k, v in self.factors.items() if v == 1 and k != 'status'])

    def get_profile_params(self):
        return self.profile_params

    def delete(self, *args, **kwargs):
        is_deletable, related = self.is_deletable()
        if is_deletable:
            profile_path = "{}/media/{}".format(BASE_DIR, self.profile_name)
            feature_path = "{}/media/{}".format(BASE_DIR, self.feature_importance)
            super().delete(*args, **kwargs)
            if os.path.isfile(profile_path):
                os.remove(profile_path)
            if os.path.isfile(feature_path):
                os.remove(feature_path)

    def __str__(self):
        return ' Model: ' + self.profile_name
示例#15
0
文件: models.py 项目: panla/kesousou
class Conference(AbstractModel):
    original_id = models.CharField('源数据id', max_length=100, null=True, unique=True, db_index=True)
    title = models.CharField('论文标题', max_length=100, db_index=True)
    abstract = models.TextField('论文摘要', null=True)
    keywords = JSONField(verbose_name='关键词', null=True)
    meeting_title = models.CharField('会议名称', max_length=100, null=True)
    meeting_date = models.DateField('会议时间', null=True)
    meeting_area = models.CharField('会议地点', max_length=100, null=True)
    creators = JSONField(verbose_name='作者')
    first_creator = models.CharField('第一作者', max_length=20, null=True, db_index=True)
    organizations = JSONField(verbose_name='作者机构')
    sponsors = JSONField(verbose_name='主办单位', null=True)
    meeting_corpus = models.CharField('母体文献', max_length=100, null=True)
    language = models.CharField('语种', max_length=10, default='中文')
    classifications = JSONField(verbose_name='机标分类号', null=True)
    publish_date = models.DateField('出版日期', null=True)
    page = models.CharField('页码', max_length=20, null=True)
    experts = models.ManyToManyField(Expert, related_name='conferences', db_index=True)

    class Meta:
        db_table = 'conferences'

    @classmethod
    def filter_by_expert_id(cls, expert_id):
        expert = Expert.objects.filter(id=expert_id).first()
        if expert:
            return expert.conferences.all()
        else:
            return None
示例#16
0
    def test_custom_json_decoder(self):
        class CustomDecoder(json.JSONDecoder):
            def decode(self, *args, **kwargs):
                return "lol"

        field = JSONField(decoder=CustomDecoder(strict=False))
        value = field.from_db_value('"anything"', None, None)
        assert value == "lol"
示例#17
0
    def test_deconstruct(self):
        field = JSONField()
        name, path, args, kwargs = field.deconstruct()

        new = JSONField(*args, **kwargs)

        assert path == "django_mysql.models.JSONField"
        assert new.default == field.default
示例#18
0
class RegionResultModel(models.Model):
    image = models.ForeignKey(ImageModel,
                              related_name='region_result',
                              on_delete=models.CASCADE)
    region_num = models.IntegerField(null=True, unique=False)
    region_type = models.TextField(null=True, unique=False)
    severity_results = JSONField(null=True)
    patching_results = JSONField(null=True)
    pothole_results = JSONField(null=True)
示例#19
0
class ConceptMap(models.Model):
    id = models.AutoField(primary_key=True)
    user = models.ForeignKey(User)
    group = models.ForeignKey(reader_models.Group, default=1)
    session = models.CharField(max_length=100, default="test")
    section = models.CharField(max_length=100)
    structure = JSONField(blank=False)
    datetime = models.DateTimeField(default=timezone.now)
    context = JSONField(blank=True) # data about the context where the concept map was created
示例#20
0
class EventAnalysisShow(models.Model):
    e_id = models.CharField(max_length=50, primary_key=True)
    geo = JSONField()
    funs_num = JSONField()
    friends_num = JSONField()
    create_time = JSONField()
    age = JSONField()

    class Meta():
        db_table = 'EventAnalysisShow'
示例#21
0
class ConceptMappingLog(models.Model):
    id = models.AutoField(primary_key=True)
    datetime = models.DateTimeField(default=timezone.now)
    session = models.CharField(max_length=100, default="test")
    user = models.ForeignKey(User)
    group = models.ForeignKey(reader_models.Group, default=1)
    section = models.CharField(max_length=100, default="test")
    action = JSONField(blank=True)# e.g. add, delete, rename
    context = JSONField(blank=True)  # data about the context where the action was performed
    zoom = models.DecimalField(max_digits=4,decimal_places=2,default=1.0)
示例#22
0
class Settings(models.Model):
    start_time = models.IntegerField(default=0, blank=True)
    date_range = models.CharField(max_length=15, default='*')
    # RECEIPT SETTINGS
    ip_address = models.CharField(max_length=100, default='192.168.0.0')
    header = JSONField()
    footer = JSONField()

    class Meta:
        db_table = "settings"
示例#23
0
 def test_custom_json_decoder(self):
     class CustomDecoder(json.JSONDecoder):
         def decode(self, *args, **kwargs):
             return 'lol'
     field = JSONField(decoder=CustomDecoder(strict=False))
     if django.VERSION >= (2, 0):
         value = field.from_db_value('"anything"', None, None)
     else:
         value = field.from_db_value('"anything"', None, None, None)
     assert value == 'lol'
示例#24
0
class UserKeyWord(models.Model):
    ukw_id = models.CharField(max_length=50, primary_key=True)
    uid = models.CharField(max_length=30)
    keywords = JSONField()
    hastags = JSONField()
    sensitive_words = JSONField()
    timestamp = models.BigIntegerField()
    store_date = models.DateField(blank=True, null=True)
    class Meta():
        db_table = 'UserKeyWord'
示例#25
0
class Flat(Model):
    """产品面板"""
    name = models.CharField("名称", max_length=255)
    slug = models.CharField(max_length=255, unique=True)
    score = models.IntegerField("评分", default=5)
    enable = models.SmallIntegerField("状态", default=True)
    qty = models.IntegerField("库存", default=0)
    meta_title = models.CharField(max_length=255, null=True, blank=True)
    meta_keywords = models.CharField(max_length=255, null=True, blank=True)
    meta_description = models.TextField(null=True, blank=True)
    price = models.DecimalField("价格", max_digits=12, decimal_places=2)
    special_from = models.DateTimeField("特价开始时间", null=True, blank=True)
    special_to = models.DateTimeField("特价结束时间", null=True, blank=True)
    special_price = models.DecimalField("优惠价",
                                        max_digits=12,
                                        decimal_places=2,
                                        default=0)
    final_price = models.DecimalField("最终价格",
                                      max_digits=12,
                                      decimal_places=2,
                                      null=True,
                                      editable=False)
    image = models.TextField("产品图片", null=True, blank=True)
    description = models.TextField(null=True, blank=True)
    short_description = models.CharField("简短描述",
                                         max_length=255,
                                         null=True,
                                         blank=True)
    favorites_num = models.IntegerField("收藏数", default=0)
    # sku ids
    relation_sku = JSONField("相关产品", null=True, blank=True)
    buy_also_buy_sku = JSONField("买了还买", null=True, blank=True)
    see_also_see_sku = JSONField("看了还看", null=True, blank=True)
    reviews_rate_star_average = models.IntegerField("评星平均值",
                                                    default=5,
                                                    editable=False)
    reviews_num = models.IntegerField("评论数", default=0, editable=False)
    # [{star1:4.5, user1:user, comment:content},]
    # reviews_rate_star_info = JSONField("评星详细", null=True, blank=True)
    created_at = models.DateTimeField("创建时间", auto_now_add=True)
    updated_at = models.DateTimeField("更新时间", auto_now=True, null=True)

    created_user = models.ForeignKey(User,
                                     verbose_name='创建者',
                                     null=True,
                                     on_delete=models.SET_NULL)

    class Meta:
        verbose_name = '产品面板'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
示例#26
0
class Assets(models.Model):
    category = models.ForeignKey(Category, verbose_name=u'分类')
    title = models.CharField(max_length=32, verbose_name=u'资产名称')
    # 债务类型(公司|个人)
    debt_type = models.CharField(max_length=16,
                                 verbose_name=u'债务类型',
                                 choices=DEBTS_TYPE)
    # 说明
    instruction = JSONField(verbose_name=u'资产说明')
    # 配套信息
    parms = JSONField(verbose_name=u'配套信息')

    bond_institution = models.CharField(max_length=32, verbose_name=u'债权机构')
    obligor = models.CharField(max_length=8, verbose_name=u'债务人')
    guarantee = models.CharField(max_length=8, verbose_name=u'保证人')
    mortgagor = models.CharField(max_length=8, verbose_name=u'抵押人')
    # 资产亮点
    spot = JSONField(verbose_name=u'资产亮点')
    # 受理公示事项
    contacts = models.CharField(max_length=8, verbose_name=u'联系人')
    c_phone = models.CharField(max_length=16, verbose_name=u'联系人电话')
    fax = models.CharField(max_length=16, verbose_name=u'传真')
    p_address = models.CharField(max_length=64, verbose_name=u'通讯地址')
    # 交易对象及声明
    transaction = models.TextField(verbose_name=u'交易对象')
    statement = models.TextField(verbose_name=u'声明')

    pub_time = models.DateTimeField(auto_now_add=True, verbose_name=u'发布时间')

    class Meta:
        verbose_name = verbose_name_plural = u'资产信息'

    def __unicode__(self):
        return self.title

    @property
    def json_data(self):
        dit_data = model_to_dict(self)
        dit_data['category'] = self.cate_name
        dit_data['imgs'] = self.get_imgs()
        dit_data['spot'] = dit_data['spot']
        dit_data['parms'] = (dit_data['parms'])
        dit_data['instruction'] = dit_data['instruction']
        # print dit_data['instruction']
        return dit_data

    @property
    def cate_name(self):
        return self.category.category_name

    def get_imgs(self, size='large'):
        imgs = self.assetsimg_set.all()
        return [getattr(img, size).url for img in imgs]
示例#27
0
class Acl(BaseModel):
    scope = models.CharField("类型(表/视图/操作..)", max_length=50, db_index=True)
    name = models.CharField("名称", max_length=50, db_index=True)
    # read = JSONField(default=get_acl('read', level='sys'))
    # write = JSONField(default=get_acl('write', level='sys'))
    # update = JSONField(default=get_acl('update', level='sys'))
    # delete = JSONField(default=get_acl('delete', level='sys'))

    read = JSONField(default=read_acl)
    write = JSONField(default=write_acl)
    update = JSONField(default=update_acl)
    delete = JSONField(default=delte_acl)
示例#28
0
class Assets(models.Model):
    category = models.ForeignKey(Category, verbose_name=u'分类')
    title = models.CharField(max_length=32, verbose_name=u'资产名称')
    # 债务类型(公司|个人)
    debt_type = models.CharField(max_length=16, verbose_name=u'债务类型', choices=DEBTS_TYPE)
    # 说明
    instruction = JSONField(verbose_name=u'资产说明')
    # 配套信息
    parms = JSONField(verbose_name=u'配套信息', blank=True)
    # 机构
    bond_institution = models.CharField(max_length=32, verbose_name=u'债权机构')
    obligor = models.CharField(max_length=8, verbose_name=u'债务人')
    guarantee = models.CharField(max_length=8, verbose_name=u'保证人')
    mortgagor = models.CharField(max_length=8, verbose_name=u'抵押人')
    # 资产亮点
    spot = JSONField(verbose_name=u'资产亮点')
    # 受理公示事项
    contacts = models.CharField(max_length=8, verbose_name=u'联系人')
    c_phone = models.CharField(max_length=16, verbose_name=u'联系人电话')
    fax = models.CharField(max_length=16, verbose_name=u'传真')
    p_address = models.CharField(max_length=64, verbose_name=u'通讯地址')
    # 交易对象及声明
    transaction = models.TextField(verbose_name=u'交易对象')
    statement = models.TextField(verbose_name=u'声明')
    # 资产创建者
    author = models.ForeignKey(User, verbose_name=u'创建人')
    # 资产所属区域
    region = models.ForeignKey(UserGroup, verbose_name=u'资产所属区域')
    # 创建时间
    pub_time = models.DateTimeField(auto_now_add=True, verbose_name=u'发布时间')

    class Meta:
        verbose_name = verbose_name_plural = u'资产信息'

    def __unicode__(self):
        return self.title

    @property
    def assets_imgs(self):
        imgs = self.assetsimg_set.all()
        res_imgs = {'middle': [], 'small': []}
        # res_imgs = dict.fromkeys(['middle', 'small'], [])
        for img in imgs:
            tmp_imgs = {'id': img.id, 
                        'src': img.assets_img.url,
                        'show': True}
            res_imgs[img.img_type].append(tmp_imgs)
        if not len(res_imgs['small']):
            noImg = {'id': None,
                     'src': None,
                     'show': False}
            res_imgs['small'].append(noImg)
        return res_imgs
示例#29
0
class Category(models.Model):
    category_name = models.CharField(max_length=16, unique=True,
                                     verbose_name=u'资产类型')
    instruction = JSONField(verbose_name=u'资产说明参数')
    parms = JSONField(verbose_name=u'资产配套信息参数')
    spot = JSONField(verbose_name=u'资产亮点参数')
    
    class Meta:
        verbose_name = verbose_name_plural = u'资产分类'

    def __unicode__(self):
        return self.category_name
示例#30
0
class Event_Hashtag_Senwords(models.Model):
    ehs_id = models.CharField(max_length=100, primary_key=True)
    e_id = models.CharField(max_length=100, blank=True, null=True)
    hashtag = JSONField()
    global_senword = JSONField()
    event_senword = JSONField()
    timestamp = models.BigIntegerField(blank=True, null=True)
    into_date = models.DateField(blank=True, null=True)
    show_status = models.IntegerField(default=0)

    class Meta():
        db_table = 'Event_Hashtag_Senwords'
 def test_model_field_formfield(self):
     model_field = JSONField()
     form_field = model_field.formfield()
     assert isinstance(form_field, forms.JSONField)