Permalink
Browse files

Merge branch 'master' of github.com:mozilla/kuma

  • Loading branch information...
2 parents 593e407 + aac3a6d commit 9153fb8c5854072e2d63df093bc6f01b5060034b @lmorchard lmorchard committed Mar 28, 2012
Showing with 21,324 additions and 1,342 deletions.
  1. +6 −0 .gitignore
  2. +3 −0 .gitmodules
  3. +1 −4 README-vagrant.md
  4. +2 −4 Vagrantfile
  5. +41 −16 apps/dekicompat/backends.py
  6. 0 apps/dekicompat/management/__init__.py
  7. 0 apps/dekicompat/management/commands/__init__.py
  8. +833 −0 apps/dekicompat/management/commands/migrate_to_kuma_wiki.py
  9. +22 −1 apps/dekicompat/tests.py
  10. +153 −78 apps/demos/__init__.py
  11. +2 −1 apps/demos/feeds.py
  12. +1 −0 apps/demos/forms.py
  13. +125 −75 apps/demos/helpers.py
  14. +1 −1 apps/demos/models.py
  15. +2 −0 apps/demos/templates/demos/detail.html
  16. +35 −2 apps/demos/templates/demos/devderby_landing.html
  17. +9 −1 apps/demos/templates/demos/submit_noauth.html
  18. +19 −0 apps/demos/tests/test_helpers.py
  19. +30 −0 apps/demos/tests/test_templates.py
  20. +4 −2 apps/demos/tests/test_views.py
  21. +3 −3 apps/devmo/fixtures/bad_date.csv
  22. +2 −2 apps/devmo/fixtures/xss.csv
  23. +2 −25 apps/devmo/forms.py
  24. +92 −57 apps/devmo/models.py
  25. +62 −5 apps/devmo/templates/devmo/profile.html
  26. +1 −1 apps/devmo/templates/devmo/profile_edit.html
  27. +37 −0 apps/devmo/tests/test_forms.py
  28. +28 −13 apps/devmo/tests/test_models.py
  29. +81 −0 apps/devmo/tests/test_views.py
  30. +3 −0 apps/devmo/urls.py
  31. +35 −16 apps/devmo/views.py
  32. +2 −2 apps/docs/templates/docs/docs.html
  33. +4 −4 apps/landing/templates/landing/addons.html
  34. +72 −158 apps/landing/templates/landing/apps.html
  35. +59 −0 apps/landing/templates/landing/apps_subscribe.html
  36. +14 −1 apps/landing/templates/landing/home.html
  37. +325 −0 apps/landing/templates/landing/learn_html5.html
  38. +4 −4 apps/landing/templates/landing/mobile.html
  39. +3 −3 apps/landing/templates/landing/mozilla.html
  40. +4 −4 apps/landing/templates/landing/web.html
  41. +39 −7 apps/landing/test_views.py
  42. +1 −0 apps/landing/urls.py
  43. +42 −11 apps/landing/views.py
  44. +26 −21 apps/users/forms.py
  45. +4 −2 apps/users/helpers.py
  46. +6 −2 apps/users/models.py
  47. +7 −0 apps/users/templates/users/browserid_explanation.html
  48. +17 −0 apps/users/templates/users/browserid_header_signin.html
  49. +25 −1 apps/users/templates/users/browserid_register.html
  50. +9 −0 apps/users/templates/users/browserid_signin.html
  51. +8 −7 apps/users/templates/users/change_email.html
  52. +7 −0 apps/users/templates/users/email/reminder.ltxt
  53. +13 −17 apps/users/templates/users/login.html
  54. +10 −1 apps/users/templates/users/register.html
  55. +21 −0 apps/users/templates/users/send_email_reminder_done.html
  56. +1 −0 apps/users/tests/__init__.py
  57. +11 −1 apps/users/tests/test_forms.py
  58. +2 −2 apps/users/tests/test_helpers.py
  59. +47 −6 apps/users/tests/test_templates.py
  60. +165 −14 apps/users/tests/test_views.py
  61. +8 −1 apps/users/urls.py
  62. +18 −2 apps/users/utils.py
  63. +151 −63 apps/users/views.py
  64. +3 −2 apps/wiki/admin.py
  65. +93 −6 apps/wiki/content.py
  66. +4 −4 apps/wiki/events.py
  67. +11 −4 apps/wiki/feeds.py
  68. +31 −35 apps/wiki/forms.py
  69. +166 −0 apps/wiki/migrations/0007_auto__add_field_revision_mindtouch_old_id.py
  70. +174 −0 apps/wiki/migrations/0008_auto__add_field_document_mindtouch_page_id__add_field_document_modifie.py
  71. +175 −0 apps/wiki/migrations/0009_auto__add_field_revision_is_mindtouch_migration__add_unique_revision_m.py
  72. +165 −0 apps/wiki/migrations/0010_add_locale_slug_uniqueness.py
  73. +169 −0 apps/wiki/migrations/0011_auto__add_field_revision_tags.py
  74. +185 −0 apps/wiki/migrations/0012_auto__add_documenttag__add_taggeddocument.py
  75. +159 −23 apps/wiki/models.py
  76. +2 −2 apps/wiki/parser.py
  77. +3 −3 apps/wiki/tasks.py
  78. +51 −15 apps/wiki/templates/wiki/document.html
  79. +12 −14 apps/wiki/templates/wiki/document_revisions.html
  80. +22 −2 apps/wiki/templates/wiki/edit_document.html
  81. +1 −1 apps/wiki/templates/wiki/includes/page_buttons.html
  82. +7 −0 apps/wiki/templates/wiki/includes/revision_diff.html
  83. +3 −1 apps/wiki/tests/__init__.py
  84. +137 −1 apps/wiki/tests/test_content.py
  85. +0 −1 apps/wiki/tests/test_forms.py
  86. +53 −15 apps/wiki/tests/test_models.py
  87. +24 −23 apps/wiki/tests/test_templates.py
  88. +402 −52 apps/wiki/tests/test_views.py
  89. +3 −1 apps/wiki/urls.py
  90. +349 −77 apps/wiki/views.py
  91. +42 −24 configs/htaccess
  92. +1 −0 kumascript
  93. +17 −0 kumascript_settings_local.json-dist
  94. +0 −53 lib/responsys.py
  95. +10 −0 media/ace/ace.js
  96. +1 −0 media/ace/mode-javascript.js
  97. +1 −0 media/ace/theme-dreamweaver.js
  98. +9,753 −0 media/ace/worker-javascript.js
  99. +7 −6 media/ckeditor/skins/kuma/editor.css
  100. +149 −14 media/css/mdn-screen.css
  101. +48 −201 media/css/wiki-screen.css
  102. BIN media/img/bg-orange-collage.jpg
  103. BIN media/img/bg-starburst-five.png
  104. BIN media/img/bg-starburst.png
  105. BIN media/img/blank.gif
  106. BIN media/img/devderby/judges/chriscoyier.jpg
  107. BIN media/img/devderby/judges/chrisheilmann.png
  108. BIN media/img/devderby/judges/remysharp.jpg
  109. BIN media/img/html5-icons.png
  110. BIN media/img/html5-logo-big.png
  111. +71 −0 media/js/apps-newsletter.js
  112. +1 −1 media/js/main.js
  113. +37 −20 media/js/mdn/init.js
  114. +25 −3 media/js/wiki.js
  115. +22 −7 media/js/wiki_ckeditor.js
  116. +165 −0 media/syntaxhighlighter/LGPL-LICENSE
  117. +20 −0 media/syntaxhighlighter/MIT-LICENSE
  118. +1 −0 media/syntaxhighlighter/VERSION
  119. +17 −0 media/syntaxhighlighter/scripts/shAutoloader.js
  120. +59 −0 media/syntaxhighlighter/scripts/shBrushAS3.js
  121. +75 −0 media/syntaxhighlighter/scripts/shBrushAppleScript.js
  122. +59 −0 media/syntaxhighlighter/scripts/shBrushBash.js
  123. +65 −0 media/syntaxhighlighter/scripts/shBrushCSharp.js
  124. +100 −0 media/syntaxhighlighter/scripts/shBrushColdFusion.js
  125. +97 −0 media/syntaxhighlighter/scripts/shBrushCpp.js
  126. +91 −0 media/syntaxhighlighter/scripts/shBrushCss.js
  127. +55 −0 media/syntaxhighlighter/scripts/shBrushDelphi.js
  128. +41 −0 media/syntaxhighlighter/scripts/shBrushDiff.js
  129. +52 −0 media/syntaxhighlighter/scripts/shBrushErlang.js
  130. +67 −0 media/syntaxhighlighter/scripts/shBrushGroovy.js
  131. +52 −0 media/syntaxhighlighter/scripts/shBrushJScript.js
  132. +57 −0 media/syntaxhighlighter/scripts/shBrushJava.js
  133. +58 −0 media/syntaxhighlighter/scripts/shBrushJavaFX.js
  134. +72 −0 media/syntaxhighlighter/scripts/shBrushPerl.js
  135. +88 −0 media/syntaxhighlighter/scripts/shBrushPhp.js
  136. +33 −0 media/syntaxhighlighter/scripts/shBrushPlain.js
  137. +74 −0 media/syntaxhighlighter/scripts/shBrushPowerShell.js
  138. +64 −0 media/syntaxhighlighter/scripts/shBrushPython.js
  139. +55 −0 media/syntaxhighlighter/scripts/shBrushRuby.js
  140. +94 −0 media/syntaxhighlighter/scripts/shBrushSass.js
  141. +51 −0 media/syntaxhighlighter/scripts/shBrushScala.js
  142. +66 −0 media/syntaxhighlighter/scripts/shBrushSql.js
  143. +56 −0 media/syntaxhighlighter/scripts/shBrushVb.js
  144. +69 −0 media/syntaxhighlighter/scripts/shBrushXml.js
  145. +17 −0 media/syntaxhighlighter/scripts/shCore.js
  146. +17 −0 media/syntaxhighlighter/scripts/shLegacy.js
  147. +226 −0 media/syntaxhighlighter/styles/shCore.css
  148. +328 −0 media/syntaxhighlighter/styles/shCoreDefault.css
  149. +331 −0 media/syntaxhighlighter/styles/shCoreDjango.css
  150. +339 −0 media/syntaxhighlighter/styles/shCoreEclipse.css
  151. +324 −0 media/syntaxhighlighter/styles/shCoreEmacs.css
  152. +328 −0 media/syntaxhighlighter/styles/shCoreFadeToGrey.css
  153. +324 −0 media/syntaxhighlighter/styles/shCoreMDUltra.css
  154. +324 −0 media/syntaxhighlighter/styles/shCoreMidnight.css
  155. +324 −0 media/syntaxhighlighter/styles/shCoreRDark.css
  156. +117 −0 media/syntaxhighlighter/styles/shThemeDefault.css
  157. +120 −0 media/syntaxhighlighter/styles/shThemeDjango.css
  158. +128 −0 media/syntaxhighlighter/styles/shThemeEclipse.css
  159. +113 −0 media/syntaxhighlighter/styles/shThemeEmacs.css
  160. +117 −0 media/syntaxhighlighter/styles/shThemeFadeToGrey.css
  161. +113 −0 media/syntaxhighlighter/styles/shThemeMDUltra.css
  162. +113 −0 media/syntaxhighlighter/styles/shThemeMidnight.css
  163. +113 −0 media/syntaxhighlighter/styles/shThemeRDark.css
  164. +1 −1 migrations/01-initial.sql
  165. +7 −2 puppet/files/etc/motd
  166. +1 −0 puppet/files/etc/sysconfig/iptables
  167. +4 −3 puppet/files/home/vagrant/bash_profile
  168. +47 −15 puppet/files/tmp/postimport.sql
  169. +17 −0 puppet/files/vagrant/kumascript_settings_local.json
  170. +13 −1 puppet/files/vagrant/settings_local.py
  171. +17 −2 puppet/manifests/classes/dev-hacks.pp
  172. +37 −0 puppet/manifests/classes/nodejs.pp
  173. +0 −7 puppet/manifests/classes/python.pp
  174. +1 −0 puppet/manifests/dev-vagrant.pp
  175. +1 −0 requirements/dev.txt
  176. +5 −0 scripts/migrate_all.sh
  177. +5 −0 scripts/migrate_recent.sh
  178. +5 −0 scripts/migrate_top.sh
  179. +9 −11 scripts/update_site.py
  180. +116 −5 settings.py
  181. +12 −5 templates/500.html
  182. +1 −1 templates/base.html
  183. +6 −36 templates/includes/login.html
  184. +1 −1 vendor
