Esempio n. 1
0
 def create_story(self):
     story = Story()
     story.headline = "This Is A Test Story"
     #normally slugify will be handled by the UI 
     story.slug = slugify(story.headline)
     summary = "Like I said in the headline, this is a test story."
     #TODO add an author(s)
     story.save()
     return story
Esempio n. 2
0
def submit(request):
	"""Submit new post view"""
	topic_list = Topic.objects.get_tree()
	selected_topic = ''
	if request.method == 'POST':
		form = StoryForm(request.POST)
		if form.is_valid():
			s = Story(title = form.cleaned_data['title'], text = form.cleaned_data['text'], user = request.user, topic = form.cleaned_data['topic'], url = form.cleaned_data['url'])
			s.slug = slugify(form.cleaned_data['title'])
			s.save()
			ds = DuggedStory(user = request.user, story = s)
			ds.save()
			urlredirect = reverse('stories_slug', args=[s.topic.urlname, s.slug])
			return redirect_to(request, urlredirect)
		else:
			if form.data['topic']:
				try:
					selected_topic = int(form.data['topic'])
				except:
					pass
	else:
		form = StoryForm()
	return render_to_response('stories/submit.html', {'form': form, 'user': request.user, 'topic_list': topic_list, 'selected_topic': selected_topic})