本文整理汇总了Python中userena.utils.get_protocol函数的典型用法代码示例。如果您正苦于以下问题:Python get_protocol函数的具体用法?Python get_protocol怎么用?Python get_protocol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_protocol函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_protocol
def test_get_protocol(self):
""" Test if the correct protocol is returned """
self.failUnlessEqual(get_protocol(), 'http')
userena_settings.USERENA_USE_HTTPS = True
self.failUnlessEqual(get_protocol(), 'https')
userena_settings.USERENA_USE_HTTPS = False
开发者ID:bagbirs,项目名称:django-userena,代码行数:7,代码来源:tests_utils.py
示例2: send_confirmation_email
def send_confirmation_email(self):
# TODO !!!!!!!!!
context = {'user': self.user,
'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES,
'new_email': self.email_unconfirmed,
'protocol': get_protocol(),
'confirmation_key': self.email_confirmation_key,
'site': Site.objects.get_current()}
# Email to the old address, if present
subject_old = render_to_string('userena/emails/confirmation_email_subject_old.txt',
context)
subject_old = ''.join(subject_old.splitlines())
message_old = render_to_string('userena/emails/confirmation_email_message_old.txt',
context)
if self.user.email:
send_mail(subject_old,
message_old,
settings.DEFAULT_FROM_EMAIL,
[self.user.email])
# Email to the new address
subject_new = render_to_string('userena/emails/confirmation_email_subject_new.txt',
context)
subject_new = ''.join(subject_new.splitlines())
message_new = render_to_string('userena/emails/confirmation_email_message_new.txt',
context)
send_mail(subject_new,
message_new,
settings.DEFAULT_FROM_EMAIL,
[self.email_unconfirmed, ])
开发者ID:ouhouhsami,项目名称:localized_classified_ads,代码行数:32,代码来源:models.py
示例3: send_confirmation_email
def send_confirmation_email(self):
"""
Sends an email to confirm the new email address.
This method sends out two emails. One to the new email address that
contains the ``email_confirmation_key`` which is used to verify this
this email address with :func:`UserenaUser.objects.confirm_email`.
The other email is to the old email address to let the user know that
a request is made to change this email address.
"""
context = {
"user": self.user,
"new_email": self.email_unconfirmed,
"protocol": get_protocol(),
"confirmation_key": self.email_confirmation_key,
"site": Site.objects.get_current(),
}
# Email to the old address
subject_old = render_to_string("userena/emails/confirmation_email_subject_old.txt", context)
subject_old = "".join(subject_old.splitlines())
message_old = render_to_string("userena/emails/confirmation_email_message_old.txt", context)
send_mail(subject_old, message_old, settings.DEFAULT_FROM_EMAIL, [self.user.email])
# Email to the new address
subject_new = render_to_string("userena/emails/confirmation_email_subject_new.txt", context)
subject_new = "".join(subject_new.splitlines())
message_new = render_to_string("userena/emails/confirmation_email_message_new.txt", context)
send_mail(subject_new, message_new, settings.DEFAULT_FROM_EMAIL, [self.email_unconfirmed])
开发者ID:stevepm,项目名称:django-userena,代码行数:35,代码来源:models.py
示例4: send_activation_email
def send_activation_email(self):
"""
Sends a activation email to the user.
This email is send when the user wants to activate their newly created
user.
"""
context= {'user': self.user,
'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES,
'protocol': get_protocol(),
'activation_days': userena_settings.USERENA_ACTIVATION_DAYS,
'activation_key': self.activation_key,
'site': Site.objects.get_current()}
subject = render_to_string('userena/emails/activation_email_subject.txt',
context)
subject = ''.join(subject.splitlines())
message = render_to_string('userena/emails/activation_email_message.txt',
context)
try:
send_mail(subject,
message,
settings.DEFAULT_FROM_EMAIL,
[self.user.email,])
except:
pass
开发者ID:nuannuanwu,项目名称:weixiao,代码行数:28,代码来源:models.py
示例5: send_activation_email
def send_activation_email(self):
"""
Sends a activation email to the user.
This email is send when the user wants to activate their newly created
user.
"""
context= {'user': self.user,
'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES,
'protocol': get_protocol(),
'activation_days': userena_settings.USERENA_ACTIVATION_DAYS,
'activation_key': self.activation_key,
'site': Site.objects.get_current()}
subject = render_to_string('userena/emails/activation_email_subject.txt',
context)
subject = ''.join(subject.splitlines())
message = render_to_string('userena/emails/activation_email_message.txt',
context)
# EMRE Modified this to use smtplib. This method doesn't work.
send_mail(subject,
message,
settings.DEFAULT_FROM_EMAIL,
[self.user.email,])
"""msg = ("From: %s\r\nTo: %s\r\nSubject:%s\r\n\r\n%s\r\n"
开发者ID:aladagemre,项目名称:django-userena,代码行数:28,代码来源:models.py
示例6: send_activation_email
def send_activation_email(
self, template="userena/emails/activation_email_message.txt", headers=None, attach_list=[]
):
"""
Sends a activation email to the user.
This email is send when the user wants to activate their newly created
user.
"""
context = {
"user": self.user,
"without_usernames": userena_settings.USERENA_WITHOUT_USERNAMES,
"protocol": get_protocol(),
"activation_days": userena_settings.USERENA_ACTIVATION_DAYS,
"activation_key": self.activation_key,
"site": Site.objects.get_current(),
}
subject = render_to_string("userena/emails/activation_email_subject.txt", context)
subject = "".join(subject.splitlines())
body = render_to_string(template, context)
message = EmailMessage(subject, body, settings.DEFAULT_FROM_EMAIL, [self.user.email], headers=headers)
if template.split(".")[-1] == "html":
message.content_subtype = "html"
for attachment in attach_list:
message.attach(attachment)
message.send()
开发者ID:myaser,项目名称:django-userena,代码行数:33,代码来源:models.py
示例7: send_confirmation_email
def send_confirmation_email(self):
"""
Sends an email to confirm the new email address.
This method sends out two emails. One to the new email address that
contains the ``email_confirmation_key`` which is used to verify this
this email address with :func:`UserenaUser.objects.confirm_email`.
The other email is to the old email address to let the user know that
a request is made to change this email address.
"""
context = {'user': self.user,
'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES,
'new_email': self.email_unconfirmed,
'protocol': get_protocol(),
'confirmation_key': self.email_confirmation_key,
'site': Site.objects.get_current()}
mailer = UserenaConfirmationMail(context=context)
mailer.generate_mail("confirmation", "_old")
if self.user.email:
mailer.send_mail(self.user.email)
mailer.generate_mail("confirmation", "_new")
mailer.send_mail(self.email_unconfirmed)
开发者ID:hsingjun0,项目名称:userena,代码行数:27,代码来源:models.py
示例8: send_invite_email
def send_invite_email(self, promoter):
"""
Sends a invitation email to the user.
This email is sent when a user invites another user to to join.
"""
context = {'user': self.user,
'promoter': promoter,
'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES,
'protocol': get_protocol(),
'activation_days': userena_settings.USERENA_ACTIVATION_DAYS,
'activation_key': self.activation_key,
'site': Site.objects.get_current()}
subject = render_to_string('userena/emails/invitation_email_subject.txt',
context)
subject = ''.join(subject.splitlines())
message = render_to_string('userena/emails/invitation_email_message.txt',
context)
send_mail(subject,
message,
settings.DEFAULT_FROM_EMAIL,
[self.user.email,])
开发者ID:fberger,项目名称:django-userena,代码行数:25,代码来源:models.py
示例9: send_activation_email_with_password
def send_activation_email_with_password(userena_signup_obj, password):
"""
Sends a activation email to the user, along with an
automatically generated password that they need to log in.
This function only exists because userena/models.py's
UserenaSignup.send_activation_email() doesn't have a way to
add custom context.
"""
context= {'user': userena_signup_obj.user,
'protocol': get_protocol(),
'activation_days': userena_settings.USERENA_ACTIVATION_DAYS,
'activation_key': userena_signup_obj.activation_key,
'site': Site.objects.get_current(),
'password': password}
subject = render_to_string('userena/emails/activation_email_subject.txt',
context)
subject = ''.join(subject.splitlines())
message = render_to_string('userena/emails/activation_email_message.txt',
context)
send_mail(subject,
message,
settings.DEFAULT_FROM_EMAIL,
[userena_signup_obj.user.email,])
开发者ID:DevangS,项目名称:CoralNet,代码行数:26,代码来源:utils.py
示例10: send_message_notification
def send_message_notification(sender, instance, **kwargs):
"""
Send email when user receives a new message. This email contains the full text
and a link to read it online.
We trigger this when a MessageRecipient is saved and not when a Message is
saved because umessages first saves a message and then adds its recipients,
so when a Message is saved, it doesn't yet have a list of recipients.
"""
if not instance.user.email:
# Email can be missing for users registered with Twitter
# or LinkedIn
return
params = {"sender": instance.message.sender.username, "body": instance.message.body}
message_url_path = reverse("userena_umessages_detail", kwargs={"username": params["sender"]})
params["message_url"] = "%s://%s%s" % (get_protocol(), Site.objects.get_current(), message_url_path)
subject = _(u"New message from %(sender)s on Imagination For People") % params
message = render_to_string("umessages/message_notification.txt", params)
recipient = instance.user.email
# XXX Resets the Content-Transfer-Encoding in email header
# Avoids bad encoding of UTF-8 body
# See https://code.djangoproject.com/ticket/3472
from email import Charset
Charset.add_charset("utf-8", Charset.SHORTEST, "utf-8", "utf-8")
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [recipient])
开发者ID:LittleFancy,项目名称:imaginationforpeople,代码行数:31,代码来源:models.py
示例11: send_message_notification
def send_message_notification(sender, instance, **kwargs):
"""
Send email when user receives a new message. This email contains the full text
and a link to read it online.
We trigger this when a MessageRecipient is saved and not when a Message is
saved because umessages first saves a message and then adds its recipients,
so when a Message is saved, it doesn't yet have a list of recipients.
"""
if not instance.user.email:
# Email can be missing for users registered with Twitter
# or LinkedIn
return
params = {
'sender': instance.message.sender.username,
'body': instance.message.body,
}
message_url_path = reverse('userena_umessages_detail',
kwargs={'username': params['sender']})
params['message_url'] = "%s://%s%s" % (
get_protocol(),
Site.objects.get_current(),
message_url_path)
subject = _(u'Message from %(sender)s') % params
message = render_to_string('umessages/message_notification.txt', params)
recipient = instance.user.email
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [recipient])
开发者ID:Retenodus,项目名称:imaginationforpeople,代码行数:31,代码来源:models.py
示例12: send_activation_email
def send_activation_email(self):
"""
Sends a activation email to the user.
This email is send when the user wants to activate their newly created
user.
"""
context = {'user': self.user,
'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES,
'protocol': get_protocol(),
'activation_days': userena_settings.USERENA_ACTIVATION_DAYS,
'activation_key': self.activation_key,
'site': Site.objects.get_current(),
'settings': settings}
subject = render_to_string(userena_settings.USERENA_ACTIVATION_EMAIL_SUBJECT_TEMPLATE,
context)
subject = ''.join(subject.splitlines())
message = render_to_string(userena_settings.USERENA_ACTIVATION_EMAIL_MESSAGE_TEMPLATE,
context)
send_mail_module = importlib.import_module(userena_settings.USERENA_SEND_EMAIL_MODULE)
send_mail_module.send_mail(subject,
message,
settings.DEFAULT_FROM_EMAIL,
[self.user.email, ])
开发者ID:adamfeuer,项目名称:django-userena,代码行数:27,代码来源:models.py
示例13: send_approval_email
def send_approval_email(self):
"""
Sends an approval email to the user.
This email is sent when USERENA_MODERATE_REGISTRATION, after an admin
has approved the registration.
"""
context= {'user': self.user,
'protocol': get_protocol(),
'site': Site.objects.get_current()}
subject = render_to_string('userena/emails/approval_email_subject.txt',
context)
subject = ''.join(subject.splitlines())
message = render_to_string('userena/emails/approval_email_message.txt',
context)
if userena_settings.USERENA_HTML_EMAIL:
message_html = render_to_string('userena/emails/approval_email_message.html',
context)
else:
message_html = None
send_mail(subject,
message,
message_html,
settings.DEFAULT_FROM_EMAIL,
[self.user.email,])
开发者ID:bioinformatics-ua,项目名称:django-userena,代码行数:31,代码来源:models.py
示例14: send_activation_email
def send_activation_email(self):
"""
Sends a activation email to the user.
This email is sent_activation_email when the user wants to activate their newly created
user.
"""
context = {'user': self.user,
'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES,
'protocol': get_protocol(),
'activation_days': userena_settings.USERENA_ACTIVATION_DAYS,
'activation_key': self.activation_key,
'site': Site.objects.get_current()}
mailer = UserenaConfirmationMail(context=context)
mailer.generate_mail("activation")
mailer.send_mail(self.user.email)
#Send email to admins with the same message
emaillist = []
if settings.USERENA_ADMIN_MODERATION:
for k, v in settings.ADMINS:
emaillist.append(v)
send_mail(settings.SITE_NAME + " - Activation done",
message,
message_html,
settings.DEFAULT_FROM_EMAIL,
emaillist)
开发者ID:bioinformatics-ua,项目名称:django-userena,代码行数:30,代码来源:models.py
示例15: send_activation_email
def send_activation_email(self, first_name = '', last_name = ''):
"""
Sends a activation email to the user.
This email is send when the user wants to activate their newly created
user.
"""
context = {'user': self.user,
'first_name': first_name,
'last_name': last_name,
'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES,
'protocol': get_protocol(),
'activation_days': userena_settings.USERENA_ACTIVATION_DAYS,
'activation_key': self.activation_key,
'site': Site.objects.get_current()}
subject = render_to_string('userena/emails/activation_email_subject.txt',
context)
subject = ''.join(subject.splitlines())
text_content = render_to_string('userena/emails/activation_email_message.txt',
context)
html_content = render_to_string('userena/emails/activation_email_message.html',
context)
email = EmailMultiAlternatives(subject, text_content, settings.DEFAULT_FROM_EMAIL, [self.user.email, ])
email.attach_alternative(html_content, "text/html")
email.send()
开发者ID:ksuralta,项目名称:django-userena,代码行数:28,代码来源:models.py
示例16: send_confirmation_email
def send_confirmation_email(self):
"""
Sends an email to confirm the new email address.
This method sends out two emails. One to the new email address that
contains the ``email_confirmation_key`` which is used to verify this
this email address with :func:`UserenaUser.objects.confirm_email`.
The other email is to the old email address to let the user know that
a request is made to change this email address.
"""
context = {'user': self.user,
'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES,
'new_email': self.email_unconfirmed,
'protocol': get_protocol(),
'confirmation_key': self.email_confirmation_key,
'site': Site.objects.get_current()}
# Email to the old address, if present
subject_old = render_to_string('userena/emails/confirmation_email_subject_old.txt',
context)
subject_old = ''.join(subject_old.splitlines())
message_old_text = render_to_string('userena/emails/confirmation_email_message_old.txt',
context)
message_old_html = render_to_string('userena/emails/confirmation_email_message_old.html',
context)
if self.user.email:
subject, from_email, to = subject_old, settings.DEFAULT_FROM_EMAIL, self.user.email
text_content = message_old_text
html_content = message_old_html
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
msg.send()
# send_mail(subject_old,
# message_old,
# settings.DEFAULT_FROM_EMAIL,
# [self.user.email])
# Email to the new address
subject_new = render_to_string('userena/emails/confirmation_email_subject_new.txt',
context)
subject_new = ''.join(subject_new.splitlines())
message_new_text = render_to_string('userena/emails/confirmation_email_message_new.txt',
context)
message_new_html = render_to_string('userena/emails/confirmation_email_message_new.html',
context)
subject, from_email, to = subject_new, settings.DEFAULT_FROM_EMAIL, self.user.email
text_content = message_new_text
html_content = message_new_html
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
msg.send()
开发者ID:beshrkayali,项目名称:django-userena,代码行数:58,代码来源:models.py
示例17: send_pending_activation_email
def send_pending_activation_email(self, organization=""):
"""
Sends a email to the user after signup.
This email is sent_pending_activation_email when the user created a new user.
"""
context = {'user': self.user,
'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES,
'organization': organization,
'protocol': get_protocol(),
'activation_days': userena_settings.USERENA_ACTIVATION_DAYS,
'activation_key': self.activation_key,
'site': Site.objects.get_current()}
subject = render_to_string('userena/emails/pending_activation_email_subject.txt',
context)
subject = ''.join(subject.splitlines())
message = render_to_string('userena/emails/pending_activation_email_message.txt',
context)
if userena_settings.USERENA_HTML_EMAIL:
message_html = render_to_string('userena/emails/pending_activation_email_message.html',
context)
else:
message_html = None
#Send email to admins with the link activation of new user
emaillist = []
if settings.USERENA_ADMIN_MODERATION:
send_mail(subject,
message,
message_html,
settings.DEFAULT_FROM_EMAIL,
[self.user.email, ])
for k, v in settings.ADMINS:
emaillist.append(v)
else:
emaillist.append(self.user.email)
if userena_settings.USERENA_HTML_EMAIL:
message = render_to_string('userena/emails/admin_activation_email_message.html',
context)
else:
message = render_to_string('userena/emails/admin_activation_email_message.txt',
context)
send_mail(settings.SITE_NAME + "- Pending activation",
message,
settings.DEFAULT_FROM_EMAIL,
emaillist)
开发者ID:bioinformatics-ua,项目名称:django-userena,代码行数:56,代码来源:models.py
示例18: send_activation_email
def send_activation_email(self):
"""
Sends a activation email to the user.
This email is sent_activation_email when the user wants to activate their newly created
user.
"""
context = {'user': self.user,
'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES,
'protocol': get_protocol(),
'activation_days': userena_settings.USERENA_ACTIVATION_DAYS,
'activation_key': self.activation_key,
'site': Site.objects.get_current()}
subject = render_to_string('userena/emails/activation_email_subject.txt',
context)
subject = ''.join(subject.splitlines())
if userena_settings.USERENA_HTML_EMAIL:
message_html = render_to_string('userena/emails/activation_email_message.html',
context)
else:
message_html = None
if (not userena_settings.USERENA_HTML_EMAIL or not message_html or
userena_settings.USERENA_USE_PLAIN_TEMPLATE):
message = render_to_string('userena/emails/activation_email_message.txt',
context)
else:
message = None
send_mail(subject,
message,
message_html,
settings.DEFAULT_FROM_EMAIL,
[self.user.email, ])
#Send email to admins with the message that the new user is active
if settings.USERENA_ADMIN_MODERATION:
for k, v in settings.ADMINS:
emaillist.append(v)
else:
emaillist.append(self.user.email)
send_mail("EMIF Catalogue - Activation done",
message,
settings.DEFAULT_FROM_EMAIL,
emaillist)
开发者ID:ming-hai,项目名称:django-userena,代码行数:50,代码来源:models.py
示例19: send_activation_email
def send_activation_email(self):
"""
Sends a activation email to the user.
This email is send when the user wants to activate their newly created
user.
Override default userena mechanism, to send beautiful HTML email
"""
email_context = {'user': self.user,
'without_usernames': userena_settings.USERENA_WITHOUT_USERNAMES,
'protocol': get_protocol(),
'activation_days': userena_settings.USERENA_ACTIVATION_DAYS,
'activation_key': self.activation_key, 'to': self.user.email}
msg = UserSignIn(email_context, self.user.email)
msg.send()
开发者ID:ouhouhsami,项目名称:localized_classified_ads,代码行数:16,代码来源:models.py
示例20: send_email
def send_email(self, email=None, site=None, request=None):
"""
Send invitation email.
Both ``email`` and ``site`` parameters are optional. If not supplied
instance's ``email`` field and current site will be used.
**Templates:**
:studytribe/invitation/invitation_email_subject.txt:
Template used to render the email subject.
**Context:**
:invitation: ``Invitation`` instance ``send_email`` is called on.
:site: ``Site`` instance to be used.
:studytribe/invitation/invitation_email_message.txt:
Template used to render the email body.
**Context:**
:invitation: ``Invitation`` instance ``send_email`` is called on.
:expiration_days: ``INVITATION_EXPIRE_DAYS`` setting.
:site: ``Site`` instance to be used.
**Signals:**
``invitation.signals.invitation_sent`` is sent on completion.
"""
email = email or self.email
if site is None:
if Site._meta.installed:
site = Site.objects.get_current()
elif request is not None:
site = RequestSite(request)
subject = render_to_string('studytribe/invitation/invitation_email_subject.txt',
{'invitation': self, 'site': site})
# Email subject *must not* contain newlines
subject = ''.join(subject.splitlines())
message = render_to_string('studytribe/invitation/invitation_email_message.txt',
{'invitation': self,
'expiration_days': settings.INVITATION_EXPIRE_DAYS,
'site': site,
'protocol':get_protocol()})
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [email])
signals.invitation_sent.send(sender=self)
开发者ID:esperyong,项目名称:study-tribe,代码行数:47,代码来源:models.py
注:本文中的userena.utils.get_protocol函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论