本文整理汇总了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
示例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,
})