from django.db import models from django.contrib.auth.validators import UnicodeUsernameValidator from django.utils.translation import gettext_lazy as _ from django.conf import settings class OrganizationApply(models.Model): AUDIT_TYPE_EMAIL = 0 AUDIT_TYPE_CERT = 1 AUDIT_TYPE_CHOICES = ( (AUDIT_TYPE_EMAIL, _('email')), (AUDIT_TYPE_CERT, _('incumbency cert')) ) AUDIT_STATUS_PEDNING = 0 AUDIT_STATUS_PASS = 1 AUDIT_STATUS_DENY = 2 AUDIT_STATUS_CHOICES = ( (AUDIT_STATUS_PEDNING, _('pending')), (AUDIT_STATUS_PASS, _('pass')), (AUDIT_STATUS_DENY, _('deny')) ) name = models.CharField( max_length=150, unique=False, validators=(UnicodeUsernameValidator(),), help_text='Required. 150 characters or fewer.' 'Letters, digits and @/./+/-/_ only.', error_messages={ 'unique': _('An organization with that name already exists.'), }, ) company_name = models.CharField(max_length=150, blank=True, null=True) industry_type_code = models.CharField(max_length=64, blank=True, null=True) industry_type_text = models.CharField(max_length=64, blank=True, null=True) member_range_code = models.CharField(max_length=64, blank=True, null=True) member_range_text = models.CharField(max_length=64, blank=True, null=True) job_title_code = models.CharField(max_length=64, blank=True, null=True) job_title_text = models.CharField(max_length=64, blank=True, null=True) company_base_code = models.CharField(max_length=64, blank=True, null=True) company_base_text = models.CharField(max_length=64, blank=True, null=True) incumbency_cert = models.ForeignKey( 'pingcap_sso.Upload', blank=True, null=True, on_delete=models.DO_NOTHING ) audit_type = models.SmallIntegerField( default=AUDIT_TYPE_EMAIL, choices=AUDIT_TYPE_CHOICES) audit_status = models.SmallIntegerField( default=AUDIT_STATUS_PEDNING, choices=AUDIT_STATUS_CHOICES) audit_reason = models.TextField() contact_phone = models.CharField( max_length=32, null=True, blank=True, help_text='Phone number is required.', error_messages={ 'unique': 'A user with that phone number already exists' } ) email = models.EmailField(null=True, blank=True) email_verified = models.BooleanField(default=False) created_by_user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING) audit_staff = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING, blank=True, null=True, related_name="organization_audits", ) organization = models.ForeignKey( 'pingcap_sso.Organization', on_delete=models.DO_NOTHING, blank=True, null=True) display = models.BooleanField(default=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Meta: db_table = 'pingcap_organization_apply'