Пример #1
0
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))
Пример #2
0
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))
Пример #3
0
# -*- coding: utf-8 -*-
__author__ = 'bobby'
import sys
import os

pwd = os.path.dirname(os.path.realpath(__file__))
sys.path.append(pwd + "../")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "v2ex.settings")

import django
django.setup()

from topic.models import Topic

from db_tools.data.topic_data import row_data

for tips_detail in row_data:
    tips = Topic()
    tips.title = tips_detail["title"]
    tips.topic_sn = tips_detail["tips_sn"]
    tips.click_num = tips_detail["click_num"]
    tips.like_num = tips_detail["like_num"]
    tips.dislike_num = tips_detail["dislike_num"]
    tips.title = tips_detail["title"]
    tips.content = tips_detail["content"]
    tips.category_id = tips_detail["category"]
    tips.author_id = tips_detail["author"]

    tips.save()