Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Added cron action for fixing desktop and mobile domain names in the s…
Browse files Browse the repository at this point in the history
…ites framework, and added it to the update staging script. Bug 608581.
  • Loading branch information
Fred Wenzel committed Nov 10, 2010
1 parent abf40fc commit aad142c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
39 changes: 39 additions & 0 deletions apps/input/cron.py
@@ -0,0 +1,39 @@
import logging

from django.conf import settings
from django.contrib.sites.models import Site

import cronjobs


log = logging.getLogger('reporter')

@cronjobs.register
def set_domains(desktop_domain, mobile_domain):
"""
Set mobile domain names in sites framework.
Example:
./manage.py cron set_domains example.com m.example.com
... sets the desktop domain to example.com, and the
mobile domain to m.example.com.
"""
# Not empty, please.
try:
assert desktop_domain
assert mobile_domain
except AssertionError:
log.error('Desktop and mobile domains must not be empty.')
return

changes = {
settings.DESKTOP_SITE_ID: desktop_domain,
settings.MOBILE_SITE_ID: mobile_domain,
}
for id, domain in changes.items():
site = Site.objects.get(id=id)
site.domain = domain
site.name = domain
site.save()
log.debug('Changed site %d domain to %s' % (id, domain))
3 changes: 3 additions & 0 deletions bin/update_staging.sh
Expand Up @@ -26,4 +26,7 @@ $PYTHON vendor/src/schematic/schematic migrations/sites
# Minify assets.
$PYTHON manage.py compress_assets

# Fix mobile and desktop site domains in database. Bug 608581.
$PYTHON ./manage.py cron set_domains input.stage.mozilla.com m.input.stage.mozilla.com

popd > /dev/null

0 comments on commit aad142c

Please sign in to comment.