Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[fix bug 979203] Clean up external account data #845

Closed
wants to merge 1 commit into from

2 participants

@jpotts

No description provided.

@glogiotatidis glogiotatidis commented on the diff
...ns/users/migrations/0054_cleanup_external_accounts.py
((32 lines not shown))
+ Q(identifier__startswith='http') & (
+ Q(type=self.TYPE_AMO) |
+ Q(type=self.TYPE_BMO) |
+ Q(type=self.TYPE_BITBUCKET) |
+ Q(type=self.TYPE_GITHUB) |
+ Q(type=self.TYPE_MDN) |
+ Q(type=self.TYPE_FACEBOOK) |
+ Q(type=self.TYPE_SLIDESHARE)
+ )
+ )
+
+ for res in results:
+ url = self.ACCOUNT_TYPES[res.type].get('url')
+
+ if url:
+ url_pattern_re = re.sub('{identifier}', '(.*)', url)
@glogiotatidis Owner

Changing .* to .+ as we need at least on char and merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@glogiotatidis

r+ this is merged! and I'm sooo happy. Thanks @jpotts :metal:

@jpotts jpotts deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 6, 2014
  1. @jpotts
This page is out of date. Refresh to see the latest.
Showing with 188 additions and 0 deletions.
  1. +188 −0 mozillians/users/migrations/0054_cleanup_external_accounts.py
View
188 mozillians/users/migrations/0054_cleanup_external_accounts.py
@@ -0,0 +1,188 @@
+# -*- coding: utf-8 -*-
+import re
+from south.v2 import DataMigration
+from django.db.models import Q
+
+
+class Migration(DataMigration):
+ no_dry_run = True
+
+ TYPE_AMO = 'AMO'
+ TYPE_BMO = 'BMO'
+ TYPE_GITHUB = 'GITHUB'
+ TYPE_MDN = 'MDN'
+ TYPE_FACEBOOK = 'FACEBOOK'
+ TYPE_BITBUCKET = 'BITBUCKET'
+ TYPE_SLIDESHARE = 'SLIDESHARE'
+
+ ACCOUNT_TYPES = {
+ TYPE_AMO: {'name': 'Mozilla Add-ons',
+ 'url': 'https://addons.mozilla.org/user/{identifier}/'},
+ TYPE_BMO: {'name': 'Bugzilla (BMO)',
+ 'url': 'https://bugzilla.mozilla.org/user_profile?login={identifier}'},
+ TYPE_GITHUB: {'name': 'GitHub', 'url': 'https://github.com/{identifier}'},
+ TYPE_BITBUCKET: {'name': 'Bitbucket', 'url': 'https://bitbucket.org/{identifier}'},
+ TYPE_MDN: {'name': 'MDN', 'url': 'https://developer.mozilla.org/profiles/{identifier}'},
+ TYPE_FACEBOOK: {'name': 'Facebook', 'url': 'https://www.facebook.com/{identifier}'},
+ TYPE_SLIDESHARE: {'name': 'SlideShare', 'url': 'http://www.slideshare.net/{identifier}'},
+ }
+
+ def forwards(self, orm):
+ results = orm.ExternalAccount.objects.filter(
+ Q(identifier__startswith='http') & (
+ Q(type=self.TYPE_AMO) |
+ Q(type=self.TYPE_BMO) |
+ Q(type=self.TYPE_BITBUCKET) |
+ Q(type=self.TYPE_GITHUB) |
+ Q(type=self.TYPE_MDN) |
+ Q(type=self.TYPE_FACEBOOK) |
+ Q(type=self.TYPE_SLIDESHARE)
+ )
+ )
+
+ for res in results:
+ url = self.ACCOUNT_TYPES[res.type].get('url')
+
+ if url:
+ url_pattern_re = re.sub('{identifier}', '(.*)', url)
@glogiotatidis Owner

