def add(request, community, widget, render): community_obj = Community.objects.get(key_name=community) widget_config = community_obj.widget_set.get(key_name=widget) class PostForm(forms.Form): title = forms.CharField(max_length=100) tags = forms.CharField(required=False, max_length=100) content = forms.CharField(required=False, widget=forms.Textarea) if request.method == 'POST': form = PostForm(request.POST) if form.is_valid(): post = Topic(author=request.user) post.title = form.cleaned_data['title'] post.content = text_markup.render( form.cleaned_data['content'] ) post.raw_content = form.cleaned_data['content'] post.add_tags( form.cleaned_data['tags'] ) post.community = community_obj post.community_widget = widget_config post.save() redirect = get_url(post) return HttpResponseRedirect(redirect) else: form = PostForm() # An unbound form context = {'form': form, 'community_obj': community_obj, 'widget_config': widget_config} return render(request, context)
def auth(request): context = {} context['auth'] = Topic.get_auth_class().get_auth() context['auth_comment'] = Comment.get_auth_class().get_auth() return context