You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.4 KiB
76 lines
2.4 KiB
from django.db import models
|
|
from django.utils.translation import gettext_lazy as _
|
|
from django.conf import settings
|
|
|
|
|
|
class VerificationDocument(models.Model):
|
|
class DocumentType(models.TextChoices):
|
|
NATIONAL_ID = 'national_id', _('National ID / Passport')
|
|
INSTITUTION_LICENSE = 'institution_license', _('Institution Registration / License')
|
|
RECOMMENDATION_LETTER = 'recommendation_letter', _('Recommendation Letter')
|
|
STUDENT_CARD = 'student_card', _('Student / Member Card')
|
|
OTHER = 'other', _('Other Document')
|
|
|
|
class Status(models.TextChoices):
|
|
PENDING = 'pending', _('Pending Review')
|
|
VERIFIED = 'verified', _('Verified')
|
|
REJECTED = 'rejected', _('Rejected')
|
|
|
|
user = models.ForeignKey(
|
|
settings.AUTH_USER_MODEL,
|
|
on_delete=models.CASCADE,
|
|
related_name='verification_documents',
|
|
verbose_name=_('User')
|
|
)
|
|
document_type = models.CharField(
|
|
max_length=50,
|
|
choices=DocumentType.choices,
|
|
default=DocumentType.NATIONAL_ID,
|
|
verbose_name=_('Document Type')
|
|
)
|
|
title = models.CharField(
|
|
max_length=255,
|
|
blank=True,
|
|
null=True,
|
|
verbose_name=_('Document Title')
|
|
)
|
|
document_file = models.FileField(
|
|
upload_to='users/documents/%Y/%m/',
|
|
verbose_name=_('Document File')
|
|
)
|
|
status = models.CharField(
|
|
max_length=20,
|
|
choices=Status.choices,
|
|
default=Status.PENDING,
|
|
verbose_name=_('Verification Status')
|
|
)
|
|
admin_notes = models.TextField(
|
|
blank=True,
|
|
null=True,
|
|
verbose_name=_('Admin Notes / Feedback')
|
|
)
|
|
reviewed_by = models.ForeignKey(
|
|
settings.AUTH_USER_MODEL,
|
|
on_delete=models.SET_NULL,
|
|
null=True,
|
|
blank=True,
|
|
related_name='reviewed_verifications',
|
|
verbose_name=_('Reviewed By')
|
|
)
|
|
uploaded_at = models.DateTimeField(
|
|
auto_now_add=True,
|
|
verbose_name=_('Uploaded At')
|
|
)
|
|
reviewed_at = models.DateTimeField(
|
|
null=True,
|
|
blank=True,
|
|
verbose_name=_('Reviewed At')
|
|
)
|
|
|
|
class Meta:
|
|
ordering = ('-uploaded_at',)
|
|
verbose_name = _('Verification Document')
|
|
verbose_name_plural = _('Verification Documents')
|
|
|
|
def __str__(self):
|
|
return f"{self.user} - {self.get_document_type_display()} ({self.status})"
|