def addEntry(self, author, title, content, date=None, msgId=None): print "Adding entry to blog", author, title user = self.findUser(author) if date == None: date = timezone.now() if msgId: entry = self.findEntryByMsgId(msgId) if entry: print "Already have entry:", entry return if not user: return "Can't find user" data = {'title': title, 'slug': slugify(title), 'status': PUBLISHED, 'sites': [Site.objects.get_current().pk], 'authors': [user.pk], 'content_template': 'zinnia/_entry_detail.html', 'detail_template': 'entry_detail.html', # 'creation_date': timezone.now(), 'creation_date': date, 'last_update': timezone.now(), 'content': content, 'tags': "dummy"} form = QuickEntryForm(data) if form.is_valid(): form.instance.content = linebreaks(form.cleaned_data['content']) entry = form.save() print "Added and saved" """ obj = EntryMailData(msg_id=msgId, entry=entry) obj.save() print "Saved link %s %s" % (entry.pk, msgId) """ else: print "problem with entry"
def test(): b = Blog() b.dump() date = timezone.now() print "date:", date b.addEntry(author="kimber", title="a test post", content=testContent, date=date)