当前位置: 首页>>代码示例>>Python>>正文


Python Topic.save方法代码示例

本文整理汇总了Python中models.Topic.save方法的典型用法代码示例。如果您正苦于以下问题:Python Topic.save方法的具体用法?Python Topic.save怎么用?Python Topic.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Topic的用法示例。


在下文中一共展示了Topic.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: new_topic

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
def new_topic(request,gname):
	'''
		login user add a new topic
	'''
	vars = {}
	group = Group.objects.get(name=gname)
	vars['group'] = group
	if request.method == "POST":
		rev_title = request.POST.get("rev_title","")
		rev_text  = request.POST.get("rev_text","")
		image_names = request.POST.get("image_names","")
		if rev_text == "" or rev_title == '':
			vars["msg"] = "标题和内容不能不写啊"
			return render(request,'new_topic.html',vars)
		images =  image_names.split("|")[:-1]
		image_str = ""
		for im in images:
			image_str += "%s<br/>"%im
		rev_text = image_str+">>>>||>>>>"+rev_text
		topic = Topic(name=rev_title,content=rev_text,group=group,creator=request.user)
		topic.save()
		topic_amount = Topic_reply_amount(topic=topic,amount=0)
		topic_amount.save()
		return redirect("topic",id=topic.id)
	return render(request,'new_topic.html',vars)
开发者ID:amituofo,项目名称:BOHOO,代码行数:27,代码来源:views.py

示例2: save

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
 def save(self):
     topic_post = False
     if not self.topic:
         topic_type = self.cleaned_data["topic_type"]
         if topic_type:
             topic_type = TopicType.objects.get(id=topic_type)
         else:
             topic_type = None
         topic = Topic(
             forum=self.forum,
             posted_by=self.user,
             subject=self.cleaned_data["subject"],
             need_replay=self.cleaned_data["need_replay"],
             need_reply_attachments=self.cleaned_data["need_reply_attachments"],
             topic_type=topic_type,
         )
         topic_post = True
         topic.save()
     else:
         topic = self.topic
     post = Post(
         topic=topic,
         posted_by=self.user,
         poster_ip=self.ip,
         message=self.cleaned_data["message"],
         topic_post=topic_post,
     )
     post.save()
     if topic_post:
         topic.post = post
         topic.save()
     attachments = self.cleaned_data["attachments"]
     post.update_attachments(attachments)
     return post
开发者ID:alexliyu,项目名称:mobilesystem,代码行数:36,代码来源:forms.py

示例3: topic_new

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
def topic_new(request, template_name='private_messages/topic_new.html'):
    if request.method == 'POST':
        form = NewTopicForm(data=request.POST)
        if form.is_valid():
            message = form.save(commit=False)

            topic = Topic(sender=request.user)
            topic.recipient = form.cleaned_data['recipient']
            topic.subject = form.cleaned_data['subject']
            topic.last_sent_at = datetime.now()
            topic.save()

            message.topic = topic
            message.sender = request.user
            message.save()

            return HttpResponseRedirect(topic.get_absolute_url())
    else:
        initial = {}
        if request.GET.has_key('recipient'):
            initial['recipient'] = request.GET['recipient']

        form = NewTopicForm(initial=initial)

    return TemplateResponse(request, template_name, {
        'pm_form': form,
    })
开发者ID:plazix,项目名称:django-private-messages,代码行数:29,代码来源:views.py

示例4: save

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
    def save(self):
        topic_post = False
        if not self.topic:
            topic_type = self.cleaned_data['topic_type']
            if topic_type:
                topic_type = TopicType.objects.get(id=topic_type)
            else:
                topic_type = None

            self.qvod_address = self.cleaned_data['qvod_address']

            topic = Topic(forum=self.forum,
                          posted_by=self.user,
                          subject=self.cleaned_data['subject'],
                          need_replay=self.cleaned_data['need_replay'],
                          need_reply_attachments=self.cleaned_data['need_reply_attachments'],
                          topic_type=topic_type,
                          qvod_address=self.qvod_address,
                          has_qvod = has_qvod
                          )
            topic_post = True
            topic.save()
        else:
            topic = self.topic
        post = Post(topic=topic, posted_by=self.user, poster_ip=self.ip,
                    message=self.cleaned_data['message'], topic_post=topic_post)
        post.save()
        if topic_post:
            topic.post = post
            topic.save()
        attachments = self.cleaned_data['attachments']
        post.update_attachments(attachments)
        return post
开发者ID:daigong,项目名称:DForum,代码行数:35,代码来源:forms.py

示例5: writeTopic

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
def writeTopic(request):
	topic_name = request.POST['topic']
	sender_name = request.POST['name']		
	topic_record = Topic()
	topic_record.sender_name = sender_name
	topic_record.topic_name = topic_name
	topic_record.save()
	return HttpResponse("ok");
开发者ID:zhangwentao,项目名称:geek,代码行数:10,代码来源:views.py

示例6: test_postSave

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
	def test_postSave(self):
		a = Topic(name='My special topic')
		a.save()
		# For each topic in the Topic model we need a self
		# referencing element in the closure table.
		topics = Topic.objects.all()
		for topic in topics:
			ct = Topic.index._ctModel.objects.get(ancestor=topic)
			self.assertTrue(ct.ancestor == ct.descendant and ct.path_length == 0)
开发者ID:wodo,项目名称:django-ct,代码行数:11,代码来源:tests.py

示例7: AddTopicForm

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
class AddTopicForm(AddPostForm):
    name = forms.CharField(label=_('Subject'), max_length=255)
    
    def save(self):
        self.topic = Topic(forum=self.forum,
                      user=self.user,
                      name=self.cleaned_data['name'])
        self.topic.save()
        return super(AddTopicForm, self).save()
