On supprime les traces inutiles

This commit is contained in:
Jean-Marie Favreau 2024-11-22 23:54:57 +01:00
parent 37817cc8f5
commit 386eca261a
2 changed files with 0 additions and 34 deletions

View File

@ -988,38 +988,29 @@ class Event(models.Model):
self.recurrence_dtend = self.recurrence_dtstart
def prepare_save(self):
logger.warning('AAA')
self.update_modification_dates()
logger.warning('BBB')
self.update_recurrence_dtstartend()
logger.warning('CCC')
# if the image is defined but not locally downloaded
if self.image and not self.local_image:
self.download_image()
logger.warning('DDD')
# remove "/" from tags
if self.tags:
self.tags = [t.replace('/', '-') for t in self.tags]
logger.warning('EEE')
# in case of importation process
if self.is_in_importation_process():
logger.warning('EE1')
# try to detect location
if not self.exact_location:
for p in Place.objects.all():
if p.match(self):
self.exact_location = p
break
logger.warning('EE2')
# try to detect category
if not self.category or self.category.name == Category.default_name:
CategorisationRule.apply_rules(self)
logger.warning('EE3')
logger.warning('FFF')
def save(self, *args, **kwargs):
self.prepare_save()
@ -1068,7 +1059,6 @@ class Event(models.Model):
e.save()
def from_structure(event_structure, import_source=None):
logger.warning("from structure")
# organisers is a manytomany relation thus cannot be initialised before creation of the event
organisers = event_structure.pop('organisers', None)
@ -1264,7 +1254,6 @@ class Event(models.Model):
for attr in Event.data_fields(all=all, local_img=False, exact_location=False):
if attr == 'organisers':
values = [[str(o) for o in e.get_organisers()] for e in events]
logger.warning("values: " + str(values))
else:
values = [getattr(e, attr) for e in events]
values = ["" if v is None else v for v in values]
@ -1366,16 +1355,12 @@ class Event(models.Model):
def update(self, other, all):
if other.has_pending_organisers():
logger.warning("set dans le update")
self.organisers.set(other.pending_organisers)
# set attributes
for attr in Event.data_fields(all=all, no_m2m=True):
logger.warning('on set l attribut ' + attr + ' sur ' + str(self.pk) + ' avec valeur ' + str(getattr(other, attr)))
setattr(self, attr, getattr(other, attr))
logger.warning('suite')
# adjust modified date if required
if other.modified_date and self.modified_date < other.modified_date:
self.modified_date = other.modified_date
@ -1389,7 +1374,6 @@ class Event(models.Model):
# Limitation: the given events should not be considered similar one to another...
def import_events(events, remove_missing_from_source=None):
logger.warning("import_events")
to_import = []
to_update = []
@ -1400,7 +1384,6 @@ class Event(models.Model):
# for each event, check if it's a new one, or a one to be updated
for event in events:
logger.warning("event " + str(event))
sdate = date.fromisoformat(event.start_day)
if event.end_day:
edate = date.fromisoformat(event.end_day)
@ -1415,20 +1398,14 @@ class Event(models.Model):
if event.uuids and len(event.uuids) > 0:
uuids |= set(event.uuids)
logger.warning("avant " + str(event))
# imported events should be updated
event.set_in_importation_process()
logger.warning("step " + str(event))
event.prepare_save()
logger.warning("neeext " + str(event))
# check if the event has already be imported (using uuid)
same_events = event.find_same_events_by_uuid()
if len(same_events) != 0:
logger.warning("same non nuls")
# check if one event has been imported and not modified in this list
same_imported = Event.find_last_pure_import(same_events)
pure = True
@ -1448,14 +1425,12 @@ class Event(models.Model):
if same_imported.other_versions.representative != same_imported:
same_imported.other_versions.representative = None
same_imported.other_versions.save()
logger.warning('on va y updater')
same_imported.update(event, pure) # we only update all tags if it"s a pure import
same_imported.set_in_importation_process()
same_imported.prepare_save()
to_update.append(same_imported)
else:
# otherwise, the new event possibly a duplication of the remaining others.
logger.warning("hop trash")
# check if it should be published
trash = len([e for e in same_events if e.status != Event.STATUS.TRASH]) == 0
@ -1477,14 +1452,11 @@ class Event(models.Model):
# import this new event
to_import.append(event)
logger.warning("apres boucle")
# then import all the new events
imported = Event.objects.bulk_create(to_import)
# update organisers (m2m relation)
for i, ti in zip(imported, to_import):
if ti.has_pending_organisers():
logger.warning("set apres bulk create " + str(i.pk))
i.organisers.set(ti.pending_organisers)
nb_updated = Event.objects.bulk_update(
@ -1493,8 +1465,6 @@ class Event(models.Model):
+ ["imported_date", "modified_date", "uuids", "status"],
)
logger.warning("avant remove")
nb_draft = 0
if remove_missing_from_source is not None and max_date is not None:
# events that are missing from the import but in database are turned into drafts
@ -1528,8 +1498,6 @@ class Event(models.Model):
nb_draft = Event.objects.bulk_update(to_draft, fields=["status"])
logger.warning("fin ça fait fin")
return imported, nb_updated, nb_draft
def set_current_date(self, date):

View File

@ -305,7 +305,6 @@ class EventUpdateView(
success_message = _("The event has been successfully modified.")
def get_form_kwargs(self):
logger.warning("start kwargs")
kwargs = super().get_form_kwargs()
kwargs["is_authenticated"] = self.request.user.is_authenticated
kwargs["is_cloning"] = self.is_cloning
@ -509,7 +508,6 @@ class EventCreateView(SuccessMessageMixin, CreateView):
def form_valid(self, form):
logger.warning(str(form.cleaned_data))
if form.cleaned_data['simple_cloning']:
form.instance.set_skip_duplicate_check()