View
@@ -2,6 +2,8 @@
*.pyo
*.sw?
.vagrant
+vagrantconfig_local.yaml
+kuma.box
settings_local.py
pip-log.txt
.coverage
@@ -21,3 +23,7 @@ puppet/cache/*
humans.txt
apps/humans/tmp
tmp
+webroot/.htaccess
+kumascript.log
+kumascript_settings_local.json
+lib/product_details_json
View
@@ -10,3 +10,6 @@
[submodule "vendor"]
path = vendor
url = git://github.com/mozilla/kuma-lib.git
+[submodule "kumascript"]
+ path = kumascript
+ url = git://github.com/mozilla/kumascript.git
View
@@ -16,10 +16,8 @@ reasons.
# Open a terminal window.
# Install vagrant, see vagrantup.com
- # NOTE: Currently, vagrant v0.8.8 appears to fail with this setup, so we
- # need to revert to 0.8.7
sudo gem update
- sudo gem install vagrant --version=0.8.7
+ sudo gem install vagrant
# Clone a Kuma repo, switch to "mdn" branch (for now)
git clone git://github.com/mozilla/kuma.git
@@ -44,7 +42,6 @@ reasons.
# production site. This can take a long while, since there's over 500MB
vagrant ssh
sudo puppet apply /vagrant/puppet/manifests/dev-vagrant-mdn-import.pp
- mysql -uroot < /vagrant/puppet/files/tmp/postimport.sql
sudo puppet apply /vagrant/puppet/manifests/dev-vagrant.pp
# Edit files as usual on your host machine; the current directory is
View
@@ -29,16 +29,14 @@ Vagrant::Config.run do |config|
end
# This thing can be a little hungry for memory
- config.vm.customize do |vm|
- vm.memory_size = CONF['memory_size']
- end
+ config.vm.customize ["modifyvm", :id, "--memory", CONF['memory_size']]
# uncomment to enable VM GUI console, mainly for troubleshooting
if CONF['gui'] == true
config.vm.boot_mode = :gui
end
- config.vm.network(CONF['ip_address'])
+ config.vm.network :hostonly, CONF['ip_address']
# Increase vagrant's patience during hang-y CentOS bootup
# see: https://github.com/jedi4ever/veewee/issues/14
@@ -1,6 +1,5 @@
-import logging
-
from datetime import datetime
+import time
from urllib import urlencode
from urllib2 import HTTPError
import urlparse
@@ -9,11 +8,12 @@
from xml.sax.saxutils import escape as xml_escape
from django.conf import settings
+from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth.models import User
-
from pyquery import PyQuery as pq
import commonware
+import constance.config
from devmo.models import UserProfile
@@ -39,6 +39,8 @@
</permissions.user>
</user>"""
+class MindTouchAPIError(Exception):
+ pass
class DekiUserBackend(object):
"""
@@ -144,7 +146,10 @@ def get_user(self, user_id):
return None
@staticmethod
- def get_or_create_user(deki_user):
+ def get_or_create_user(deki_user, sync_attrs=('is_superuser',
+ 'is_staff',
+ 'is_active',
+ 'email')):
"""
Grab the User via their UserProfile and deki_user_id.
If non exists, create both.
@@ -157,21 +162,28 @@ def get_or_create_user(deki_user):
profile = UserProfile.objects.get(deki_user_id=deki_user.id)
user = profile.user
- except UserProfile.DoesNotExist:
+ except ObjectDoesNotExist:
# No existing profile, so try creating a new profile and user
+
+ # HACK: Usernames in Kuma are limited to 30 characters. There are
+ # around 0.1% of MindTouch users in production (circa 2011) whose
+ # names exceed this length. They're mostly the product of spammers
+ # and security tests but it will still throw MySQL-level errors
+ # during migration.
+ username = deki_user.username[:30]
+
user, created = (User.objects
- .get_or_create(username=deki_user.username))
- user.username = deki_user.username
+ .get_or_create(username=username))
+ user.username = username
user.email = deki_user.email
user.set_unusable_password()
user.save()
profile = UserProfile(deki_user_id=deki_user.id, user=user)
- profile.save()
+ profile.save(skip_mindtouch_put=True)
user.deki_user = deki_user
# Sync these attributes from Deki -> Django (for now)
- sync_attrs = ('is_superuser', 'is_staff', 'is_active', 'email')
needs_save = False
for sa in sync_attrs:
deki_val = getattr(deki_user, sa, None)
@@ -211,27 +223,40 @@ def generate_mindtouch_user_xml(user):
role = 'Contributor'
if user.is_staff and user.is_superuser:
role = 'Admin'
- user_xml = MINDTOUCH_USER_XML % {'username': user.username,
- 'email': user.email,
- 'fullname': user.get_profile().fullname,
+ user_xml = MINDTOUCH_USER_XML % {'username': user.username.encode('utf-8'),
+ 'email': user.email.encode('utf-8'),
+ 'fullname': user.get_profile().fullname.encode('utf-8'),
'status': 'active',
'language': user.get_profile().mindtouch_language,
'timezone': user.get_profile().mindtouch_timezone,
'role': role}
return user_xml
@staticmethod
+ def _perform_post_mindtouch_user(url, data, headers):
+ return requests.post(url, data=data, headers=headers)
+
+ @staticmethod
def post_mindtouch_user(user):
# post a new mindtouch user
user_url = '%s/@api/deki/users?apikey=%s' % (
settings.DEKIWIKI_ENDPOINT,
settings.DEKIWIKI_APIKEY)
user_xml = DekiUserBackend.generate_mindtouch_user_xml(user)
headers = {'Content-Type': 'application/xml'}
- resp = requests.post(user_url, data=user_xml, headers=headers)
+ resp = DekiUserBackend._perform_post_mindtouch_user(user_url,
+ user_xml,
+ headers)
if resp.status_code is not 200:
- # TODO: decide WTF to do here
- pass
+ # HACK: MindTouch fails intermittently, so retry a few times
+ for i in range(constance.config.DEKIWIKI_POST_RETRIES):
+ resp = DekiUserBackend._perform_post_mindtouch_user(
+ user_url, data=user_xml, headers=headers)
+ if resp.status_code is 200:
+ break
+ time.sleep(constance.config.DEKIWIKI_API_RETRY_WAIT * i)
+ if resp.status_code is not 200:
+ raise MindTouchAPIError("post_mindtouch_user failed")
return DekiUser.parse_user_info(resp.content)
@staticmethod
@@ -264,7 +289,7 @@ def __init__(self, id, username, fullname, email, gravatar,
self.email = email
self.gravatar = gravatar
self.profile_url = profile_url
- self.is_active = False
+ self.is_active = True
self.is_staff = False
self.is_superuser = False
Oops, something went wrong.

0 comments on commit 9153fb8

Please sign in to comment.