diff --git a/ISS/forms.py b/ISS/forms.py index fa9d216..173c66f 100644 --- a/ISS/forms.py +++ b/ISS/forms.py @@ -62,7 +62,7 @@ def clean(self, value): posters = [] unfound = [] - for username in value.split(','): + for username in value.split('; '): if not username: continue norm = Poster.iss_normalize_username(username) @@ -79,6 +79,12 @@ def clean(self, value): else: posters.append(user) + for poster in posters: + if posters.count(poster) > 1: + raise ValidationError( + 'Duplicate users found.', + code='DUPLICATE_USERS') + if unfound: raise ValidationError(unfound) else: @@ -88,7 +94,7 @@ def widget_attrs(self, widget): attrs = super(PosterSelectField, self).widget_attrs(widget) attrs['data-auto-suggest'] = 'true' - attrs['data-auto-suggest-delimiter'] = ',' + attrs['data-auto-suggest-delimiter'] = '; ' return attrs @@ -540,6 +546,10 @@ def clean_username(self): raise ValidationError('You may not register that username.', code='FORBIDDEN_USERNAME') + if ";" in norm_username: + raise ValidationError('You may not register that username.', + code='FORBIDDEN_USERNAME') + if len(norm_username) < 1: raise ValidationError('Invalid username', code='INVALID_GENERAL') diff --git a/ISS/models/core_models.py b/ISS/models/core_models.py index b832723..89a0c07 100644 --- a/ISS/models/core_models.py +++ b/ISS/models/core_models.py @@ -14,6 +14,7 @@ from ISS import utils from ISS.utils import HomoglyphNormalizer from .polls import Poll +from .polls import PollVote from .auth_package import AuthPackage, AccessControlList from .admin_models import Ban @@ -221,12 +222,30 @@ def can_auto_anonymize(self): @transaction.atomic def merge_into(self, other): """ - Reassigns all the records that tie to this user to another one and + Reassigns all (<-- lies) the records that tie to this user to another one and disables this user afterwards. """ Thread.objects.filter(author=self).update(author=other) - Post.objects.filter(author=self).update(author=other) + + Post.objects.filter(author=self).update( + posted_from='127.0.0.1', + author=other + ) + + PostSnapshot.objects.filter(obsolesced_by=self).update( + obsolescing_ip='127.0.0.1', + obsolesced_by=other + ) + + for post in Post.objects.all(): + post.content = post.content.replace("author=\"" + self.username + "\"", "author=\"" + str(other) + "\"") + post.save() + + PrivateMessage.objects.filter(inbox=self).delete() + PrivateMessage.objects.filter(sender=self).update(sender=other) + + PollVote.objects.filter(voter=self).delete() for thanks in self.thanks_given.all(): try: diff --git a/ISS/templates/thread.html b/ISS/templates/thread.html index 3cdd2ae..2283b69 100644 --- a/ISS/templates/thread.html +++ b/ISS/templates/thread.html @@ -64,6 +64,7 @@