Events und Gallery in einzelne Apps aufgetielt.
Lokalisierung auf einzelne Apps aufgeteilt Mai-Star Ranking in die Navigation integriert
This commit is contained in:
@@ -24,7 +24,8 @@ class Command(BaseCommand):
|
||||
|
||||
def create_article(self):
|
||||
self.slug = slugify(self.headline[:50])
|
||||
article, created = Article.objects.get_or_create(slug=self.slug, date_created=self.date_created,
|
||||
article, created = Article.objects.get_or_create(slug=self.slug,
|
||||
date_created=self.date_created,
|
||||
defaults={
|
||||
'author': self.author,
|
||||
'headline_de': self.headline,
|
||||
@@ -37,9 +38,11 @@ class Command(BaseCommand):
|
||||
article.save()
|
||||
|
||||
def parse_with_date(self, original):
|
||||
match_obj = re.search(self.date_header_regex, original, re.IGNORECASE | re.DOTALL)
|
||||
match_obj = re.search(self.date_header_regex, original,
|
||||
re.IGNORECASE | re.DOTALL)
|
||||
if match_obj:
|
||||
self.date_created = datetime.strptime(match_obj.group('date'), '%d.%m.%Y')
|
||||
self.date_created = datetime.strptime(match_obj.group('date'),
|
||||
'%d.%m.%Y')
|
||||
self.headline = match_obj.group('title').strip()
|
||||
self.content = match_obj.group('content').strip()
|
||||
return True
|
||||
@@ -47,7 +50,8 @@ class Command(BaseCommand):
|
||||
return False
|
||||
|
||||
def parse_without_date(self, original):
|
||||
match_obj = re.search(self.header_regex, original, re.IGNORECASE | re.DOTALL)
|
||||
match_obj = re.search(self.header_regex, original,
|
||||
re.IGNORECASE | re.DOTALL)
|
||||
if match_obj:
|
||||
self.date_created = datetime.strptime('01.01.1982', '%d.%m.%Y')
|
||||
self.headline = match_obj.group('title').strip()
|
||||
@@ -71,7 +75,8 @@ class Command(BaseCommand):
|
||||
if not table.cell_value(row, 2) in ('Archiv', 'News'):
|
||||
continue
|
||||
original = table.cell_value(row, 3)
|
||||
if self.parse_with_date(original) or self.parse_without_date(original):
|
||||
if self.parse_with_date(original) or self.parse_without_date(
|
||||
original):
|
||||
self.create_article()
|
||||
else:
|
||||
print "Fehler bei String!"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils.datetime_safe import datetime
|
||||
|
||||
from events.models import Event, Location
|
||||
import xlrd
|
||||
|
||||
|
||||
Reference in New Issue
Block a user