1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- from django.db import models
- from django.utils.translation import ugettext_lazy as _
- from django_models_ext import BaseModelMixin, upload_file_path, upload_path
- from jsonfield import JSONField
- from shortuuidfield import ShortUUIDField
- from TimeConvert import TimeConvert as tc
- from utils.qiniucdn import qiniu_file_url
- class LensmanContributionContractInfo(BaseModelMixin):
- CONTRACT_STATUS_TUPLE = (
- (1, u'合同创建'),
- (2, u'合同签署中'),
- (3, u'合同拒签'),
- (4, u'合同签署完成'),
- (5, u'合同流签(合同过期)'),
- (6, u'合同撤回'),
- (8, u'合同待填写'),
- (21, u'解除协议(已解除)'),
- (16, u'合同已失效'),
- )
- APPROVE_STATUS_TYPE = (
- (2, u'待签署'),
- (7, u'待签署'),
- (3, u'已签署'),
- (4, u'拒绝'),
- (5, u'过期没人处理'),
- (6, u'流程已撤回'),
- (8, u'合同待填写'),
- (9, u'流程已终止'),
- (10, u'填写完成'),
- (15, u'解除协议(已解除)'),
- (15, u'已转他人处理'),
- )
- contract_id = ShortUUIDField(_(u'contract_id'), max_length=32, blank=True, null=True, help_text=u'合同唯一标识', db_index=True, unique=True)
- user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
- lensman_id = models.CharField(_(u'lensman_id'), max_length=32, blank=True, null=True, help_text=u'摄影师唯一标识', db_index=True)
- activity_id = models.CharField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True)
- contribution_id = models.CharField(_(u'contribution_id'), max_length=32, blank=True, null=True, help_text=u'活动投稿唯一标识', db_index=True)
- contract_content_fields = JSONField(_(u'contract_content_fields'), blank=True, null=True, help_text=u'合同内容字段')
- contract_file = models.FileField(_(u'contract_file'), upload_to=upload_path, blank=True, null=True, help_text=u'图片')
-
- flow_id = models.CharField(_(u'flow_id'), max_length=128, blank=True, null=True, help_text=u'腾讯电子签流程ID')
-
- document_id = models.CharField(_(u'document_id'), max_length=128, blank=True, null=True, help_text=u'腾讯电子签文档ID')
- tencent_contract_status = models.IntegerField(_(u'tencent_contract_status'), choices=CONTRACT_STATUS_TUPLE, default=-1, help_text=u'腾讯电子签合同签署状态', db_index=True)
- tencent_approve_status = models.IntegerField(_(u'tencent_approve_status'), choices=APPROVE_STATUS_TYPE, default=-1, help_text=u'腾讯电子签签署人签署状态', db_index=True)
- class Meta:
- verbose_name = _(u'摄影师投稿合同信息')
- verbose_name_plural = _(u'摄影师投稿合同信息')
- def __unicode__(self):
- return '%d' % self.pk
- @property
- def contract_file_url(self):
- return qiniu_file_url(self.contract_file.name, bucket='tamron')
- @property
- def contract_status(self):
- if self.tencent_approve_status == 3 and self.tencent_contract_status == 4:
- return 1
- else:
- return 0
- @property
- def data(self):
- return {
- 'contract_id': self.contract_id,
- 'lensman_id': self.lensman_id,
- 'activity_id': self.activity_id,
- 'contribution_id': self.contribution_id,
- 'contract_content_fields': self.contract_content_fields,
- 'contract_file_url': self.contract_file_url,
- 'contract_status': self.contract_status,
- 'created_at': tc.local_string(utc_dt=self.created_at, format='%Y-%m-%d %H:%M:%S'),
- 'updated_at': tc.local_string(utc_dt=self.updated_at, format='%Y-%m-%d %H:%M:%S')
- }
- @property
- def admindata(self):
- return self.data
- @property
- def mpdata(self):
- return self.data
|