本文整理汇总了Python中myrobogals.rgmessages.models.EmailMessage.content_subtype方法的典型用法代码示例。如果您正苦于以下问题:Python EmailMessage.content_subtype方法的具体用法?Python EmailMessage.content_subtype怎么用?Python EmailMessage.content_subtype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myrobogals.rgmessages.models.EmailMessage
的用法示例。
在下文中一共展示了EmailMessage.content_subtype方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: writeemail
# 需要导入模块: from myrobogals.rgmessages.models import EmailMessage [as 别名]
# 或者: from myrobogals.rgmessages.models.EmailMessage import content_subtype [as 别名]
def writeemail(request):
memberstatustypes = MemberStatusType.objects.all()
if not request.user.is_staff:
raise Http404
if request.method == 'POST':
typesel = request.POST['type']
schedsel = request.POST['scheduling']
statussel = request.POST['status']
if 'step' in request.POST:
if request.POST['step'] == '1':
emailform = WriteEmailForm(request.POST, user=request.user)
request.session['emailform'] = emailform
elif request.POST['step'] == '2':
if 'emailform' not in request.session:
raise Http404
emailform = request.session['emailform']
del request.session['emailform']
else:
raise Http404
else:
raise Http404
if emailform.is_valid():
data = emailform.cleaned_data
if request.POST['step'] == '2':
message = EmailMessage()
message.subject = data['subject']
message.body = data['body']
message.from_address = request.user.email
message.reply_address = request.user.email
message.sender = request.user
message.html = True
if request.POST['scheduling'] == '1':
message.scheduled = True
message.scheduled_date = datetime.combine(data['schedule_date'], data['schedule_time'])
try:
message.scheduled_date_type = int(data['schedule_zone'])
except Exception:
message.scheduled_date_type = 1
else:
message.scheduled = False
if request.POST['type'] == '4':
n = data['newsletters']
message.from_name = n.from_name
message.from_address = n.from_email
message.reply_address = n.from_email
message.sender = n.from_user
else:
message.content_subtype = "html"
if int(data['from_type']) == 0:
message.from_name = "Robogals"
elif int(data['from_type']) == 1:
message.from_name = request.user.chapter.name
else:
message.from_name = request.user.get_full_name()
# Don't send it yet until the recipient list is done
message.status = -1
# Save to database so we get a value for the primary key,
# which we need for entering the recipient entries
message.save()
if request.POST['type'] == '1':
if request.user.is_superuser:
# "Email all members worldwide" feature disabled Nov 2010 - too much potential for abuse.
# Can be re-enabled by uncommenting the following line, commenting the exception,
# and removing the disabled tag from the relevant radio button in email_write.html
#users = User.objects.filter(chapter__in=data['chapters'], is_active=True, email_chapter_optin=True)
raise Exception
else:
users = User.objects.filter(chapter=request.user.chapter, is_active=True, email_chapter_optin=True).exclude(email='')
elif request.POST['type'] == '2':
if request.user.is_superuser:
users = User.objects.filter(chapter__in=data['chapters_exec'], is_active=True, is_staff=True).exclude(email='')
else:
users = User.objects.filter(chapter=request.user.chapter, is_active=True, is_staff=True).exclude(email='')
elif request.POST['type'] == '5':
ul = data['list']
users = ul.users.all().exclude(email='')
elif request.POST['type'] == '4':
if request.user.is_superuser:
# Special rule for The Amplifier
if data['newsletters'].pk == 1:
users = User.objects.filter(is_active=True, email_newsletter_optin=True).exclude(email='')
else:
users = User.objects.none()
else:
users = data['recipients']
usersfiltered = []
if statussel != '0' and request.POST['type'] != '4':
for one_user in users:
if one_user.membertype().pk == int(statussel):
if request.POST['step'] == '1':
usersfiltered.append(one_user)
else:
if str(one_user.pk) in request.POST.keys():
recipient = EmailRecipient()
#.........这里部分代码省略.........
示例2: writeemail
# 需要导入模块: from myrobogals.rgmessages.models import EmailMessage [as 别名]
# 或者: from myrobogals.rgmessages.models.EmailMessage import content_subtype [as 别名]
def writeemail(request):
memberstatustypes = MemberStatusType.objects.all()
if not request.user.is_staff:
raise Http404
if request.method == 'POST':
typesel = request.POST['type']
schedsel = request.POST['scheduling']
statussel = request.POST['status']
if 'step' in request.POST:
if request.POST['step'] == '1':
emailform = WriteEmailForm(request.POST, user=request.user)
request.session['emailid'] = datetime.utcnow().strftime('%y%m%d%H%M%S')
request.session['emailform'] = emailform
elif request.POST['step'] == '2':
if ('emailform' not in request.session) or ('emailid' not in request.session):
if 'emailform' in request.session:
del request.session['emailform']
if 'emailid' in request.session:
del request.session['emailid']
raise Http404
if request.session['emailid'] != request.POST['emailid']:
raise Http404
warning = False
msg = ''
maxfilesize = 10
maxfilesetting = MessagesSettings.objects.filter(key='maxuploadfilesize')
if maxfilesetting:
maxfilesize = int(maxfilesetting[0].value)
for f in request.FILES.getlist('upload_files'):
if (f.name.__len__() > 70):
msg += '<br>File name: "' + f.name + '" is longer than 70 characters'
warning = True
if (f.size > maxfilesize * 1024*1024):
msg += '<br>File: "' + f.name + '" is larger than ' + str(maxfilesize) + ' MB'
warning = True
if warning:
del request.session['emailform']
del request.session['emailid']
request.user.message_set.create(message=unicode(_('- Can not upload files. Reason(s): %s' % msg)))
return HttpResponseRedirect('/messages/email/write/')
emailform = request.session['emailform']
del request.session['emailform']
del request.session['emailid']
else:
raise Http404
else:
raise Http404
if emailform.is_valid():
data = emailform.cleaned_data
if request.POST['step'] == '2':
message = EmailMessage()
message.subject = data['subject']
if data['header_list']:
hl = data['header_list']
message.body = hl.upper_body + data['body'] + hl.lower_body
else:
message.body = data['body']
message.from_address = request.user.email
message.reply_address = request.user.email
message.sender = request.user
message.html = True
if request.POST['scheduling'] == '1':
message.scheduled = True
message.scheduled_date = datetime.combine(data['schedule_date'], data['schedule_time'])
try:
message.scheduled_date_type = int(data['schedule_zone'])
except Exception:
message.scheduled_date_type = 1
else:
message.scheduled = False
if request.POST['type'] == '4':
n = data['newsletters']
message.from_name = n.from_name
message.from_address = n.from_email
message.reply_address = n.from_email
message.sender = n.from_user
else:
message.content_subtype = "html"
if int(data['from_type']) == 0:
message.from_name = "Robogals"
elif int(data['from_type']) == 1:
message.from_name = request.user.chapter.name
else:
message.from_name = request.user.get_full_name()
# Don't send it yet until the recipient list is done
message.status = -1
# Save to database so we get a value for the primary key,
# which we need for entering the recipient entries
message.save()
if request.POST['type'] == '1':
if request.user.is_superuser:
# "Email all members worldwide" feature disabled Nov 2010 - too much potential for abuse.
# Can be re-enabled by uncommenting the following line, commenting the exception,
# and removing the disabled tag from the relevant radio button in email_write.html
#users = User.objects.filter(chapter__in=data['chapters'], is_active=True, email_chapter_optin=True)
#.........这里部分代码省略.........