This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cron action for fixing desktop and mobile domain names in the s…
…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
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters