本文整理汇总了Python中tendenci.apps.emails.models.Email.owner方法的典型用法代码示例。如果您正苦于以下问题:Python Email.owner方法的具体用法?Python Email.owner怎么用?Python Email.owner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tendenci.apps.emails.models.Email
的用法示例。
在下文中一共展示了Email.owner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from tendenci.apps.emails.models import Email [as 别名]
# 或者: from tendenci.apps.emails.models.Email import owner [as 别名]
def save(self, *args, **kwargs):
data = self.cleaned_data
subject = ''
subj = data.get('subject', '')
inc_last_name = data.get('personalize_subject_last_name')
inc_first_name = data.get('personalize_subject_first_name')
if inc_first_name and not inc_last_name:
subject = '[firstname] ' + subj
elif inc_last_name and not inc_first_name:
subject = '[lastname] ' + subj
elif inc_first_name and inc_last_name:
subject = '[firstname] [lastname] ' + subj
else:
subject = subj
nl = super(OldGenerateForm, self).save(*args, **kwargs)
nl.subject = subject
nl.actionname = subject
nl.date_created = datetime.datetime.now()
nl.send_status = 'draft'
if nl.default_template:
template = render_to_string(nl.default_template, context_instance=RequestContext(self.request))
email_content = nl.generate_newsletter(self.request, template)
email = Email()
email.subject = subject
email.body = email_content
email.sender = self.request.user.email
email.sender_display = self.request.user.profile.get_name()
email.reply_to = self.request.user.email
email.creator = self.request.user
email.creator_username = self.request.user.username
email.owner = self.request.user
email.owner_username = self.request.user.username
email.save()
nl.email = email
nl.save()
return nl