当前位置: 首页>>代码示例>>Python>>正文


Python EmailMessage.scheduled方法代码示例

本文整理汇总了Python中myrobogals.rgmessages.models.EmailMessage.scheduled方法的典型用法代码示例。如果您正苦于以下问题:Python EmailMessage.scheduled方法的具体用法?Python EmailMessage.scheduled怎么用?Python EmailMessage.scheduled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在myrobogals.rgmessages.models.EmailMessage的用法示例。


在下文中一共展示了EmailMessage.scheduled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cancelvisit

# 需要导入模块: from myrobogals.rgmessages.models import EmailMessage [as 别名]
# 或者: from myrobogals.rgmessages.models.EmailMessage import scheduled [as 别名]
def cancelvisit(request, visit_id):
    if not request.user.is_staff:
        raise Http404
    chapter = request.user.chapter
    v = get_object_or_404(SchoolVisit, pk=visit_id)
    if (v.chapter != chapter) and not request.user.is_superuser:
        raise Http404
    if request.method == 'POST':
        cancelform = CancelForm(request.POST, user=request.user, visit=v)
        if cancelform.is_valid():
            data = cancelform.cleaned_data
            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
            message.from_name = chapter.name
            message.scheduled = False

            # 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()

            # Send to everyone who has been invited
            id_list = EventAttendee.objects.filter(event=v.id, rsvp_status=2).values_list('user_id')
            users = User.objects.filter(id__in=id_list, is_active=True, email_reminder_optin=True)

            for one_user in users:
                recipient = EmailRecipient()
                recipient.message = message
                recipient.user = one_user
                recipient.to_name = one_user.get_full_name()
                recipient.to_address = one_user.email
                recipient.save()

            message.status = 0
            message.save()
            Event.objects.filter(id=v.id).delete()
            messages.success(request, message=unicode(_("Visit cancelled successfully")))
            return HttpResponseRedirect('/teaching/list/')
    else:
        cancelform = CancelForm(None, user=request.user, visit=v)
    return render_to_response('visit_cancel.html', {'cancelform': cancelform, 'visit_id': visit_id},
                              context_instance=RequestContext(request))
开发者ID:robogals,项目名称:myrobogals,代码行数:50,代码来源:eventvisit.py

示例2: rsvpemail

# 需要导入模块: from myrobogals.rgmessages.models import EmailMessage [as 别名]
# 或者: from myrobogals.rgmessages.models.EmailMessage import scheduled [as 别名]
def rsvpemail(request, conf_id):
	# Superuser check
	if not request.user.is_superuser:
		raise Http404
    
	conf = get_object_or_404(Conference, pk=conf_id)
	chapter = request.user.chapter
	
	# Determine if form has been POSTed back
	if request.method == 'POST':
		# Validate email form data
		emailform = EmailAttendeesForm(request.POST, conference=conf, user=request.user)
		if emailform.is_valid():
			data = emailform.cleaned_data
			
			# Set up message
			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 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()
				
			message.scheduled = False
				
			# 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()
			
			
			# Start processing recipient list
			# Insert choices for attending, not attending etc here
			if request.POST['invitee_type'] == '1':	# All
				# Using `ConferenceAttendee`
				users = ConferenceAttendee.objects.filter(conference=conf.id)
		
				# Using `User`
				# id_list = ConferenceAttendee.objects.filter(conference=conf.id).values_list('user_id')
				# users = User.objects.filter(id__in = id_list, is_active=True, email_reminder_optin=True).order_by('last_name')
			elif request.POST['invitee_type'] == '2': # Selected
				users = data['memberselect']

			for one_user in users:
				recipient = EmailRecipient()
				recipient.message = message
				recipient.to_address = one_user.email
				
				# Using `ConferenceAttendee`
				recipient.user = one_user.user
				recipient.to_name = one_user.full_name()
				
				# Using `User`
				# recipient.user = one_user
				# recipient.to_name = one_user.get_full_name()

				recipient.save()
			
			# Send message
			message.status = 0
			message.save()
			
			request.user.message_set.create(message=unicode(_("Email sent successfully")))
			return HttpResponseRedirect('/conferences/' + str(conf.pk) + '/')
	else:
		emailform = EmailAttendeesForm(None, conference=conf, user=request.user)
	
	
	# Display email form
	return render_to_response('conf_rsvp_email.html', {'conf': conf, 'emailform': emailform}, context_instance=RequestContext(request))
开发者ID:MeidaPoc,项目名称:myrobogals,代码行数:81,代码来源:views.py

示例3: writeemail

# 需要导入模块: from myrobogals.rgmessages.models import EmailMessage [as 别名]
# 或者: from myrobogals.rgmessages.models.EmailMessage import scheduled [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

示例4: emailvisitattendees

# 需要导入模块: from myrobogals.rgmessages.models import EmailMessage [as 别名]
# 或者: from myrobogals.rgmessages.models.EmailMessage import scheduled [as 别名]
def emailvisitattendees(request, visit_id):
    if not request.user.is_staff:
        raise Http404
    chapter = request.user.chapter
    v = get_object_or_404(SchoolVisit, pk=visit_id)
    if (v.chapter != chapter) and not request.user.is_superuser:
        raise Http404
    if request.method == 'POST':
        emailform = EmailAttendeesForm(request.POST, user=request.user, visit=v)
        if emailform.is_valid():
            data = emailform.cleaned_data

            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
            message.from_name = chapter.name
            message.scheduled = False

            # 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()

            # Start processing recipient list
            # Send to all invitees
            if request.POST['invitee_type'] == '1':
                id_list = EventAttendee.objects.filter(event=v.id).values_list('user_id')
                users = User.objects.filter(id__in=id_list, is_active=True, email_reminder_optin=True)
            # Send to invitees who have RSVP'd as attending
            elif request.POST['invitee_type'] == '2':
                id_list = EventAttendee.objects.filter(event=v.id, rsvp_status=2).values_list('user_id')
                users = User.objects.filter(id__in=id_list, is_active=True, email_reminder_optin=True)
            # Send to invitees who have RSVP'd as not attending
            elif request.POST['invitee_type'] == '3':
                id_list = EventAttendee.objects.filter(event=v.id, rsvp_status=4).values_list('user_id')
                users = User.objects.filter(id__in=id_list, is_active=True, email_reminder_optin=True)
            # Send to invitees who have yet to RSVP
            elif request.POST['invitee_type'] == '4':
                id_list = EventAttendee.objects.filter(event=v.id, rsvp_status=1).values_list('user_id')
                users = User.objects.filter(id__in=id_list, is_active=True, email_reminder_optin=True)
            # Send to specifically selected users
            elif request.POST['invitee_type'] == '5':
                users = data['memberselect']

            for one_user in users:
                recipient = EmailRecipient()
                recipient.message = message
                recipient.user = one_user
                recipient.to_name = one_user.get_full_name()
                recipient.to_address = one_user.email
                recipient.save()

            message.status = 0
            message.save()

            messages.success(request, message=unicode(_("Email sent succesfully")))
            return HttpResponseRedirect('/teaching/' + str(v.pk) + '/')
    else:
        emailform = EmailAttendeesForm(None, user=request.user, visit=v)
    return render_to_response('visit_email.html', {'emailform': emailform, 'visit_id': visit_id},
                              context_instance=RequestContext(request))
开发者ID:robogals,项目名称:myrobogals,代码行数:68,代码来源:eventvisit.py

示例5: writeemail

# 需要导入模块: from myrobogals.rgmessages.models import EmailMessage [as 别名]
# 或者: from myrobogals.rgmessages.models.EmailMessage import scheduled [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方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。