當前位置: 首頁>>代碼示例>>Python>>正文


Python models.OPMLExporter類代碼示例

本文整理匯總了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)
開發者ID:343max,項目名稱:NewsBlur,代碼行數:26,代碼來源:models.py

示例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)
開發者ID:JayabalM,項目名稱:NewsBlur,代碼行數:34,代碼來源:models.py

示例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
開發者ID:Laptop765,項目名稱:NewsBlur,代碼行數:12,代碼來源:views.py

示例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
開發者ID:AlphaCluster,項目名稱:NewsBlur,代碼行數:15,代碼來源:views.py

示例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
開發者ID:gforguru,項目名稱:NewsBlur,代碼行數:15,代碼來源:views.py


注:本文中的apps.feed_import.models.OPMLExporter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。