开发者ID:vencax,项目名称:django-vxk-forum,代码行数:11,代码来源:forms.py

示例8: save_topic

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
def save_topic(data_dict):
    topic_list = Topic.objects.filter(title=data_dict['title'])
    
    if topic_list.count() == 0:
        t = Topic(title=data_dict['title'])
        t.image_url = data_dict['image']
        t.link = data_dict['link']
        t.desc = data_dict['desc']
        t.date = data_dict['date']
        t.user = data_dict['user']
        t.clicked=data_dict['clicked']
        t.comments = data_dict['comments']
        t.save()
开发者ID:caoguangyao,项目名称:b-tv,代码行数:15,代码来源:views.py

示例9: addTopic

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
def addTopic(inTitle):
    try:
        existingTopic = Topic.objects.get(title=inTitle)
        return False
    except Topic.DoesNotExist: #this is a good thing! We can create an topic now!
        newTopic = Topic()
        newTopic.title = inTitle
        newTopic.save()
        return newTopic
    
    

        
开发者ID:jweiner1,项目名称:factlist,代码行数:11,代码来源:dbutils.py

示例10: publish_api

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
def publish_api(request):

    if request.method == 'POST':
        data = request.POST

       

        new_board = Board.objects.get(board_title=data['topic_board'])


        new_user = User.objects.get(email=data['topic_author'])
        new_user_profile = UserProfile.objects.get(user=new_user)

        new_tags = data['topic_tags'].split(',')



        new_topic = Topic(
                topic_status = data['topic_status'],
                topic_is_top = data['topic_is_top'],
                topic_title = data['topic_title'],
                topic_content = data['topic_content'],
                topic_board = new_board,
                topic_author =new_user_profile,
               
                topic_is_pub = data['topic_is_pub'],
                topic_final_comment_time = datetime.datetime.now(),
                topic_final_comment_user = new_user_profile,
            )

        new_topic.save()

        for tag in new_tags:
            if tag != '':
                t = Tag.objects.get(tag_name=tag)
                new_topic.topic_tag.add(t)
                new_topic.save()

        

        return HttpResponse(json.dumps({
                    'status':'success',
                    'id':new_topic.id,
                },ensure_ascii=False),content_type="application/json")

    else:
        tf = TopicForm()

    return HttpResponse(json.dumps({
                    'status':'not post',
                },ensure_ascii=False),content_type="application/json")
开发者ID:seraph0017,项目名称:qa,代码行数:53,代码来源:views.py

示例11: new_topic

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
def new_topic(request, forum_slug):
    forum = get_object_or_404(Forum, slug=forum_slug)
    if request.method == 'GET':
        topic_form = TopicForm()
    elif request.method == 'POST':
        topic_form = TopicForm(request.POST)
        if topic_form.is_valid():
            data = topic_form.cleaned_data
            new_topic = Topic(forum=forum, title=data['title'], user=request.user)
            new_topic.save()
            new_post = Post(topic=new_topic, body=data['body'], user=request.user, ip_address=request.META.get('REMOTE_ADDR'))
            new_post.save()
            return HttpResponseRedirect(new_topic.get_absolute_url())
    return render_to_response('forum/topic_new.html', {'forum':forum, 'form':topic_form}, RequestContext(request))
开发者ID:fdb,项目名称:projecthub,代码行数:16,代码来源:views.py

示例12: save

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
 def save(self):
     if not self.topic:
         ## caution I maybe will modified the name to
         ## tag in the future
         topic = Topic(tag = self.tag,
                 subject = self.cleaned_data['subject'],
                 posted_by = self.user,
                 )
         topic.save()
     else:
         topic = self.topic
     post = Post(topic=topic,tag = self.tag,posted_by=self.user,poster_ip=self.ip,content = self.cleaned_data['content'])
     post.save()
     return post
开发者ID:SeavantUUz,项目名称:Kutoto,代码行数:16,代码来源:forms.py

示例13: form_valid

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
    def form_valid(self, form):
        topic_name = form.cleaned_data['topic']
        post_body = form.cleaned_data['message']
        user = self.request.user

        topic = Topic(forum=self.forum, name=topic_name)
        topic.save()
        post = Post(topic=topic, body=post_body, user=user)
        post.save()
        topic.last_post = post
        topic.save()

        self.success_url = reverse('forums:topic', args=[topic.id])

        return super(TopicCreateView, self).form_valid(form)
开发者ID:shivalashkari,项目名称:django-forums,代码行数:17,代码来源:views.py

示例14: create_topics

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
def create_topics():
    topics = [
        'news',
        'cricket',
        'politics',
        'us presidential elections',
        'movies',
        'travel',
        'funny',
        'love',
        'tennis',
        'badminton',
    ]

    for topic in topics:
        t = Topic(name=topic)
        t.save()
开发者ID:krdeepak,项目名称:djmysite,代码行数:19,代码来源:util.py

示例15: save

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import save [as 别名]
 def save(self):
     topic_post = False
     if not self.topic:
         topic = Topic(forum=self.forum, posted_by=self.user, subject=self.cleaned_data["subject"])
         topic_post = True
         topic.save()
     else:
         topic = self.topic
     post = Post(
         topic=topic,
         posted_by=self.user,
         poster_ip=self.ip,
         message=self.cleaned_data["message"],
         topic_post=topic_post,
     )
     post.save()
     attachments = self.cleaned_data["attachments"]
     post.update_attachments(attachments)
     return post
开发者ID:REDISS,项目名称:LBForum,代码行数:21,代码来源:forms.py


注:本文中的models.Topic.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。