Exemple #1
0
def putWeekReport(report, newsletter):

    # if nothing changed, nothing to report, moving on.
    if report['db_changes'] == None and report['discussion'] == None and report['characteristic'] == None:
        return

    now = timezone.now()

    mess = Message(title=newsletter.title+" - Recent Changes - "+now.strftime("%Y-%m-%d %H:%M"),slug=newsletter.slug+'_'+now.strftime("%Y%m%d%H%M%S"), newsletter=newsletter)
    mess.save()

    if report['db_changes'] != None:
        art = Article(title="Changes on Database:", text=report['db_changes'], post=mess)
        art.save()

    if report['discussion'] != None:
        art2 = Article(title="New Discussion:", text=report['discussion'], post=mess)
        art2.save()

    if report['characteristic'] != None:
        art3 = Article(title="New Population Characteristic Data:", text=report['characteristic'], post=mess)
        art3.save()

    subm = Submission.from_message(mess)

    subm.prepared = True

    subm.save()
Exemple #2
0
    def make_article(self):
        a = Article()
        a.title = 'Test title'
        a.text = 'This should be a very long text with <html> in it as well.'
        a.post = self.m
        a.save()

        return a
Exemple #3
0
def send_newsletter(post_id):
    post = Post.objects.get(pk=post_id)
    if not post.notified:
        print("send_newsletter activated")
        site = Site.objects.all()[0]

        newsletter = Newsletter.objects.all()[0]
        submission = Submission()
        message = Message()
        article = Article()
        article.url = "http://{}{}".format(site.domain, post.get_absolute_url())
        article.title = post.title
        article.sortorder = 0

        message.title = post.title
        message.newsletter = newsletter
        message.slug = post.slug
        message.save()
        message.articles.add(article, bulk=False)
        message.save()
        article.save()

        submission.newsletter = newsletter
        submission.message = message
        submission.save()
        for s in newsletter.get_subscriptions():
            submission.subscriptions.add(s)
        submission.save()

        submission.submit()
        Submission.submit_queue()
        post.notified = True
        post.save()
        print("send_newsletter submitted")
Exemple #4
0
    def make_article(self):
        a = Article()
        a.title = 'Test title'
        a.text = 'This should be a very long text with <html> in it as well.'
        a.post = self.m
        a.save()

        return a
def putWeekReport(report, newsletter):

    # if nothing changed, nothing to report, moving on.
    if report['db_changes'] == None and report[
            'discussion'] == None and report['characteristic'] == None:
        return

    now = timezone.now()

    mess = Message(title=newsletter.title + " - Recent Changes - " +
                   now.strftime("%Y-%m-%d %H:%M"),
                   slug=newsletter.slug + '_' + now.strftime("%Y%m%d%H%M%S"),
                   newsletter=newsletter)
    mess.save()

    if report['db_changes'] != None:
        art = Article(title="Changes on Database:",
                      text=report['db_changes'],
                      post=mess)
        art.save()

    if report['discussion'] != None:
        art2 = Article(title="New Discussion:",
                       text=report['discussion'],
                       post=mess)
        art2.save()

    if report['characteristic'] != None:
        art3 = Article(title="New Population Characteristic Data:",
                       text=report['characteristic'],
                       post=mess)
        art3.save()

    subm = Submission.from_message(mess)

    subm.prepared = True

    subm.save()