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


Python models.Topic类代码示例

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


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

示例1: post

    def post(self):
        creator = users.get_current_user()
        title = self.request.get('title')
        descrip = self.request.get('descrip')

        start = util.convert_htmldatetime(self.request.get('start'))
        end = util.convert_htmldatetime(self.request.get('end'))
        slot_minutes = int(self.request.get('slot_minutes'))

        topic = Topic(
            creator=creator,
            title=title,
            descrip=descrip,
            start=start,
            end=end,
            slot_minutes=slot_minutes)
        topic.put()

        # Now create slots
        current_slot = start
        while (current_slot < end):
            slot = TopicSlot(start=current_slot, topic=topic)
            slot.put()
            current_slot += datetime.timedelta(minutes=slot_minutes)
        self.redirect(topic.full_link)
开发者ID:djensenius,项目名称:hangout-scheduler,代码行数:25,代码来源:pages.py

示例2: store

    def store(self, topic_name, article_entry_list):
        """Stores the article entries in the database.

        :param topic_name The name of the topic
        :param article_entry_list The list of entries of this topic
        """

        try:
            # Try to retrieve the topic to see if it exists already
            topic = Topic.get(Topic.name == topic_name)
        except Topic.DoesNotExist:
            # If not, create it
            topic = Topic.create(name=topic_name)

        # Go through all the articles in this topic
        for article_entry in article_entry_list:
            article_name = article_entry.subject

            # If there is no subject, it means the article is corrupted
            # therefore we skip it
            if not article_name:
                continue

            # Create the files with the content
            # Overwrite existing files
            try:
                Article.create(topic=topic, subject=article_name,
                               body=article_entry.body)
            except Article.DoesNotExist:
                pass
开发者ID:QFAPP,项目名称:QF,代码行数:30,代码来源:__init__.py

示例3: recursive_copy_topic_list_structure

def recursive_copy_topic_list_structure(parent, topic_list_part):
    delete_topics = {}
    for topic_dict in topic_list_part:
        logging.info(topic_dict["name"])
        if "playlist" in topic_dict:
            topic = Topic.get_by_title_and_parent(topic_dict["name"], parent)
            if topic:
                logging.info(topic_dict["name"] + " is already created")
            else:
                version = TopicVersion.get_edit_version()
                root = Topic.get_root(version)
                topic = Topic.get_by_title_and_parent(topic_dict["playlist"], root)
                if topic:
                    delete_topics[topic.key()] = topic
                    logging.info("copying %s to parent %s" %
                                (topic_dict["name"], parent.title))
                    topic.copy(title=topic_dict["name"], parent=parent,
                               standalone_title=topic.title)
                else:
                    logging.error("Topic not found! %s" % (topic_dict["playlist"]))
        else:
            topic = Topic.get_by_title_and_parent(topic_dict["name"], parent)
            if topic:
                logging.info(topic_dict["name"] + " is already created")
            else:
                logging.info("adding %s to parent %s" %
                             (topic_dict["name"], parent.title))
                topic = Topic.insert(title=topic_dict["name"], parent=parent)

        if "items" in topic_dict:
            delete_topics.update(
                recursive_copy_topic_list_structure(topic,
                                                    topic_dict["items"]))

    return delete_topics
开发者ID:di445,项目名称:server,代码行数:35,代码来源:topics.py

示例4: save

 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()
     attachments = self.cleaned_data['attachments']
     post.update_attachments(attachments)
     return post
开发者ID:macdylan,项目名称:LBForum,代码行数:25,代码来源:forms.py

示例5: new_topic

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,代码行数:25,代码来源:views.py

示例6: writeTopic

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,代码行数:8,代码来源:views.py

示例7: AddTopicForm

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,代码行数:9,代码来源:forms.py

示例8: test_postSave

	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,代码行数:9,代码来源:tests.py

示例9: saveTopic

 def saveTopic(self):
     topic = Topic()
     topic.class_type = self.class_type.data
     topic.class_id = int(self.class_id.data)
     topic.subject = self.subject.data
     topic.content = self.content.data
     topic.project_id = self.project.id
     topic.user_id = self.user.id
     current_time = int(time.time())
     topic.created_at = current_time
     topic.updated_at = current_time
     db.session.add(topic)
     db.session.commit()
     project = topic.project
     for atta_id in self.attachments:
         atta = Attachment.query.get(atta_id)
         atta.topic_id = topic.id
         atta.project_id = topic.project_id
         atta.root_class = topic.class_type
         if topic.class_id == 0:
             atta.root_id = topic.id
         else:
             atta.root_id = topic.class_id
         db.session.commit()
         project.file_count += 1
     db.session.commit()
     return topic
开发者ID:Red54,项目名称:Sophia,代码行数:27,代码来源:forms.py

示例10: pyforum_view

 def pyforum_view(self):
     topics = Topic.objects
     form = Form(self.request,schema=TopicSchema())
     if form.validate():
         context = {'title' : form.data['title']}
         Topic.add(context)
         return HTTPFound(location='/list')
     return {'title': 'List View PyForum',
             'topics':topics,
             'form' : FormRenderer(form)
         }
开发者ID:tgonzales,项目名称:pyramid-forum,代码行数:11,代码来源:views.py

示例11: discussion

def discussion(topic_key):
    messages = None
    if topic_key:
        topic = Topic.get(topic_key)
        if not topic:
            flash('No topic found', 'error')
            return redirect(url_for('index'))
        child_topics = []
        for child_topic_key in topic.child_topics:
            child_topics.append(Topic.get(child_topic_key))
        messages = Message.all().filter('topic', topic).order('-created_at').fetch(limit=50)
    return render_template('discussion.html', messages=messages, topic=topic, child_topics=child_topics)
开发者ID:ouxuedong,项目名称:dod-app,代码行数:12,代码来源:main.py

示例12: save_topic

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,代码行数:13,代码来源:views.py

示例13: addTopic

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,代码行数:9,代码来源:dbutils.py

示例14: publish_api

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,代码行数:51,代码来源:views.py

示例15: save

 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,代码行数:14,代码来源:forms.py


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