# Path: boxes/models.py
# class Box(models.Model):
# 
#     OPEN = 10
#     EXPIRED = 20
#     DONE = 30
#     CLOSED = 40
# 
#     STATUSES = (
#         (OPEN, _('Open')),
#         (EXPIRED, _('Expired')),
#         (DONE, _('Done')),
#         (CLOSED, _('Closed'))
#     )
# 
#     name = models.CharField(max_length=128, verbose_name=_('Name'))
#     description = models.TextField(null=True, blank=True,
#                                    verbose_name=_('Description'))
#     uuid = models.UUIDField(default=uuid.uuid4, editable=False,
#                             verbose_name=_('Unique ID'))
# 
#     owner = models.ForeignKey(settings.AUTH_USER_MODEL,
#                               on_delete=models.CASCADE,
#                               related_name='own_boxes',
#                               verbose_name=_('Owner'))
# 
#     recipients = models.ManyToManyField(settings.AUTH_USER_MODEL,
#                                         related_name='boxes',
#                                         through='Membership',
#                                         through_fields=('box', 'user'),
#                                         verbose_name=_('Recipients'))
#     created_at = models.DateTimeField(auto_now_add=True,
#                                       verbose_name=_('Created at'))
#     updated_at = models.DateTimeField(auto_now=True,
#                                       verbose_name=_('Updated at'))
#     expires_at = models.DateTimeField(null=True, blank=True,
#                                       verbose_name=_('Expires at'))
# 
#     status = models.IntegerField(choices=STATUSES, default=OPEN,
#                                  verbose_name=_('Status'))
#     max_messages = models.PositiveIntegerField(default=1, validators=[
#                                                MinValueValidator(1)],
#                                                verbose_name=_('Max. messages'))
# 
#     last_sent_at = models.DateTimeField(null=True,
#                                         verbose_name=_('Last sent at'))
# 
#     class Meta:
#         verbose_name = _('Box')
#         verbose_name_plural = _('Boxes')
# 
#     def __str__(self):
#         return self.name
# 
#     @staticmethod
#     def get_status(name):
#         return {
#             "Open": Box.OPEN,
#             "Expired": Box.EXPIRED,
#             "Done": Box.DONE,
#             "Closed": Box.CLOSED
#         }.get(name, Box.OPEN)


from django.forms import ModelForm, Form, CharField, Textarea, BooleanField
from .models import Box
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from sys import getsizeof


MAX_MESSAGE_SIZE = 10485760  # Bytes = 10 Mb


class CreateBoxForm(ModelForm):
    never_expires = BooleanField(required=False)

    field_order = [
        "name",
        "never_expires",
        "expires_at",
        "max_messages",
        "description"]

    class Meta:

# Path: boxes/models.py
# class Box(models.Model):
# 
#     OPEN = 10
#     EXPIRED = 20
#     DONE = 30
#     CLOSED = 40
# 
#     STATUSES = (
#         (OPEN, _('Open')),
#         (EXPIRED, _('Expired')),
#         (DONE, _('Done')),
#         (CLOSED, _('Closed'))
#     )
# 
#     name = models.CharField(max_length=128, verbose_name=_('Name'))
#     description = models.TextField(null=True, blank=True,
#                                    verbose_name=_('Description'))
#     uuid = models.UUIDField(default=uuid.uuid4, editable=False,
#                             verbose_name=_('Unique ID'))
# 
#     owner = models.ForeignKey(settings.AUTH_USER_MODEL,
#                               on_delete=models.CASCADE,
#                               related_name='own_boxes',
#                               verbose_name=_('Owner'))
# 
#     recipients = models.ManyToManyField(settings.AUTH_USER_MODEL,
#                                         related_name='boxes',
#                                         through='Membership',
#                                         through_fields=('box', 'user'),
#                                         verbose_name=_('Recipients'))
#     created_at = models.DateTimeField(auto_now_add=True,
#                                       verbose_name=_('Created at'))
#     updated_at = models.DateTimeField(auto_now=True,
#                                       verbose_name=_('Updated at'))
#     expires_at = models.DateTimeField(null=True, blank=True,
#                                       verbose_name=_('Expires at'))
# 
#     status = models.IntegerField(choices=STATUSES, default=OPEN,
#                                  verbose_name=_('Status'))
#     max_messages = models.PositiveIntegerField(default=1, validators=[
#                                                MinValueValidator(1)],
#                                                verbose_name=_('Max. messages'))
# 
#     last_sent_at = models.DateTimeField(null=True,
#                                         verbose_name=_('Last sent at'))
# 
#     class Meta:
#         verbose_name = _('Box')
#         verbose_name_plural = _('Boxes')
# 
#     def __str__(self):
#         return self.name
# 
#     @staticmethod
#     def get_status(name):
#         return {
#             "Open": Box.OPEN,
#             "Expired": Box.EXPIRED,
#             "Done": Box.DONE,
#             "Closed": Box.CLOSED
#         }.get(name, Box.OPEN)


# Path: boxes/forms.py
from django.forms import ModelForm, Form, CharField, Textarea, BooleanField
from .models import Box
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from sys import getsizeof



MAX_MESSAGE_SIZE = 10485760  # Bytes = 10 Mb


class CreateBoxForm(ModelForm):
    never_expires = BooleanField(required=False)

    field_order = [
        "name",
        "never_expires",
        "expires_at",
        "max_messages",
        "description"]

    class Meta:

        model = Box