本文整理汇总了Python中tendenci.apps.notifications.models.send_emails函数的典型用法代码示例。如果您正苦于以下问题:Python send_emails函数的具体用法?Python send_emails怎么用?Python send_emails使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_emails函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: send_welcome_email
def send_welcome_email(user):
"""
Send email to user account.
Expects user account else returns false.
"""
from django.utils.http import int_to_base36
from django.contrib.auth.tokens import default_token_generator
from tendenci.core.site_settings.utils import get_setting
token_generator = default_token_generator
site_url = get_setting("site", "global", "siteurl")
site_name = get_setting("site", "global", "sitedisplayname")
# send new user account welcome email (notification)
send_emails(
[user.email],
"user_welcome",
{
"site_url": site_url,
"site_name": site_name,
"uid": int_to_base36(user.id),
"user": user,
"username": user.username,
"token": token_generator.make_token(user),
},
)
开发者ID:githubber,项目名称:tendenci,代码行数:27,代码来源:utils.py
示例2: group_delete
def group_delete(request, id, template_name="user_groups/delete.html"):
group = get_object_or_404(Group, pk=id)
if not has_perm(request.user,'user_groups.delete_group',group): raise Http403
if request.method == "POST":
# send notification to administrators
recipients = get_notice_recipients('module', 'groups', 'grouprecipients')
if recipients:
if notification:
extra_context = {
'object': group,
'request': request,
}
notification.send_emails(recipients,'group_deleted', extra_context)
log_defaults = {
'event_id' : 163000,
'event_data': '%s (%d) deleted by %s' % (group._meta.object_name, group.pk, request.user),
'description': '%s deleted' % group._meta.object_name,
'user': request.user,
'request': request,
'instance': group,
}
EventLog.objects.log(**log_defaults)
group.delete()
return HttpResponseRedirect(reverse('group.search'))
return render_to_response(template_name, {'group':group},
context_instance=RequestContext(request))
开发者ID:legutierr,项目名称:tendenci,代码行数:31,代码来源:views.py
示例3: delete
def delete(request, id, template_name="committees/delete.html"):
committee = get_object_or_404(Committee, pk=id)
if not has_perm(request.user, 'committees.delete_committee'):
raise Http403
if request.method == "POST":
EventLog.objects.log(instance=committee)
messages.add_message(request, messages.SUCCESS, 'Successfully deleted %s' % committee)
# send notification to administrators
recipients = get_notice_recipients('module', 'committees', 'committeerecipients')
if recipients:
if notification:
extra_context = {
'object': committee,
'request': request,
}
notification.send_emails(recipients, 'committee_deleted', extra_context)
committee.delete()
return HttpResponseRedirect(reverse('committees.search'))
return render_to_response(template_name, {'committee': committee},
context_instance=RequestContext(request))
开发者ID:BIGGANI,项目名称:tendenci,代码行数:25,代码来源:views.py
示例4: add
def add(request, form_class=NewsForm, template_name="news/add.html"):
# check permission
if not has_perm(request.user, 'news.add_news'):
raise Http403
if request.method == "POST":
form = form_class(request.POST, user=request.user)
if form.is_valid():
news = form.save(commit=False)
# update all permissions and save the model
news = update_perms_and_save(request, form, news)
messages.add_message(request, messages.SUCCESS, 'Successfully added %s' % news)
# send notification to administrators
recipients = get_notice_recipients('module', 'news', 'newsrecipients')
if recipients:
if notification:
extra_context = {
'object': news,
'request': request,
}
notification.send_emails(recipients, 'news_added', extra_context)
return HttpResponseRedirect(reverse('news.detail', args=[news.slug]))
else:
form = form_class(user=request.user)
return render_to_response(template_name, {'form': form},
context_instance=RequestContext(request))
开发者ID:eloyz,项目名称:tendenci,代码行数:32,代码来源:views.py
示例5: delete
def delete(request, id, template_name="resumes/delete.html"):
resume = get_object_or_404(Resume, pk=id)
if has_perm(request.user,'resumes.delete_resume'):
if request.method == "POST":
log_defaults = {
'event_id' : 433000,
'event_data': '%s (%d) deleted by %s' % (resume._meta.object_name, resume.pk, request.user),
'description': '%s deleted' % resume._meta.object_name,
'user': request.user,
'request': request,
'instance': resume,
}
EventLog.objects.log(**log_defaults)
messages.add_message(request, messages.SUCCESS, 'Successfully deleted %s' % resume)
# send notification to administrators
recipients = get_notice_recipients('module', 'resumes', 'resumerecipients')
if recipients:
if notification:
extra_context = {
'object': resume,
'request': request,
}
notification.send_emails(recipients,'resume_deleted', extra_context)
resume.delete()
return HttpResponseRedirect(reverse('resume.search'))
return render_to_response(template_name, {'resume': resume},
context_instance=RequestContext(request))
else:
raise Http403
开发者ID:repos-python,项目名称:tendenci,代码行数:35,代码来源:views.py
示例6: delete
def delete(request, id, template_name="pages/delete.html"):
page = get_object_or_404(Page, pk=id)
if not has_perm(request.user, 'pages.delete_page'):
raise Http403
if request.method == "POST":
EventLog.objects.log(instance=page)
messages.add_message(request, messages.SUCCESS,
_('Successfully deleted %(p)s' % { 'p': unicode(page)}))
# send notification to administrators
recipients = get_notice_recipients('module', 'pages', 'pagerecipients')
if recipients:
if notification:
extra_context = {
'object': page,
'request': request,
}
notification.send_emails(recipients, 'page_deleted', extra_context)
# Soft delete
page.status = False
page.status_detail = 'inactive'
page.save()
return HttpResponseRedirect(reverse('page.search'))
return render_to_response(template_name, {'page': page},
context_instance=RequestContext(request))
开发者ID:BillTheBest,项目名称:tendenci,代码行数:29,代码来源:views.py
示例7: add
def add(request, form_class=NewsForm, template_name="news/add.html"):
# check permission
if not has_perm(request.user, "news.add_news"):
raise Http403
if request.method == "POST":
form = form_class(request.POST, request.FILES, user=request.user)
if form.is_valid():
news = form.save(commit=False)
# update all permissions and save the model
news = update_perms_and_save(request, form, news)
# save photo
photo = form.cleaned_data["photo_upload"]
if photo:
news.save(photo=photo)
assign_files_perms(news, files=[news.thumbnail])
messages.add_message(request, messages.SUCCESS, "Successfully added %s" % news)
# send notification to administrators
recipients = get_notice_recipients("module", "news", "newsrecipients")
if recipients:
if notification:
extra_context = {"object": news, "request": request}
notification.send_emails(recipients, "news_added", extra_context)
return HttpResponseRedirect(reverse("news.detail", args=[news.slug]))
else:
form = form_class(user=request.user)
return render_to_response(template_name, {"form": form}, context_instance=RequestContext(request))
开发者ID:githubber,项目名称:tendenci,代码行数:33,代码来源:views.py
示例8: save_model
def save_model(self, request, object, form, change):
instance = form.save(commit=False)
instance = update_perms_and_save(request, form, instance)
if instance.meta:
meta = instance.meta
else:
meta = MetaTags()
meta.title = form.cleaned_data['meta_title']
meta.description = form.cleaned_data['meta_description']
meta.keywords = form.cleaned_data['meta_keywords']
meta.canonical_url = form.cleaned_data['meta_canonical_url']
meta.save()
instance.meta = meta
instance.save()
# notifications
if not request.user.profile.is_superuser:
# send notification to administrators
recipients = get_notice_recipients('module', 'pages', 'pagerecipients')
notice_type = 'page_added'
if change: notice_type = 'page_edited'
if recipients:
if notification:
extra_context = {
'object': instance,
'request': request,
}
notification.send_emails(recipients, notice_type, extra_context)
return instance
开发者ID:MariusCC,项目名称:tendenci,代码行数:32,代码来源:admin.py
示例9: delete
def delete(request, id, template_name="directories/delete.html"):
directory = get_object_or_404(Directory, pk=id)
if has_perm(request.user,'directories.delete_directory'):
if request.method == "POST":
msg_string = 'Successfully deleted %s' % directory
messages.add_message(request, messages.SUCCESS, _(msg_string))
# send notification to administrators
recipients = get_notice_recipients('module', 'directories', 'directoryrecipients')
if recipients:
if notification:
extra_context = {
'object': directory,
'request': request,
}
notification.send_emails(recipients,'directory_deleted', extra_context)
directory.delete()
return HttpResponseRedirect(reverse('directory.search'))
return render_to_response(template_name, {'directory': directory},
context_instance=RequestContext(request))
else:
raise Http403
开发者ID:RMUCapstone-MIS590,项目名称:tendenci,代码行数:26,代码来源:views.py
示例10: delete
def delete(request, id, template_name="studygroups/delete.html"):
study_group = get_object_or_404(StudyGroup, pk=id)
if not has_perm(request.user, 'studygroup.delete_studygroup'):
raise Http403
if request.method == "POST":
EventLog.objects.log(instance=study_group)
messages.add_message(request, messages.SUCCESS, 'Successfully deleted %s' % study_group)
# send notification to administrators
recipients = get_notice_recipients('module', 'studygroups', 'studygrouprecipients')
if recipients:
if notification:
extra_context = {
'object': study_group,
'request': request,
}
notification.send_emails(recipients, 'studygroup_deleted', extra_context)
study_group.delete()
return HttpResponseRedirect(reverse('studygroups.search'))
return render_to_response(template_name, {'study_group': study_group},
context_instance=RequestContext(request))
开发者ID:fbates,项目名称:tendenci-site,代码行数:25,代码来源:views.py
示例11: email_member
def email_member(notice, membership, global_context):
user = membership.user
body = notice.email_content
context = membership.get_field_items()
context['membership'] = membership
context.update(global_context)
# corporate member corp_replace_str
if membership.corporate_membership_id:
context['corporate_membership_notice'] = corp_replace_str
if membership.expire_dt:
context.update({
'expire_dt': time.strftime(
"%d-%b-%y %I:%M %p",
membership.expire_dt.timetuple()),
})
if membership.payment_method:
payment_method_name = membership.payment_method.human_name
else:
payment_method_name = ''
context.update({
'member_number': membership.member_number,
'payment_method': payment_method_name,
'referer_url': '%s%s?next=%s' % (site_url, reverse('auth_login'), membership.referer_url),
'membership_link': '%s%s' % (site_url, membership.get_absolute_url()),
'renew_link': '%s%s' % (site_url, membership.get_absolute_url())
})
body = fieldify(body)
body = '%s <br /><br />%s' % (body, get_footer())
context = Context(context)
template = Template(body)
body = template.render(context)
email_recipient = user.email
subject = notice.subject.replace('(name)',
user.get_full_name())
template = Template(subject)
subject = template.render(context)
email_context.update({
'subject':subject,
'content':body})
if notice.sender:
email_context.update({
'sender':notice.sender,
'reply_to':notice.sender})
if notice.sender_display:
email_context.update({'sender_display':notice.sender_display})
notification.send_emails([email_recipient], 'membership_notice_email',
email_context)
if verbosity > 1:
print 'To ', email_recipient, subject
开发者ID:MariusCC,项目名称:tendenci,代码行数:60,代码来源:send_membership_notices.py
示例12: auto_update_paid_object
def auto_update_paid_object(self, request, payment):
"""
Update the object after online payment is received.
"""
from datetime import datetime
try:
from tendenci.apps.notifications import models as notification
except:
notification = None
from tendenci.core.perms.utils import get_notice_recipients
# approve it
if self.renew_entry_id:
self.approve_renewal(request)
else:
self.approve_join(request)
# send notification to administrators
recipients = get_notice_recipients('module', 'corporate_memberships', 'corporatemembershiprecipients')
if recipients:
if notification:
extra_context = {
'object': self,
'request': request,
}
notification.send_emails(recipients,'corp_memb_paid', extra_context)
开发者ID:eloyz,项目名称:tendenci,代码行数:27,代码来源:models.py
示例13: delete
def delete(request, id, template_name="resumes/delete.html"):
resume = get_object_or_404(Resume, pk=id)
if has_perm(request.user, "resumes.delete_resume"):
if request.method == "POST":
log_defaults = {
"event_id": 433000,
"event_data": "%s (%d) deleted by %s" % (resume._meta.object_name, resume.pk, request.user),
"description": "%s deleted" % resume._meta.object_name,
"user": request.user,
"request": request,
"instance": resume,
}
EventLog.objects.log(**log_defaults)
messages.add_message(request, messages.SUCCESS, "Successfully deleted %s" % resume)
# send notification to administrators
recipients = get_notice_recipients("module", "resumes", "resumerecipients")
if recipients:
if notification:
extra_context = {"object": resume, "request": request}
notification.send_emails(recipients, "resume_deleted", extra_context)
resume.delete()
return HttpResponseRedirect(reverse("resume.search"))
return render_to_response(template_name, {"resume": resume}, context_instance=RequestContext(request))
else:
raise Http403
开发者ID:eloyz,项目名称:tendenci,代码行数:31,代码来源:views.py
示例14: add
def add(request, form_class=ArticleForm, template_name="articles/add.html"):
if has_perm(request.user, 'articles.add_article'):
if request.method == "POST":
form = form_class(request.POST, user=request.user)
if form.is_valid():
article = form.save(commit=False)
# add all permissions and save the model
update_perms_and_save(request, form, article)
messages.add_message(request, messages.SUCCESS, 'Successfully added %s' % article)
# send notification to administrator(s) and module recipient(s)
recipients = get_notice_recipients('module', 'articles', 'articlerecipients')
if recipients and notification:
notification.send_emails(recipients, 'article_added', {
'object': article,
'request': request,
})
return HttpResponseRedirect(reverse('article', args=[article.slug]))
else:
form = form_class(user=request.user)
return render_to_response(template_name, {'form': form},
context_instance=RequestContext(request))
else:
raise Http403
开发者ID:repos-python,项目名称:tendenci,代码行数:28,代码来源:views.py
示例15: email_admins_recap
def email_admins_recap(notices, total_sent):
"""Send admins recap after the notices were processed.
"""
recap_recipient = get_admin_emails()
if recap_recipient:
template_name = "corporate_memberships/notices/email_recap.html"
try:
recap_email_content = render_to_string(
template_name,
{'notices': notices,
'total_sent': total_sent,
'site_url': site_url,
'site_display_name': site_display_name,
'site_contact_name': site_contact_name,
'site_contact_email': site_contact_email})
recap_subject = '%s Corporate Membership Notices Distributed' % (
site_display_name)
email_context.update({
'subject':recap_subject,
'content': recap_email_content,
'content_type':"html"})
notification.send_emails(recap_recipient, 'corp_memb_notice_email',
email_context)
except TemplateDoesNotExist:
pass
开发者ID:BIGGANI,项目名称:tendenci,代码行数:26,代码来源:send_corp_membership_notices.py
示例16: send_notifications
def send_notifications(scope, scope_category, name, label, extra_context=None):
"""
a small wrapper for sending notification emails to
recipients specified in site_settings.
"""
recipients = get_notice_recipients(scope, scope_category, name)
if recipients:
send_emails(recipients, label, extra_context)
开发者ID:RMUCapstone-MIS590,项目名称:tendenci,代码行数:8,代码来源:utils.py
示例17: group_add_edit
def group_add_edit(request, group_slug=None,
form_class=GroupForm,
template_name="user_groups/add_edit.html"):
add, edit = False, False
if group_slug:
group = get_object_or_404(Group, slug=group_slug)
if not has_perm(request.user,'user_groups.change_group',group):
raise Http403
title = _("Edit Group")
edit = True
else:
group = None
if not has_perm(request.user,'user_groups.add_group'):raise Http403
title = _("Add Group")
add = True
if request.method == 'POST':
if edit:
form = form_class(request.POST, instance=group, user=request.user)
else:
form = form_class(request.POST, user=request.user)
if form.is_valid():
group = form.save(commit=False)
if not group.id:
group.creator = request.user
group.creator_username = request.user.username
# set up user permission
group.allow_user_view, group.allow_user_edit = form.cleaned_data['user_perms']
group.owner = request.user
group.owner_username = request.user.username
group = form.save()
if add:
# send notification to administrators
recipients = get_notice_recipients('module', 'groups', 'grouprecipients')
if recipients:
if notification:
extra_context = {
'object': group,
'request': request,
}
notification.send_emails(recipients,'group_added', extra_context)
EventLog.objects.log(instance=group)
return HttpResponseRedirect(group.get_absolute_url())
else:
if edit:
form = form_class(instance=group, user=request.user)
else:
form = form_class(user=request.user)
return render_to_response(template_name, {'form':form, 'titie':title, 'group':group}, context_instance=RequestContext(request))
开发者ID:jiwonlee777,项目名称:tendenci,代码行数:56,代码来源:views.py
示例18: send_email_notification
def send_email_notification(notice_name, recipients, extra_context):
"""
Send email notice specified by the notice_name to the recipients.
recipients - a list of emails
"""
try:
from tendenci.apps.notifications import models as notification
except:
notification = None
if notification and recipients:
notification.send_emails(recipients, notice_name, extra_context)
开发者ID:goetzk,项目名称:tendenci,代码行数:11,代码来源:utils.py
示例19: add
def add(request, form_class=ResumeForm, template_name="resumes/add.html"):
can_add_active = has_perm(request.user, 'resumes.add_resume')
if not any([request.user.profile.is_superuser,
can_add_active,
get_setting('module', 'resumes', 'usercanadd'),
(request.user.profile.is_member and get_setting('module', 'resumes', 'userresumesrequiresmembership'))
]):
raise Http403
if request.method == "POST":
form = form_class(request.POST or None, user=request.user)
if form.is_valid():
resume = form.save(commit=False)
# set it to pending if the user does not have add permission
if not can_add_active:
resume.status_detail = 'pending'
# set up the expiration time based on requested duration
now = datetime.now()
resume.expiration_dt = now + timedelta(days=resume.requested_duration)
resume = update_perms_and_save(request, form, resume)
# we need to save instance first since we need the id for the file path
if request.FILES:
resume.resume_file = request.FILES['resume_file']
resume.resume_file.file.seek(0)
resume.save()
EventLog.objects.log(instance=resume)
if request.user.is_authenticated():
messages.add_message(request, messages.SUCCESS, _('Successfully added %(r)s' % {'r':resume}))
# send notification to administrators
recipients = get_notice_recipients('module', 'resumes', 'resumerecipients')
if recipients:
if notification:
extra_context = {
'object': resume,
'request': request,
}
notification.send_emails(recipients,'resume_added', extra_context)
if not request.user.is_authenticated():
return HttpResponseRedirect(reverse('resume.thank_you'))
else:
return HttpResponseRedirect(reverse('resume', args=[resume.slug]))
else:
form = form_class(user=request.user)
return render_to_response(template_name, {'form':form},
context_instance=RequestContext(request))
开发者ID:goetzk,项目名称:tendenci,代码行数:53,代码来源:views.py
示例20: email_script_errors
def email_script_errors(err_msg):
"""Send error message to us if any.
"""
script_recipient = get_script_support_emails()
if script_recipient:
email_context.update({
'subject':'Error Processing Corporate Membership Notices on %s' % (
site_url),
'content':'%s \n\nTime Submitted: %s\n' % (err_msg, nowstr),
'content_type':"text"})
notification.send_emails(script_recipient, 'corp_memb_notice_email',
email_context)
开发者ID:BIGGANI,项目名称:tendenci,代码行数:13,代码来源:send_corp_membership_notices.py
注:本文中的tendenci.apps.notifications.models.send_emails函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论