本文整理汇总了Python中tendenci.core.perms.utils.get_notice_recipients函数的典型用法代码示例。如果您正苦于以下问题:Python get_notice_recipients函数的具体用法?Python get_notice_recipients怎么用?Python get_notice_recipients使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_notice_recipients函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: delete
def delete(request, id, template_name="profiles/delete.html"):
user = get_object_or_404(User, pk=id)
try:
profile = Profile.objects.get(user=user)
except:
profile = None
if not has_perm(request.user,'profiles.delete_profile',profile): raise Http403
if request.method == "POST":
recipients = get_notice_recipients('module', 'users', 'userrecipients')
if recipients:
if notification:
extra_context = {
'profile': profile,
'request': request,
}
notification.send_emails(recipients,'user_deleted', extra_context)
#soft delete
#profile.delete()
#user.delete()
if profile:
profile.status_detail = 'inactive'
profile.save()
user.is_active = False
user.save()
return HttpResponseRedirect(reverse('profile.search'))
return render_to_response(template_name, {'user_this':user, 'profile': profile},
context_instance=RequestContext(request))
开发者ID:repos-python,项目名称:tendenci,代码行数:32,代码来源:views.py
示例3: 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":
EventLog.objects.log(instance=resume)
messages.add_message(request, messages.SUCCESS, _('Successfully deleted %(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_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:BillTheBest,项目名称:tendenci,代码行数:27,代码来源: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: 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
示例6: edit
def edit(request, id=None, form_class=HelpFileForm, template_name="help_files/edit.html"):
help_file = get_object_or_404(HelpFile, pk=id)
if has_perm(request.user,'help_files.change_helpfile', help_file):
if request.method == "POST":
form = form_class(request.POST, instance=help_file, user=request.user)
if form.is_valid():
help_file = form.save(commit=False)
# add all permissions and save the model
help_file = update_perms_and_save(request, form, help_file)
form.save_m2m()
messages.add_message(request, messages.SUCCESS, 'Successfully edited %s' % help_file)
# send notification to administrator(s) and module recipient(s)
recipients = get_notice_recipients('module', 'help_files', 'helpfilerecipients')
# if recipients and notification:
# notification.send_emails(recipients,'help_file_added', {
# 'object': help_file,
# 'request': request,
# })
return HttpResponseRedirect(reverse('help_file.details', args=[help_file.slug]))
else:
form = form_class(instance=help_file, user=request.user)
return render_to_response(template_name, {'help_file': help_file, 'form':form},
context_instance=RequestContext(request))
else:
raise Http403
开发者ID:DeepInTheCode,项目名称:tendenci,代码行数:30,代码来源: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: 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
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例14: 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:legutierr,项目名称:tendenci,代码行数:8,代码来源:utils.py
示例15: 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:jkimma,项目名称:tendenci,代码行数:56,代码来源:views.py
示例16: add
def add(request, form_class=ArticleForm,
category_form_class=CategoryForm,
template_name="articles/add.html"):
content_type = get_object_or_404(ContentType,
app_label='articles',
model='article')
if has_perm(request.user, 'articles.add_article'):
if request.method == "POST":
form = form_class(request.POST, user=request.user)
categoryform = category_form_class(content_type,
request.POST,
prefix='category')
if form.is_valid() and categoryform.is_valid():
article = form.save()
article.update_category_subcategory(
categoryform.cleaned_data['category'],
categoryform.cleaned_data['sub_category']
)
# 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)
initial_category_form_data = {
'app_label': 'articles',
'model': 'article',
'pk': 0,
}
categoryform = category_form_class(content_type,
initial=initial_category_form_data,
prefix='category')
return render_to_response(template_name, {'form': form,
'categoryform': categoryform,},
context_instance=RequestContext(request))
else:
raise Http403
开发者ID:jkimma,项目名称:tendenci,代码行数:50,代码来源:views.py
示例17: save_model
def save_model(self, request, object, form, change):
instance = form.save(commit=False)
# update all permissions and save the model
instance = update_perms_and_save(request, form, instance)
# notifications
if not request.user.profile.is_superuser:
# send notification to administrators
recipients = get_notice_recipients("site", "global", "allnoticerecipients")
if recipients:
if notification:
extra_context = {"object": instance, "request": request}
notification.send_emails(recipients, notice_type, extra_context)
return instance
开发者ID:kaisatec,项目名称:tendenci,代码行数:16,代码来源:admin.py
示例18: delete
def delete(self, *args, **kwargs):
# Related objects
# Import related objects here to prevent circular references
from tendenci.apps.pages.models import Page
from tendenci.addons.events.models import Event
from tendenci.apps.stories.models import Story
pages = Page.objects.filter(header_image=self.pk)
events = Event.objects.filter(image=self.pk)
stories = Story.objects.filter(image=self.pk)
# Set foreign key of related objects to None
for page in pages:
page.header_image = None
page.save()
for event in events:
event.image = None
event.save()
for story in stories:
story.image = None
story.save()
# roll back the transaction to fix the error for postgresql
#"current transaction is aborted, commands ignored until
# end of transaction block"
#connection._rollback() # comment it out because this line of code leads to IntegrityError for files that inherit File's model.
# send notification to administrator(s) and module recipient(s)
if self.file:
recipients = get_notice_recipients('module', 'files', 'filerecipients')
site_display_name = get_setting('site', 'global', 'sitedisplayname')
if self.owner:
owner = self.owner.get_full_name() or self.owner
else:
owner = "Unknown"
if recipients and notification:
notification.send_emails(recipients, 'file_deleted', {
'object': self,
'author': owner,
'SITE_GLOBAL_SITEDISPLAYNAME': site_display_name,
})
# delete actual file; do not save() self.instance
self.file.delete(save=False)
# delete database record
super(File, self).delete(*args, **kwargs)
开发者ID:MariusCC,项目名称:tendenci,代码行数:46,代码来源:models.py
示例19: save_model
def save_model(self, request, object, form, change):
instance = form.save(commit=False)
instance = update_perms_and_save(request, form, instance)
# 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:repos-python,项目名称:tendenci,代码行数:18,代码来源:admin.py
示例20: 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)
EventLog.objects.log(instance=group)
group.delete()
return HttpResponseRedirect(reverse("group.search"))
return render_to_response(template_name, {"group": group}, context_instance=RequestContext(request))
开发者ID:jmichels,项目名称:tendenci,代码行数:20,代码来源:views.py
注:本文中的tendenci.core.perms.utils.get_notice_recipients函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论