def visit_corporation_topics(request, gurl_number): corporation = Corporation.objects(url_number=gurl_number).get() if request.method == "POST": form = NewTopicForm(request.POST) if form.is_valid(): title = form.cleaned_data['title'] content = form.cleaned_data['content'] topic = Topic(title=title) turl_number = len(Topic.objects) + 1 topic.url_number = turl_number topic.content = content topic.creat_time = datetime.datetime.now() topic.is_active = True topic.is_locked = False topic.is_top = False topic.clicks = 0 topic.update_time = datetime.datetime.now() topic.update_author = request.user sccard = S_C_Card.objects(user=request.user, corporation=corporation).get() topic.creator = sccard topic.save() return HttpResponseRedirect('/corporation/' + str(gurl_number) + '/topic/' + str(turl_number) + '/') else: form = NewTopicForm() return render_to_response('corporation/corporation_topics.html', { 'form': form, 'corporation': corporation, 'STATIC_URL': STATIC_URL, 'current_user': request.user }, context_instance=RequestContext(request))
def visit_corporation_topics(request, gurl_number): corporation = Corporation.objects(url_number=gurl_number).get() if request.method == "POST": form = NewTopicForm(request.POST) if form.is_valid(): title = form.cleaned_data['title'] content = form.cleaned_data['content'] topic = Topic(title=title) turl_number = len(Topic.objects) + 1 topic.url_number = turl_number topic.content = content topic.creat_time = datetime.datetime.now() topic.is_active = True topic.is_locked = False topic.is_top = False topic.clicks = 0 topic.update_time = datetime.datetime.now() topic.update_author = request.user sccard = S_C_Card.objects(user=request.user, corporation=corporation).get() topic.creator = sccard topic.save() return HttpResponseRedirect('/corporation/' + str(gurl_number) + '/topic/' + str(turl_number) + '/') else: form = NewTopicForm() return render_to_response('corporation/corporation_topics.html', {'form':form, 'corporation':corporation, 'STATIC_URL':STATIC_URL, 'current_user':request.user}, context_instance=RequestContext(request))