WIP référence circulaire résolue pour les models. Problème d’appel aux méthodes de classes.
This commit is contained in:
parent
eb81c2438a
commit
59f3341b0d
@ -2,12 +2,12 @@ from .utils import *
|
||||
from .configuration import *
|
||||
from .user import *
|
||||
from .static_content import *
|
||||
|
||||
from .category import *
|
||||
from .tag import *
|
||||
from .event import *
|
||||
from .place import *
|
||||
from .organisation import *
|
||||
from .event import *
|
||||
from .message import *
|
||||
from .import_recurrent import *
|
||||
from .import_batch import *
|
||||
from .category import *
|
||||
from .imports import *
|
||||
from .special_period import *
|
||||
|
@ -6,7 +6,7 @@ from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from ..models import Place, remove_accents
|
||||
from ..models.utils import remove_accents
|
||||
|
||||
|
||||
class Category(models.Model):
|
||||
@ -166,7 +166,7 @@ class CategorisationRule(models.Model):
|
||||
)
|
||||
|
||||
place = models.ForeignKey(
|
||||
Place,
|
||||
"Place",
|
||||
verbose_name=_("Place"),
|
||||
help_text=_("Location from place"),
|
||||
null=True,
|
||||
|
@ -33,20 +33,25 @@ from django_resized import ResizedImageField
|
||||
from icalendar import Calendar as icalCal
|
||||
from icalendar import Event as icalEvent
|
||||
|
||||
from ..models import (
|
||||
Category,
|
||||
Place,
|
||||
Organisation,
|
||||
Message,
|
||||
RecurrentImport,
|
||||
remove_accents,
|
||||
CategorisationRule,
|
||||
SiteConfiguration,
|
||||
Tag,
|
||||
)
|
||||
# from ..models.place import Place
|
||||
# from ..models.category import CategorisationRule, Category
|
||||
# from ..models.message import Message
|
||||
# from ..models.imports import RecurrentImport
|
||||
from ..models.utils import remove_accents
|
||||
from ..models.configuration import SiteConfiguration
|
||||
|
||||
# from ..models.tag import Tag
|
||||
from ..calendar import CalendarDay
|
||||
from ..import_tasks.extractor import Extractor
|
||||
|
||||
Category = None
|
||||
CategorisationRule = None
|
||||
Place = None
|
||||
Tag = None
|
||||
Message = None
|
||||
RecurrentImport = None
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -272,7 +277,7 @@ class Event(models.Model):
|
||||
)
|
||||
|
||||
category = models.ForeignKey(
|
||||
Category,
|
||||
"Category",
|
||||
verbose_name=_("Category"),
|
||||
null=True,
|
||||
default=None,
|
||||
@ -301,7 +306,7 @@ class Event(models.Model):
|
||||
)
|
||||
|
||||
exact_location = models.ForeignKey(
|
||||
Place,
|
||||
"Place",
|
||||
verbose_name=_("Location"),
|
||||
null=True,
|
||||
on_delete=models.SET_NULL,
|
||||
@ -335,7 +340,7 @@ class Event(models.Model):
|
||||
)
|
||||
|
||||
organisers = models.ManyToManyField(
|
||||
Organisation,
|
||||
"Organisation",
|
||||
related_name="organised_events",
|
||||
verbose_name=_("Organisers"),
|
||||
help_text=_(
|
||||
|
@ -1,69 +0,0 @@
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from ..models import RecurrentImport
|
||||
|
||||
|
||||
class BatchImportation(models.Model):
|
||||
class STATUS(models.TextChoices):
|
||||
RUNNING = "running", _("Running")
|
||||
CANCELED = "canceled", _("Canceled")
|
||||
SUCCESS = "success", _("Success")
|
||||
FAILED = "failed", _("Failed")
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Batch importation")
|
||||
verbose_name_plural = _("Batch importations")
|
||||
permissions = [("run_batchimportation", "Can run a batch importation")]
|
||||
indexes = [
|
||||
models.Index(fields=["created_date"]),
|
||||
models.Index(fields=["status"]),
|
||||
models.Index(fields=["created_date", "recurrentImport"]),
|
||||
]
|
||||
|
||||
created_date = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
recurrentImport = models.ForeignKey(
|
||||
RecurrentImport,
|
||||
verbose_name=_("Recurrent import"),
|
||||
help_text=_("Reference to the recurrent import processing"),
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=models.SET_NULL,
|
||||
editable=False,
|
||||
)
|
||||
|
||||
url_source = models.URLField(
|
||||
verbose_name=_("URL (if not recurrent import)"),
|
||||
help_text=_("Source URL if no RecurrentImport is associated."),
|
||||
max_length=1024,
|
||||
blank=True,
|
||||
null=True,
|
||||
editable=False,
|
||||
)
|
||||
|
||||
status = models.CharField(
|
||||
_("Status"),
|
||||
max_length=20,
|
||||
choices=STATUS.choices,
|
||||
default=STATUS.RUNNING,
|
||||
)
|
||||
|
||||
error_message = models.CharField(
|
||||
verbose_name=_("Error message"), max_length=512, blank=True, null=True
|
||||
)
|
||||
|
||||
nb_initial = models.PositiveIntegerField(
|
||||
verbose_name=_("Number of collected events"), default=0
|
||||
)
|
||||
nb_imported = models.PositiveIntegerField(
|
||||
verbose_name=_("Number of imported events"), default=0
|
||||
)
|
||||
nb_updated = models.PositiveIntegerField(
|
||||
verbose_name=_("Number of updated events"), default=0
|
||||
)
|
||||
nb_removed = models.PositiveIntegerField(
|
||||
verbose_name=_("Number of removed events"), default=0
|
||||
)
|
||||
|
||||
celery_id = models.CharField(max_length=128, default="")
|
@ -3,7 +3,11 @@ from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django_better_admin_arrayfield.models.fields import ArrayField
|
||||
|
||||
from ..models import Organisation, Category, BatchImportation, Event
|
||||
|
||||
# from ..models.event import Event
|
||||
Event = None
|
||||
# from ..models.organisation import Organisation
|
||||
Organisation = None
|
||||
|
||||
|
||||
class RecurrentImport(models.Model):
|
||||
@ -117,7 +121,7 @@ class RecurrentImport(models.Model):
|
||||
)
|
||||
|
||||
defaultOrganiser = models.ForeignKey(
|
||||
Organisation,
|
||||
"Organisation",
|
||||
verbose_name=_("Organiser"),
|
||||
help_text=_("Organiser of each imported event"),
|
||||
default=None,
|
||||
@ -127,7 +131,7 @@ class RecurrentImport(models.Model):
|
||||
)
|
||||
|
||||
defaultCategory = models.ForeignKey(
|
||||
Category,
|
||||
"Category",
|
||||
verbose_name=_("Category"),
|
||||
help_text=_("Category of each imported event"),
|
||||
default=None,
|
||||
@ -163,3 +167,68 @@ class RecurrentImport(models.Model):
|
||||
return events[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class BatchImportation(models.Model):
|
||||
class STATUS(models.TextChoices):
|
||||
RUNNING = "running", _("Running")
|
||||
CANCELED = "canceled", _("Canceled")
|
||||
SUCCESS = "success", _("Success")
|
||||
FAILED = "failed", _("Failed")
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Batch importation")
|
||||
verbose_name_plural = _("Batch importations")
|
||||
permissions = [("run_batchimportation", "Can run a batch importation")]
|
||||
indexes = [
|
||||
models.Index(fields=["created_date"]),
|
||||
models.Index(fields=["status"]),
|
||||
models.Index(fields=["created_date", "recurrentImport"]),
|
||||
]
|
||||
|
||||
created_date = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
recurrentImport = models.ForeignKey(
|
||||
RecurrentImport,
|
||||
verbose_name=_("Recurrent import"),
|
||||
help_text=_("Reference to the recurrent import processing"),
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=models.SET_NULL,
|
||||
editable=False,
|
||||
)
|
||||
|
||||
url_source = models.URLField(
|
||||
verbose_name=_("URL (if not recurrent import)"),
|
||||
help_text=_("Source URL if no RecurrentImport is associated."),
|
||||
max_length=1024,
|
||||
blank=True,
|
||||
null=True,
|
||||
editable=False,
|
||||
)
|
||||
|
||||
status = models.CharField(
|
||||
_("Status"),
|
||||
max_length=20,
|
||||
choices=STATUS.choices,
|
||||
default=STATUS.RUNNING,
|
||||
)
|
||||
|
||||
error_message = models.CharField(
|
||||
verbose_name=_("Error message"), max_length=512, blank=True, null=True
|
||||
)
|
||||
|
||||
nb_initial = models.PositiveIntegerField(
|
||||
verbose_name=_("Number of collected events"), default=0
|
||||
)
|
||||
nb_imported = models.PositiveIntegerField(
|
||||
verbose_name=_("Number of imported events"), default=0
|
||||
)
|
||||
nb_updated = models.PositiveIntegerField(
|
||||
verbose_name=_("Number of updated events"), default=0
|
||||
)
|
||||
nb_removed = models.PositiveIntegerField(
|
||||
verbose_name=_("Number of removed events"), default=0
|
||||
)
|
||||
|
||||
celery_id = models.CharField(max_length=128, default="")
|
@ -5,7 +5,8 @@ from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django_ckeditor_5.fields import CKEditor5Field
|
||||
|
||||
from ..models import Event
|
||||
# from ..models.event import Event
|
||||
Event = None
|
||||
|
||||
|
||||
class Message(models.Model):
|
||||
@ -38,7 +39,7 @@ class Message(models.Model):
|
||||
)
|
||||
|
||||
related_event = models.ForeignKey(
|
||||
Event,
|
||||
"Event",
|
||||
verbose_name=_("Related event"),
|
||||
help_text=_("The message is associated with this event."),
|
||||
null=True,
|
||||
|
@ -3,8 +3,6 @@ from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django_ckeditor_5.fields import CKEditor5Field
|
||||
|
||||
from ..models import Place
|
||||
|
||||
|
||||
class Organisation(models.Model):
|
||||
name = models.CharField(
|
||||
@ -31,7 +29,7 @@ class Organisation(models.Model):
|
||||
)
|
||||
|
||||
principal_place = models.ForeignKey(
|
||||
Place,
|
||||
"Place",
|
||||
verbose_name=_("Principal place"),
|
||||
help_text=_(
|
||||
"Place mainly associated with this organizer. Mainly used if there is a similarity in the name, to avoid redundant displays."
|
||||
|
@ -10,7 +10,8 @@ from django_ckeditor_5.fields import CKEditor5Field
|
||||
from django_extensions.db.fields import AutoSlugField
|
||||
from location_field.models.spatial import LocationField
|
||||
|
||||
from ..models import Event
|
||||
# from ..models.event import Event
|
||||
Event = None
|
||||
|
||||
|
||||
class Place(models.Model):
|
||||
|
@ -8,7 +8,10 @@ from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django_ckeditor_5.fields import CKEditor5Field
|
||||
|
||||
from ..models import Event, no_slash_validator, remove_accents
|
||||
# from ..models.event import Event
|
||||
from ..models.utils import no_slash_validator, remove_accents
|
||||
|
||||
Event = None
|
||||
|
||||
|
||||
class Tag(models.Model):
|
||||
|
Loading…
x
Reference in New Issue
Block a user