# HG changeset patch # User Brian Neal # Date 1299297810 0 # Node ID 9d470c7a2b937718e690d9bcda9ec14ac09b9e99 # Parent c5ae0a276e337f203c50336b7ea9c3b447afb9ab Following up on #168; redo some code to make it more DRY. Added a function on the profile to reset the text fields. diff -r c5ae0a276e33 -r 9d470c7a2b93 gpp/bio/admin.py --- a/gpp/bio/admin.py Sat Mar 05 03:43:32 2011 +0000 +++ b/gpp/bio/admin.py Sat Mar 05 04:03:30 2011 +0000 @@ -98,11 +98,7 @@ for profile in qs: Comment.objects.filter(user=profile.user).delete() delete_user_posts(profile.user) - profile.location = '' - profile.occupation = '' - profile.interests = '' - profile.profile_text = '' - profile.signature = '' + profile.reset_text_fields() profile.save() mark_spammer.short_description = "Mark selected users as spammers" diff -r c5ae0a276e33 -r 9d470c7a2b93 gpp/bio/models.py --- a/gpp/bio/models.py Sat Mar 05 03:43:32 2011 +0000 +++ b/gpp/bio/models.py Sat Mar 05 04:03:30 2011 +0000 @@ -126,6 +126,18 @@ user_is_active.boolean = True user_is_active.short_description = "Is Active" + def reset_text_fields(self): + """ + Reset profile text fields to empty defaults. + This function is useful when a spammer is identified. + + """ + self.location = '' + self.occupation = '' + self.interests = '' + self.profile_text = '' + self.signature = '' + def search_title(self): full_name = self.user.get_full_name() if full_name: diff -r c5ae0a276e33 -r 9d470c7a2b93 gpp/forums/views/spam.py --- a/gpp/forums/views/spam.py Sat Mar 05 03:43:32 2011 +0000 +++ b/gpp/forums/views/spam.py Sat Mar 05 04:03:30 2011 +0000 @@ -37,11 +37,7 @@ profile = user.get_profile() profile.status = bio.models.STA_SPAMMER profile.status_date = datetime.datetime.now() - profile.location = '' - profile.occupation = '' - profile.interests = '' - profile.profile_text = '' - profile.signature = '' + profile.reset_text_fields() profile.save() Comment.objects.filter(user=user).delete()