Skip to content

Commit

Permalink
Got the import csv functionality working
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaMark16 committed Jun 10, 2011
1 parent bd9c862 commit 4e95d68
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cms_redirects/admin.py
Expand Up @@ -2,7 +2,7 @@
from cms_redirects.models import CMSRedirect

class CMSRedirectAdmin(admin.ModelAdmin):
list_display = ('old_path', 'new_path', 'page', 'page_site', 'actual_response_code',)
list_display = ('old_path', 'new_path', 'page', 'page_site', 'site', 'actual_response_code',)
list_filter = ('site',)
search_fields = ('old_path', 'new_path', 'page')
radio_fields = {'site': admin.VERTICAL}
Expand Down
15 changes: 11 additions & 4 deletions cms_redirects/management/commands/import_redirect_csv.py
Expand Up @@ -6,6 +6,7 @@
from django.contrib.sites.models import Site
from django.core.exceptions import ObjectDoesNotExist

from cms_redirects.models import CMSRedirect

class Command(BaseCommand):
can_import_settings = True
Expand Down Expand Up @@ -41,9 +42,15 @@ def execute(self, *args, **options):
raise CommandError("No site found, invalid domain: %s" % options["site"])

for row in reader:
print row["Old Url"]
print row["New Url"]
print "*************"
old_url = row["Old Url"]
new_url = row["New Url"]
resp_code = row["Response Code"]
if resp_code not in ['301', '302']:
resp_code = '301'
redirect, created = CMSRedirect.objects.get_or_create(site=current_site, old_path=old_url)
redirect.new_path = new_url
redirect.response_code = resp_code
redirect.save()



Expand All @@ -52,4 +59,4 @@ def execute(self, *args, **options):





5 changes: 0 additions & 5 deletions redirect_demo/settings.py
Expand Up @@ -68,11 +68,6 @@

CMS_TEMPLATES = (
('home.html', gettext('Homepage')),
('content2.html', gettext('Content')),
('content.html', gettext('Content (without image)')),
('content3.html', gettext('Content (without left nav)')),
('freezgard_base.html', gettext('FreezGard Homepage')),
('freezgard_content.html', gettext('FreezGard Content')),
)

CMS_PLACEHOLDER_CONF = {
Expand Down

0 comments on commit 4e95d68

Please sign in to comment.