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.
69 lines
2.1 KiB
69 lines
2.1 KiB
import os
|
|
from django.conf import settings
|
|
from django.contrib.auth import get_user_model
|
|
from django.core.validators import RegexValidator
|
|
from django.db import models
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
# Create your models here.
|
|
from core.models import AbstractStatusModel, STATUS_DELETED
|
|
|
|
# --------------------- REQUEST STATUS LIST --------------------
|
|
|
|
STATUS_NEW = 0
|
|
from core.models import AbstractStatusModel, STATUS_NEW, STATUS_CHOICES, STATUS_ACTIVE, STATUS_DELETED
|
|
|
|
# --------------------- REQUEST STATUS LIST --------------------
|
|
|
|
STATUS_IN_PROCESSING = 10
|
|
STATUS_PROCESSED = 20
|
|
STATUS_REJECTED = 40
|
|
|
|
REQUEST_STATUS_CHOICES = (
|
|
STATUS_CHOICES[0],
|
|
(STATUS_IN_PROCESSING, _('Processing')),
|
|
(STATUS_PROCESSED, _('Processed')),
|
|
(STATUS_REJECTED, _('Rejected')),
|
|
STATUS_CHOICES[-1]
|
|
)
|
|
|
|
REQUEST_DEFAULT_STATUS = STATUS_NEW
|
|
|
|
# ----------------- REQUEST FILE STATUS LIST ------------------
|
|
|
|
FILE_REQUEST_STATUS_CHOICES = (
|
|
(STATUS_ACTIVE, _('Active')),
|
|
(STATUS_DELETED, _('Deleted')),
|
|
)
|
|
|
|
FILE_REQUEST_DEFAULT_STATUS = STATUS_ACTIVE
|
|
|
|
|
|
class Request(AbstractStatusModel):
|
|
name = models.CharField(_('Name'), max_length=255)
|
|
email = models.EmailField(_('Email'))
|
|
subject = models.CharField(_('Subject'), max_length=500)
|
|
message = models.TextField(blank=True, null=True)
|
|
phone_regex = RegexValidator(regex=r'^((\+7)|8)?\d{10}$',
|
|
message="Phone number must be entered in the format: '+99999999999'. Up to 12 digits allowed.")
|
|
phone = models.CharField(validators=(phone_regex,), max_length=12, blank=True, null=True)
|
|
status = models.SmallIntegerField(_('Status'), default=REQUEST_DEFAULT_STATUS, choices=REQUEST_STATUS_CHOICES)
|
|
|
|
@property
|
|
def is_status_processed(self):
|
|
return self.status == STATUS_PROCESSED
|
|
|
|
@property
|
|
def is_status_rejected(self):
|
|
return self.status == STATUS_REJECTED
|
|
|
|
@property
|
|
def is_status_processing(self):
|
|
return self.status == STATUS_IN_PROCESSING
|
|
|
|
def __str__(self):
|
|
return self.subject
|
|
|
|
class Meta:
|
|
verbose_name = _('Request')
|
|
verbose_name_plural = _('Requests')
|
|
|