Only reopen a duplicatedevent if data is different (not tags or categories)
This commit is contained in:
		@@ -1078,9 +1078,9 @@ class Event(models.Model):
 | 
			
		||||
    def masked(self):
 | 
			
		||||
        return self.other_versions and self.other_versions.representative != self
 | 
			
		||||
 | 
			
		||||
    def get_comparison(events):
 | 
			
		||||
    def get_comparison(events, all=True):
 | 
			
		||||
        result = []
 | 
			
		||||
        for attr in Event.data_fields(local_img=False, exact_location=False):
 | 
			
		||||
        for attr in Event.data_fields(all=all, local_img=False, exact_location=False):
 | 
			
		||||
            values = [getattr(e, attr) for e in events]
 | 
			
		||||
            values = ["" if v is None else v for v in values]
 | 
			
		||||
            values = [[] if attr == "tags" and v == "" else v for v in values]
 | 
			
		||||
@@ -1096,8 +1096,8 @@ class Event(models.Model):
 | 
			
		||||
                result.append({"similar": False, "key": attr, "values": values})
 | 
			
		||||
        return result
 | 
			
		||||
 | 
			
		||||
    def similar(self, event):
 | 
			
		||||
        res = Event.get_comparison([self, event])
 | 
			
		||||
    def similar(self, event, all=True):
 | 
			
		||||
        res = Event.get_comparison([self, event], all)
 | 
			
		||||
        for r in res:
 | 
			
		||||
            if not r["similar"]:
 | 
			
		||||
                return False
 | 
			
		||||
@@ -1132,10 +1132,16 @@ class Event(models.Model):
 | 
			
		||||
        elist = list(events) + ([self] if self.pk is not None else [])
 | 
			
		||||
        Event.objects.bulk_update(elist, fields=["other_versions"])
 | 
			
		||||
 | 
			
		||||
    def data_fields(local_img=True, exact_location=True):
 | 
			
		||||
        result = [
 | 
			
		||||
            "category",
 | 
			
		||||
            "tags",
 | 
			
		||||
    def data_fields(local_img=True, exact_location=True, all=True):
 | 
			
		||||
        result = []
 | 
			
		||||
 | 
			
		||||
        if all:
 | 
			
		||||
            result += [
 | 
			
		||||
                "category",
 | 
			
		||||
                "tags",
 | 
			
		||||
            ]
 | 
			
		||||
 | 
			
		||||
        result += [
 | 
			
		||||
            "title",
 | 
			
		||||
            "location",
 | 
			
		||||
            "start_day",
 | 
			
		||||
@@ -1226,13 +1232,13 @@ class Event(models.Model):
 | 
			
		||||
                # if not, we check if it does not match exactly with another
 | 
			
		||||
                if not same_imported:
 | 
			
		||||
                    for e in same_events:
 | 
			
		||||
                        if event.similar(e):
 | 
			
		||||
                        if event.similar(e, False):
 | 
			
		||||
                            same_imported = e
 | 
			
		||||
                            break
 | 
			
		||||
 | 
			
		||||
                if same_imported:
 | 
			
		||||
                    # reopen DuplicatedEvents if required
 | 
			
		||||
                    if not event.similar(same_imported) and same_imported.other_versions:
 | 
			
		||||
                    if not event.similar(same_imported, False) and same_imported.other_versions:
 | 
			
		||||
                        if same_imported.status != Event.STATUS.TRASH:
 | 
			
		||||
                            if same_imported.other_versions.is_published():
 | 
			
		||||
                                if same_imported.other_versions.representative != same_imported:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user