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


Python Topic.subject方法代码示例

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


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

示例1: saveTopic

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import subject [as 别名]
 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,代码行数:29,代码来源:forms.py

示例2: topic_new

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import subject [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


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