Changing .* to .+ as we need at least on char and merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ match = re.match(url_pattern_re, res.identifier)
+ if match:
+ res.identifier = match.groups()[0]
+ res.save()
+
+ def backwards(self, orm):
+ pass
+
+ models = {
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'groups.group': {
+ 'Meta': {'ordering': "['name']", 'object_name': 'Group'},
+ 'accepting_new_members': ('django.db.models.fields.CharField', [], {'default': "'yes'", 'max_length': '10'}),
+ 'curator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'groups_curated'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['users.UserProfile']"}),
+ 'description': ('django.db.models.fields.TextField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
+ 'functional_area': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'irc_channel': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '63', 'blank': 'True'}),
+ 'max_reminder': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'members_can_leave': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}),
+ 'new_member_criteria': ('django.db.models.fields.TextField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
+ 'url': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'}),
+ 'visible': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'website': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}),
+ 'wiki': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200', 'blank': 'True'})
+ },
+ 'groups.groupmembership': {
+ 'Meta': {'unique_together': "(('userprofile', 'group'),)", 'object_name': 'GroupMembership'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['groups.Group']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'status': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
+ 'userprofile': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['users.UserProfile']"})
+ },
+ 'groups.skill': {
+ 'Meta': {'ordering': "['name']", 'object_name': 'Skill'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}),
+ 'url': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'})
+ },
+ 'users.externalaccount': {
+ 'Meta': {'ordering': "['type']", 'unique_together': "(('identifier', 'type', 'user'),)", 'object_name': 'ExternalAccount'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'identifier': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'privacy': ('django.db.models.fields.PositiveIntegerField', [], {'default': '3'}),
+ 'type': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['users.UserProfile']"})
+ },
+ 'users.language': {
+ 'Meta': {'ordering': "['code']", 'unique_together': "(('code', 'userprofile'),)", 'object_name': 'Language'},
+ 'code': ('django.db.models.fields.CharField', [], {'max_length': '63'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'userprofile': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['users.UserProfile']"})
+ },
+ 'users.usernameblacklist': {
+ 'Meta': {'ordering': "['value']", 'object_name': 'UsernameBlacklist'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_regex': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'value': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'users.userprofile': {
+ 'Meta': {'ordering': "['full_name']", 'object_name': 'UserProfile', 'db_table': "'profile'"},
+ 'allows_community_sites': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'allows_mozilla_sites': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'basket_token': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '1024', 'blank': 'True'}),
+ 'bio': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
+ 'city': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
+ 'country': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50'}),
+ 'date_mozillian': ('django.db.models.fields.DateField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+ 'date_vouched': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+ 'full_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'members'", 'blank': 'True', 'through': "orm['groups.GroupMembership']", 'to': "orm['groups.Group']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ircname': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '63', 'blank': 'True'}),
+ 'is_vouched': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_updated': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'auto_now': 'True', 'blank': 'True'}),
+ 'photo': ('sorl.thumbnail.fields.ImageField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}),
+ 'privacy_bio': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_city': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_country': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_date_mozillian': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_email': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_full_name': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_groups': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_ircname': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_languages': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_photo': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_region': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_skills': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_timezone': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_title': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'privacy_tshirt': ('mozillians.users.models.PrivacyField', [], {'default': '1'}),
+ 'privacy_vouched_by': ('mozillians.users.models.PrivacyField', [], {'default': '3'}),
+ 'region': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
+ 'skills': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'members'", 'blank': 'True', 'to': "orm['groups.Skill']"}),
+ 'timezone': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '70', 'blank': 'True'}),
+ 'tshirt': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True'}),
+ 'vouched_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'vouchees'", 'on_delete': 'models.SET_NULL', 'default': 'None', 'to': "orm['users.UserProfile']", 'blank': 'True', 'null': 'True'})
+ }
+ }
+
+ complete_apps = ['users']
+ symmetrical = True
Something went wrong with that request. Please try again.