本文整理匯總了Python中apps.feed_import.models.OPMLExporter類的典型用法代碼示例。如果您正苦於以下問題:Python OPMLExporter類的具體用法?Python OPMLExporter怎麽用?Python OPMLExporter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了OPMLExporter類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: send_opml_export_email
def send_opml_export_email(self):
if not self.user.email:
return
MSentEmail.objects.get_or_create(receiver_user_id=self.user.pk,
email_type='opml_export')
exporter = OPMLExporter(self.user)
opml = exporter.process()
params = {
'feed_count': UserSubscription.objects.filter(user=self.user).count(),
}
user = self.user
text = render_to_string('mail/email_opml_export.txt', params)
html = render_to_string('mail/email_opml_export.xhtml', params)
subject = "Backup OPML file of your NewsBlur sites"
filename= 'NewsBlur Subscriptions - %s.xml' % datetime.datetime.now().strftime('%Y-%m-%d')
msg = EmailMultiAlternatives(subject, text,
from_email='NewsBlur <%s>' % settings.HELLO_EMAIL,
to=['%s <%s>' % (user, user.email)])
msg.attach_alternative(html, "text/html")
msg.attach(filename, opml, 'text/xml')
msg.send(fail_silently=True)
logging.user(self.user, "~BB~FM~SBSending OPML backup email to: %s" % self.user.email)
示例2: send_opml_export_email
def send_opml_export_email(self, reason=None, force=False):
if not self.user.email:
return
emails_sent = MSentEmail.objects.filter(receiver_user_id=self.user.pk,
email_type='opml_export')
day_ago = datetime.datetime.now() - datetime.timedelta(days=1)
for email in emails_sent:
if email.date_sent > day_ago and not force:
logging.user(self.user, "~SN~FMNot sending opml export email, already sent today.")
return
MSentEmail.record(receiver_user_id=self.user.pk, email_type='opml_export')
exporter = OPMLExporter(self.user)
opml = exporter.process()
params = {
'feed_count': UserSubscription.objects.filter(user=self.user).count(),
'reason': reason,
}
user = self.user
text = render_to_string('mail/email_opml_export.txt', params)
html = render_to_string('mail/email_opml_export.xhtml', params)
subject = "Backup OPML file of your NewsBlur sites"
filename= 'NewsBlur Subscriptions - %s.xml' % datetime.datetime.now().strftime('%Y-%m-%d')
msg = EmailMultiAlternatives(subject, text,
from_email='NewsBlur <%s>' % settings.HELLO_EMAIL,
to=['%s <%s>' % (user, user.email)])
msg.attach_alternative(html, "text/html")
msg.attach(filename, opml, 'text/xml')
msg.send(fail_silently=True)
logging.user(self.user, "~BB~FM~SBSending OPML backup email to: %s" % self.user.email)
示例3: opml_export
def opml_export(request):
user = get_user(request)
exporter = OPMLExporter(user)
opml = exporter.process()
now = datetime.datetime.now()
response = HttpResponse(opml, mimetype='text/xml')
response['Content-Disposition'] = 'attachment; filename=NewsBlur Subscriptions - %s' % (
now.strftime('%d %B %Y')
)
return response
示例4: opml_export
def opml_export(request):
user = get_user(request)
now = datetime.datetime.now()
if request.REQUEST.get('user_id') and user.is_staff:
user = User.objects.get(pk=request.REQUEST['user_id'])
exporter = OPMLExporter(user)
opml = exporter.process()
response = HttpResponse(opml, mimetype='text/xml')
response['Content-Disposition'] = 'attachment; filename=NewsBlur Subscriptions - %s - %s' % (
user.username,
now.strftime('%Y-%m-%d')
)
return response
示例5: opml_export
def opml_export(request):
user = get_user(request)
now = datetime.datetime.now()
if request.REQUEST.get("user_id") and user.is_staff:
user = User.objects.get(pk=request.REQUEST["user_id"])
exporter = OPMLExporter(user)
opml = exporter.process()
response = HttpResponse(opml, mimetype="text/xml")
response["Content-Disposition"] = "attachment; filename=NewsBlur Subscriptions - %s - %s" % (
user.username,
now.strftime("%Y-%m-%d"),
)
return response