當前位置: 首頁>>代碼示例>>Python>>正文


Python EmailMessage.scheduled_date_type方法代碼示例

本文整理匯總了Python中myrobogals.rgmessages.models.EmailMessage.scheduled_date_type方法的典型用法代碼示例。如果您正苦於以下問題:Python EmailMessage.scheduled_date_type方法的具體用法?Python EmailMessage.scheduled_date_type怎麽用?Python EmailMessage.scheduled_date_type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在myrobogals.rgmessages.models.EmailMessage的用法示例。


在下文中一共展示了EmailMessage.scheduled_date_type方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: writeemail

# 需要導入模塊: from myrobogals.rgmessages.models import EmailMessage [as 別名]
# 或者: from myrobogals.rgmessages.models.EmailMessage import scheduled_date_type [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()
#.........這裏部分代碼省略.........
開發者ID:CodeMontage,項目名稱:myrobogals,代碼行數:103,代碼來源:views.py

示例2: writeemail

# 需要導入模塊: from myrobogals.rgmessages.models import EmailMessage [as 別名]
# 或者: from myrobogals.rgmessages.models.EmailMessage import scheduled_date_type [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)
#.........這裏部分代碼省略.........
開發者ID:MeidaPoc,項目名稱:myrobogals,代碼行數:103,代碼來源:views.py


注:本文中的myrobogals.rgmessages.models.EmailMessage.scheduled_date_type方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。