2019-08-02 12:57:53 +00:00
|
|
|
# -*- mode: python; coding: utf-8 -*-
|
|
|
|
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2017-07-03 23:47:22 +00:00
|
|
|
from django.core.validators import MinValueValidator
|
2019-08-02 12:57:53 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
2021-10-26 09:37:32 +00:00
|
|
|
from polymorphic.models import PolymorphicModel
|
2019-08-02 12:57:53 +00:00
|
|
|
|
2019-08-11 07:22:22 +00:00
|
|
|
from .fields import ISBNField
|
|
|
|
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2021-10-23 16:31:03 +00:00
|
|
|
class Author(models.Model):
|
2019-08-16 12:01:13 +00:00
|
|
|
name = models.CharField(
|
|
|
|
max_length=255,
|
|
|
|
unique=True,
|
|
|
|
verbose_name=_('name'),
|
|
|
|
)
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2020-02-10 16:27:30 +00:00
|
|
|
note = models.IntegerField(
|
|
|
|
default=0,
|
|
|
|
verbose_name=_("note"),
|
|
|
|
)
|
|
|
|
|
2017-06-30 01:25:07 +00:00
|
|
|
def __str__(self):
|
2019-08-16 12:01:13 +00:00
|
|
|
return self.name
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2019-08-02 12:57:53 +00:00
|
|
|
class Meta:
|
|
|
|
verbose_name = _("author")
|
|
|
|
verbose_name_plural = _("authors")
|
2019-08-16 12:01:13 +00:00
|
|
|
ordering = ['name']
|
2019-08-02 12:57:53 +00:00
|
|
|
|
|
|
|
|
2021-10-26 09:37:32 +00:00
|
|
|
class Borrowable(PolymorphicModel):
|
2021-11-02 11:32:31 +00:00
|
|
|
isbn = ISBNField(
|
|
|
|
_('ISBN'),
|
|
|
|
help_text=_('You may be able to scan it from a bar code.'),
|
|
|
|
unique=True,
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
2021-10-26 09:37:32 +00:00
|
|
|
title = models.CharField(
|
|
|
|
max_length=255,
|
|
|
|
verbose_name=_("title"),
|
|
|
|
)
|
|
|
|
|
|
|
|
present = models.BooleanField(
|
|
|
|
verbose_name=_("present"),
|
|
|
|
help_text=_("Tell that the medium is present in the Mediatek."),
|
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
def __str__(self):
|
2021-10-26 13:07:37 +00:00
|
|
|
obj = self
|
|
|
|
if obj.__class__ == Borrowable:
|
|
|
|
# Get true object instance, useful for autocompletion
|
|
|
|
obj = Borrowable.objects.get(pk=obj.pk)
|
|
|
|
|
|
|
|
title = obj.title
|
|
|
|
if hasattr(obj, 'subtitle'):
|
|
|
|
subtitle = obj.subtitle
|
|
|
|
if subtitle:
|
|
|
|
title = f"{title} : {subtitle}"
|
|
|
|
return title
|
2021-10-26 09:37:32 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _('borrowable')
|
|
|
|
verbose_name_plural = _('borrowables')
|
|
|
|
|
|
|
|
|
|
|
|
class Medium(Borrowable):
|
|
|
|
external_url = models.URLField(
|
|
|
|
verbose_name=_('external URL'),
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
side_identifier = models.CharField(
|
|
|
|
verbose_name=_('side identifier'),
|
|
|
|
max_length=255,
|
|
|
|
)
|
|
|
|
|
|
|
|
authors = models.ManyToManyField(
|
|
|
|
'Author',
|
|
|
|
verbose_name=_('authors'),
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("medium")
|
|
|
|
verbose_name_plural = _("media")
|
|
|
|
|
|
|
|
|
|
|
|
class Book(Medium):
|
|
|
|
subtitle = models.CharField(
|
|
|
|
verbose_name=_('subtitle'),
|
|
|
|
max_length=255,
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
number_of_pages = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('number of pages'),
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
publish_date = models.DateField(
|
|
|
|
verbose_name=_('publish date'),
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("book")
|
|
|
|
verbose_name_plural = _("books")
|
|
|
|
|
|
|
|
|
|
|
|
class OldComic(models.Model):
|
2019-08-11 07:22:22 +00:00
|
|
|
isbn = ISBNField(
|
|
|
|
_('ISBN'),
|
|
|
|
help_text=_('You may be able to scan it from a bar code.'),
|
2020-02-10 16:41:05 +00:00
|
|
|
unique=True,
|
2019-08-11 07:22:22 +00:00
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
2020-05-21 14:56:41 +00:00
|
|
|
|
2019-08-11 07:22:22 +00:00
|
|
|
title = models.CharField(
|
|
|
|
verbose_name=_('title'),
|
|
|
|
max_length=255,
|
|
|
|
)
|
2020-05-21 14:56:41 +00:00
|
|
|
|
2019-08-11 07:22:22 +00:00
|
|
|
subtitle = models.CharField(
|
|
|
|
verbose_name=_('subtitle'),
|
|
|
|
max_length=255,
|
|
|
|
blank=True,
|
|
|
|
)
|
2020-05-21 14:56:41 +00:00
|
|
|
|
2019-08-11 07:22:22 +00:00
|
|
|
external_url = models.URLField(
|
|
|
|
verbose_name=_('external URL'),
|
|
|
|
blank=True,
|
|
|
|
)
|
2020-05-21 14:56:41 +00:00
|
|
|
|
2019-08-11 08:49:04 +00:00
|
|
|
side_identifier = models.CharField(
|
|
|
|
verbose_name=_('side identifier'),
|
2019-08-11 07:22:22 +00:00
|
|
|
max_length=255,
|
|
|
|
)
|
2020-05-21 14:56:41 +00:00
|
|
|
|
2019-08-11 07:22:22 +00:00
|
|
|
authors = models.ManyToManyField(
|
2021-10-23 16:31:03 +00:00
|
|
|
'Author',
|
2019-08-11 07:22:22 +00:00
|
|
|
verbose_name=_('authors'),
|
|
|
|
)
|
2020-05-21 14:56:41 +00:00
|
|
|
|
2019-08-11 07:22:22 +00:00
|
|
|
number_of_pages = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('number of pages'),
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
2020-05-21 14:56:41 +00:00
|
|
|
|
2019-08-11 07:22:22 +00:00
|
|
|
publish_date = models.DateField(
|
|
|
|
verbose_name=_('publish date'),
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2020-09-25 12:20:17 +00:00
|
|
|
present = models.BooleanField(
|
|
|
|
verbose_name=_("present"),
|
|
|
|
help_text=_("Tell that the medium is present in the Mediatek."),
|
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
2017-06-30 01:25:07 +00:00
|
|
|
def __str__(self):
|
2019-08-15 09:37:10 +00:00
|
|
|
if self.subtitle:
|
|
|
|
return "{} : {}".format(self.title, self.subtitle)
|
|
|
|
else:
|
|
|
|
return self.title
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2019-08-02 12:57:53 +00:00
|
|
|
class Meta:
|
2021-10-23 16:31:03 +00:00
|
|
|
verbose_name = _("comic")
|
|
|
|
verbose_name_plural = _("comics")
|
2019-08-11 16:37:04 +00:00
|
|
|
ordering = ['title', 'subtitle']
|
2019-08-02 12:57:53 +00:00
|
|
|
|
|
|
|
|
2021-10-26 09:37:32 +00:00
|
|
|
class Comic(Book):
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("comic")
|
|
|
|
verbose_name_plural = _("comics")
|
|
|
|
ordering = ['title', 'subtitle']
|
|
|
|
|
|
|
|
|
|
|
|
class OldManga(models.Model):
|
2020-05-21 14:56:41 +00:00
|
|
|
isbn = ISBNField(
|
|
|
|
_('ISBN'),
|
|
|
|
help_text=_('You may be able to scan it from a bar code.'),
|
|
|
|
unique=True,
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
title = models.CharField(
|
|
|
|
verbose_name=_('title'),
|
|
|
|
max_length=255,
|
|
|
|
)
|
|
|
|
|
|
|
|
subtitle = models.CharField(
|
|
|
|
verbose_name=_('subtitle'),
|
|
|
|
max_length=255,
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
external_url = models.URLField(
|
|
|
|
verbose_name=_('external URL'),
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
side_identifier = models.CharField(
|
|
|
|
verbose_name=_('side identifier'),
|
|
|
|
max_length=255,
|
|
|
|
)
|
|
|
|
|
|
|
|
authors = models.ManyToManyField(
|
2021-10-23 16:31:03 +00:00
|
|
|
'Author',
|
2020-05-21 14:56:41 +00:00
|
|
|
verbose_name=_('authors'),
|
|
|
|
)
|
|
|
|
|
|
|
|
number_of_pages = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('number of pages'),
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
publish_date = models.DateField(
|
|
|
|
verbose_name=_('publish date'),
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
2020-09-25 12:20:17 +00:00
|
|
|
present = models.BooleanField(
|
|
|
|
verbose_name=_("present"),
|
|
|
|
help_text=_("Tell that the medium is present in the Mediatek."),
|
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
2020-05-22 19:08:44 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("manga")
|
|
|
|
verbose_name_plural = _("mangas")
|
|
|
|
ordering = ['title']
|
|
|
|
|
|
|
|
|
2021-10-26 09:37:32 +00:00
|
|
|
class Manga(Book):
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("manga")
|
|
|
|
verbose_name_plural = _("mangas")
|
|
|
|
ordering = ['title', 'subtitle']
|
|
|
|
|
|
|
|
|
|
|
|
class OldNovel(models.Model):
|
2020-05-22 19:08:44 +00:00
|
|
|
isbn = ISBNField(
|
|
|
|
_('ISBN'),
|
|
|
|
help_text=_('You may be able to scan it from a bar code.'),
|
|
|
|
unique=True,
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
title = models.CharField(
|
|
|
|
verbose_name=_('title'),
|
|
|
|
max_length=255,
|
|
|
|
)
|
|
|
|
|
|
|
|
subtitle = models.CharField(
|
|
|
|
verbose_name=_('subtitle'),
|
|
|
|
max_length=255,
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
external_url = models.URLField(
|
|
|
|
verbose_name=_('external URL'),
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
side_identifier = models.CharField(
|
|
|
|
verbose_name=_('side identifier'),
|
|
|
|
max_length=255,
|
|
|
|
)
|
|
|
|
|
|
|
|
authors = models.ManyToManyField(
|
2021-10-23 16:31:03 +00:00
|
|
|
'Author',
|
2020-05-22 19:08:44 +00:00
|
|
|
verbose_name=_('authors'),
|
|
|
|
)
|
|
|
|
|
|
|
|
number_of_pages = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('number of pages'),
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
publish_date = models.DateField(
|
|
|
|
verbose_name=_('publish date'),
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
2020-09-25 12:20:17 +00:00
|
|
|
present = models.BooleanField(
|
|
|
|
verbose_name=_("present"),
|
|
|
|
help_text=_("Tell that the medium is present in the Mediatek."),
|
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
2020-05-22 19:08:44 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
class Meta:
|
2021-10-23 16:31:03 +00:00
|
|
|
verbose_name = _("novel")
|
|
|
|
verbose_name_plural = _("novels")
|
2020-05-22 19:08:44 +00:00
|
|
|
ordering = ['title', 'subtitle']
|
|
|
|
|
2020-05-22 16:04:41 +00:00
|
|
|
|
2021-10-26 09:37:32 +00:00
|
|
|
class Novel(Book):
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("novel")
|
|
|
|
verbose_name_plural = _("novels")
|
|
|
|
ordering = ['title', 'subtitle']
|
|
|
|
|
|
|
|
|
|
|
|
class OldVinyl(models.Model):
|
2020-05-22 16:04:41 +00:00
|
|
|
title = models.CharField(
|
|
|
|
verbose_name=_('title'),
|
|
|
|
max_length=255,
|
|
|
|
)
|
|
|
|
|
|
|
|
side_identifier = models.CharField(
|
|
|
|
verbose_name=_('side identifier'),
|
|
|
|
max_length=255,
|
|
|
|
)
|
|
|
|
|
2020-05-23 12:23:39 +00:00
|
|
|
rpm = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('rounds per minute'),
|
|
|
|
choices=[
|
|
|
|
(33, _('33 RPM')),
|
|
|
|
(45, _('45 RPM')),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2020-05-22 16:04:41 +00:00
|
|
|
authors = models.ManyToManyField(
|
2021-10-23 16:31:03 +00:00
|
|
|
'Author',
|
2020-05-22 16:04:41 +00:00
|
|
|
verbose_name=_('authors'),
|
|
|
|
)
|
|
|
|
|
2020-09-25 12:20:17 +00:00
|
|
|
present = models.BooleanField(
|
|
|
|
verbose_name=_("present"),
|
|
|
|
help_text=_("Tell that the medium is present in the Mediatek."),
|
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
2020-05-21 14:56:41 +00:00
|
|
|
def __str__(self):
|
2020-05-22 16:04:41 +00:00
|
|
|
return self.title
|
2020-05-21 14:56:41 +00:00
|
|
|
|
|
|
|
class Meta:
|
2021-10-23 16:31:03 +00:00
|
|
|
verbose_name = _("vinyl")
|
|
|
|
verbose_name_plural = _("vinyls")
|
2020-05-22 16:04:41 +00:00
|
|
|
ordering = ['title']
|
|
|
|
|
|
|
|
|
2021-10-26 09:37:32 +00:00
|
|
|
class Vinyl(Medium):
|
|
|
|
rpm = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('rounds per minute'),
|
|
|
|
choices=[
|
|
|
|
(33, _('33 RPM')),
|
|
|
|
(45, _('45 RPM')),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("vinyl")
|
|
|
|
verbose_name_plural = _("vinyls")
|
|
|
|
ordering = ['title']
|
|
|
|
|
|
|
|
|
|
|
|
class OldCD(models.Model):
|
2020-05-22 16:04:41 +00:00
|
|
|
title = models.CharField(
|
|
|
|
verbose_name=_('title'),
|
|
|
|
max_length=255,
|
|
|
|
)
|
|
|
|
|
|
|
|
side_identifier = models.CharField(
|
|
|
|
verbose_name=_('side identifier'),
|
|
|
|
max_length=255,
|
|
|
|
)
|
|
|
|
|
|
|
|
authors = models.ManyToManyField(
|
2021-10-23 16:31:03 +00:00
|
|
|
'Author',
|
2020-05-22 16:04:41 +00:00
|
|
|
verbose_name=_('authors'),
|
|
|
|
)
|
|
|
|
|
2020-09-25 12:20:17 +00:00
|
|
|
present = models.BooleanField(
|
|
|
|
verbose_name=_("present"),
|
|
|
|
help_text=_("Tell that the medium is present in the Mediatek."),
|
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
2020-05-22 16:04:41 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("CD")
|
|
|
|
verbose_name_plural = _("CDs")
|
|
|
|
ordering = ['title']
|
2020-05-21 14:56:41 +00:00
|
|
|
|
|
|
|
|
2021-10-26 09:37:32 +00:00
|
|
|
class CD(Medium):
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("CD")
|
|
|
|
verbose_name_plural = _("CDs")
|
|
|
|
ordering = ['title']
|
|
|
|
|
|
|
|
|
|
|
|
class OldReview(models.Model):
|
2020-05-24 13:37:57 +00:00
|
|
|
title = models.CharField(
|
|
|
|
verbose_name=_('title'),
|
|
|
|
max_length=255,
|
|
|
|
)
|
|
|
|
|
|
|
|
number = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('number'),
|
|
|
|
)
|
|
|
|
|
|
|
|
year = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('year'),
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
month = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('month'),
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
day = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('day'),
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
double = models.BooleanField(
|
|
|
|
verbose_name=_('double'),
|
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
2020-09-25 12:20:17 +00:00
|
|
|
present = models.BooleanField(
|
|
|
|
verbose_name=_("present"),
|
|
|
|
help_text=_("Tell that the medium is present in the Mediatek."),
|
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
2020-05-24 13:37:57 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.title + " n°" + str(self.number)
|
|
|
|
|
|
|
|
class Meta:
|
2021-10-23 16:31:03 +00:00
|
|
|
verbose_name = _("review")
|
|
|
|
verbose_name_plural = _("reviews")
|
2020-05-24 13:37:57 +00:00
|
|
|
ordering = ['title', 'number']
|
|
|
|
|
|
|
|
|
2021-10-26 09:37:32 +00:00
|
|
|
class Review(Borrowable):
|
|
|
|
number = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('number'),
|
|
|
|
)
|
|
|
|
|
|
|
|
year = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('year'),
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
month = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('month'),
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
day = models.PositiveIntegerField(
|
|
|
|
verbose_name=_('day'),
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
double = models.BooleanField(
|
|
|
|
verbose_name=_('double'),
|
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.title + " n°" + str(self.number)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("review")
|
|
|
|
verbose_name_plural = _("reviews")
|
|
|
|
ordering = ['title', 'number']
|
|
|
|
|
|
|
|
|
2021-10-23 16:31:03 +00:00
|
|
|
class FutureMedium(models.Model):
|
2020-05-12 15:33:32 +00:00
|
|
|
isbn = ISBNField(
|
|
|
|
_('ISBN'),
|
|
|
|
help_text=_('You may be able to scan it from a bar code.'),
|
|
|
|
unique=True,
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
)
|
|
|
|
|
2020-05-22 19:37:02 +00:00
|
|
|
type = models.CharField(
|
|
|
|
_('type'),
|
|
|
|
choices=[
|
2021-10-23 16:31:03 +00:00
|
|
|
('bd', _('Comic')),
|
2020-05-22 19:37:02 +00:00
|
|
|
('manga', _('Manga')),
|
|
|
|
('roman', _('Roman')),
|
|
|
|
],
|
|
|
|
max_length=8,
|
|
|
|
)
|
|
|
|
|
2020-09-25 12:20:17 +00:00
|
|
|
present = models.BooleanField(
|
|
|
|
verbose_name=_("present"),
|
|
|
|
help_text=_("Tell that the medium is present in the Mediatek."),
|
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
2020-05-12 15:33:32 +00:00
|
|
|
class Meta:
|
|
|
|
verbose_name = _("future medium")
|
|
|
|
verbose_name_plural = _("future media")
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Future medium (ISBN: {isbn})".format(isbn=self.isbn, )
|
|
|
|
|
|
|
|
|
2017-06-30 01:25:07 +00:00
|
|
|
class Emprunt(models.Model):
|
2019-08-16 12:01:13 +00:00
|
|
|
media = models.ForeignKey(
|
2021-10-26 09:37:32 +00:00
|
|
|
'media.Borrowable',
|
2019-08-16 12:01:13 +00:00
|
|
|
on_delete=models.PROTECT,
|
|
|
|
)
|
|
|
|
user = models.ForeignKey(
|
|
|
|
'users.User',
|
|
|
|
on_delete=models.PROTECT,
|
|
|
|
verbose_name=_("borrower"),
|
|
|
|
)
|
|
|
|
date_emprunt = models.DateTimeField(
|
|
|
|
verbose_name=_('borrowed on'),
|
|
|
|
)
|
2019-08-08 14:33:05 +00:00
|
|
|
date_rendu = models.DateTimeField(
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
2019-08-16 12:01:13 +00:00
|
|
|
verbose_name=_('given back on'),
|
2019-08-08 14:33:05 +00:00
|
|
|
)
|
|
|
|
permanencier_emprunt = models.ForeignKey(
|
|
|
|
'users.User',
|
|
|
|
on_delete=models.PROTECT,
|
|
|
|
related_name='user_permanencier_emprunt',
|
2019-08-16 12:01:13 +00:00
|
|
|
verbose_name=_('borrowed with'),
|
|
|
|
help_text=_('The keyholder that registered this borrowed item.')
|
2019-08-08 14:33:05 +00:00
|
|
|
)
|
|
|
|
permanencier_rendu = models.ForeignKey(
|
|
|
|
'users.User',
|
|
|
|
on_delete=models.PROTECT,
|
|
|
|
related_name='user_permanencier_rendu',
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
2019-08-16 12:01:13 +00:00
|
|
|
verbose_name=_('given back to'),
|
|
|
|
help_text=_('The keyholder to whom this item was given back.')
|
2019-08-08 14:33:05 +00:00
|
|
|
)
|
2017-07-06 15:30:23 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return str(self.media) + str(self.user)
|
2019-08-02 12:57:53 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("borrowed item")
|
|
|
|
verbose_name_plural = _("borrowed items")
|
2019-08-11 16:37:04 +00:00
|
|
|
ordering = ['-date_emprunt']
|
2019-08-02 12:57:53 +00:00
|
|
|
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2021-10-26 09:37:32 +00:00
|
|
|
class OldGame(models.Model):
|
2021-10-23 16:39:51 +00:00
|
|
|
DURATIONS = (
|
2019-08-02 12:57:53 +00:00
|
|
|
('-1h', '-1h'),
|
|
|
|
('1-2h', '1-2h'),
|
|
|
|
('2-3h', '2-3h'),
|
|
|
|
('3-4h', '3-4h'),
|
|
|
|
('4h+', '4h+'),
|
|
|
|
)
|
2017-06-30 01:25:07 +00:00
|
|
|
|
2021-10-26 09:37:32 +00:00
|
|
|
title = models.CharField(
|
2019-08-16 12:01:13 +00:00
|
|
|
max_length=255,
|
|
|
|
verbose_name=_("name"),
|
|
|
|
)
|
2021-10-23 16:39:51 +00:00
|
|
|
owner = models.ForeignKey(
|
2019-08-16 12:01:13 +00:00
|
|
|
'users.User',
|
|
|
|
on_delete=models.PROTECT,
|
|
|
|
verbose_name=_("owner"),
|
|
|
|
)
|
2021-10-23 16:39:51 +00:00
|
|
|
duration = models.CharField(
|
|
|
|
choices=DURATIONS,
|
2019-08-16 12:01:13 +00:00
|
|
|
max_length=255,
|
|
|
|
verbose_name=_("duration"),
|
|
|
|
)
|
2021-10-23 16:39:51 +00:00
|
|
|
players_min = models.IntegerField(
|
2019-08-16 12:01:13 +00:00
|
|
|
validators=[MinValueValidator(1)],
|
|
|
|
verbose_name=_("minimum number of players"),
|
|
|
|
)
|
2021-10-23 16:39:51 +00:00
|
|
|
players_max = models.IntegerField(
|
2019-08-16 12:01:13 +00:00
|
|
|
validators=[MinValueValidator(1)],
|
|
|
|
verbose_name=_('maximum number of players'),
|
|
|
|
)
|
|
|
|
comment = models.CharField(
|
|
|
|
max_length=255,
|
|
|
|
blank=True,
|
|
|
|
verbose_name=_('comment'),
|
|
|
|
)
|
2017-07-03 15:48:56 +00:00
|
|
|
|
2017-07-06 15:30:23 +00:00
|
|
|
def __str__(self):
|
2021-10-26 09:37:32 +00:00
|
|
|
return str(self.title)
|
2019-08-02 12:57:53 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("game")
|
|
|
|
verbose_name_plural = _("games")
|
2021-10-26 09:37:32 +00:00
|
|
|
ordering = ['title']
|
|
|
|
|
|
|
|
|
|
|
|
class Game(Borrowable):
|
|
|
|
DURATIONS = (
|
|
|
|
('-1h', '-1h'),
|
|
|
|
('1-2h', '1-2h'),
|
|
|
|
('2-3h', '2-3h'),
|
|
|
|
('3-4h', '3-4h'),
|
|
|
|
('4h+', '4h+'),
|
|
|
|
)
|
|
|
|
owner = models.ForeignKey(
|
|
|
|
'users.User',
|
|
|
|
on_delete=models.PROTECT,
|
|
|
|
verbose_name=_("owner"),
|
|
|
|
)
|
|
|
|
duration = models.CharField(
|
|
|
|
choices=DURATIONS,
|
|
|
|
max_length=255,
|
|
|
|
verbose_name=_("duration"),
|
|
|
|
)
|
|
|
|
players_min = models.IntegerField(
|
|
|
|
validators=[MinValueValidator(1)],
|
|
|
|
verbose_name=_("minimum number of players"),
|
|
|
|
)
|
|
|
|
players_max = models.IntegerField(
|
|
|
|
validators=[MinValueValidator(1)],
|
|
|
|
verbose_name=_('maximum number of players'),
|
|
|
|
)
|
|
|
|
comment = models.CharField(
|
|
|
|
max_length=255,
|
|
|
|
blank=True,
|
|
|
|
verbose_name=_('comment'),
|
|
|
|
)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return str(self.title)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _("game")
|
|
|
|
verbose_name_plural = _("games")
|
|
|
|
ordering = ['title']
|