本文整理汇总了Python中messages.models.Message.subject方法的典型用法代码示例。如果您正苦于以下问题:Python Message.subject方法的具体用法?Python Message.subject怎么用?Python Message.subject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类messages.models.Message
的用法示例。
在下文中一共展示了Message.subject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_mail_compose
# 需要导入模块: from messages.models import Message [as 别名]
# 或者: from messages.models.Message import subject [as 别名]
def show_mail_compose(self, request):
try:
if request.is_ajax():
mail_sent_complete = False
if request.method == 'POST':
form = ComposeMailForm(request.POST)
if form.is_valid():
new_mail = Message()
user = request.user
new_mail.id_sender = user
user2 = User.objects.get(id= form.cleaned_data['user_id'])
new_mail.id_receiver = user2
new_mail.datetime = datetime.now()
new_mail.id_conversation = 1
new_mail.text = form.cleaned_data['text']
new_mail.subject = form.cleaned_data['subject']
new_mail.save()
form = ComposeMailForm()
mail_sent_complete = MAILSENTCOMPLETE
else:
form = ComposeMailForm()
week = {0:'Lunes',1:'Martes',2:'Miércoles',3:'Jueves',4:'Viernes',5:'Sábado',6:'Domingo'}
month = {0: 'Enero', 1:'Febrero',2:'Marzo',3:'Abril',4:'Mayo',5:'Junio',6:'Julio',7:'Agosto',8:'Septiembre',9:'Octubre',10:'Noviembre',11:'Diciembre'}
date_time = week[datetime.today().weekday()] + " " + str(datetime.today().day) + "/" + month[datetime.today().month - 1] + " " + str(datetime.today().year)
c = { 'form': form , 'date_t':date_time, 'mail_sent_complete' : mail_sent_complete}
c.update(csrf(request))
return render_to_response('user_send_mail.html', c)
else: return HttpResponseRedirect("/usuarios/profile/mail")
except Exception as e: return self.show_error(e)
示例2: send_complete_message
# 需要导入模块: from messages.models import Message [as 别名]
# 或者: from messages.models.Message import subject [as 别名]
def send_complete_message(self):
msg = Message()
msg.user = self.user
msg.subject = u'Your request was completed'
msg.object = self
msg.save()
return msg
示例3: invite_send_message
# 需要导入模块: from messages.models import Message [as 别名]
# 或者: from messages.models.Message import subject [as 别名]
def invite_send_message(sender, instance, created, **kwargs):
if created:
msg = Message()
msg.subject = ugettext(u'Invitation to join a team')
msg.user = instance.user
msg.object = instance
msg.author = instance.author
msg.save()
示例4: send_to_teams
# 需要导入模块: from messages.models import Message [as 别名]
# 或者: from messages.models.Message import subject [as 别名]
def send_to_teams(self, team_ids, author):
subject = self.cleaned_data['subject']
content = self.cleaned_data['content']
content = u''.join([content, '\n\n', ugettext('This message is from site administrator.')])
users = User.objects.filter(teams__in=team_ids).exclude(pk=author.pk)
for user in users:
m = Message(author=author, user=user)
m.subject = subject
m.content = content
m.save()
return users.count()
示例5: save
# 需要导入模块: from messages.models import Message [as 别名]
# 或者: from messages.models.Message import subject [as 别名]
def save(self):
messages = []
team = self.cleaned_data['team']
languages = self.cleaned_data['languages']
members = team.users.exclude(pk=self.author.pk)
if languages:
members = members.filter(userlanguage__language__in=languages).distinct()
for user in members:
message = Message(user=user)
message.author = self.author
message.content = self.cleaned_data['content']
message.subject = self.cleaned_data['subject']
message.object = team
message.save()
messages.append(message)
return messages