Files @ 76b653ed8afb
Branch filter:

Location: website/www/conservancy/apps/blog/models.py

Denver Gingerich
Lawsuit FAQ now uses ESXi 6.0 and add minor fixes.

The main change here is that the lawsuit FAQ page now shows one how to
verify that VMware combined Linux source code with their binary-only
components using VMware's ESXi 6.0 rather than ESXi 5.5 Update 2.
This required a couple minor path changes and updates to the memory
addresses and SHA-1 checksums. The analysis steps otherwise remained
the same.

The FAQ is now more generic in its discussion of the ESXi versions
that were originally analyzed, in order to avoid confusion with the
analysis provided in the FAQ, which uses a newer version and reaches
the same conclusion.

Some minor, unrelated fixes were also added. These include:
* add period at end of paragraphs where it was previously missing
* convert ">" in <pre> and <code> to "&gt;" so the page is valid HTML
* convert "&" in <pre> to "&amp;" so the page is valid HTML
* add missing 's' to "truct pci_driver"
* fix the "tg.c" filename - this should be "tg3.c"
from django.db import models
from django.conf import settings
from conservancy.apps.staff.models import Person
from datetime import datetime, timedelta

class EntryTag(models.Model):
    """Tagging for blog entries"""

    label = models.CharField(max_length=100)
    slug = models.SlugField()

    class Meta:
        db_table = 'techblog_entrytag' # legacy

    def __unicode__(self):
        return self.label

    def get_absolute_url(self):
        return u"/blog/?tag=%s" % self.slug

class Entry(models.Model):
    """Blog entry"""

    headline = models.CharField(max_length=200)
    slug = models.SlugField(unique_for_date='pub_date')
    summary = models.TextField(help_text="Use raw HTML.  Unlike in the press release model, this summary is not included at the beginning of the body when the entry is displayed.")
    body = models.TextField(help_text="Use raw HTML.  Include the full body of the post.")
    pub_date = models.DateTimeField()
    author = models.ForeignKey(Person)
    tags = models.ManyToManyField(EntryTag, null=True, blank=True)

    date_created = models.DateTimeField(auto_now_add=True)
    date_last_modified = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = 'techblog_entries' # legacy
        verbose_name_plural = 'entries'
        ordering = ('-pub_date',)
        get_latest_by = 'pub_date'

    def __unicode__(self):
        return self.headline

    def get_absolute_url(self):
        return (u"/blog/%s/%s/"
                % (self.pub_date.strftime("%Y/%b/%d").lower(),
                   self.slug))

    def is_recent(self):
        return self.pub_date > (datetime.now() - timedelta(days=30))
        # question: does datetime.now() do a syscall each time is it called?

    # Ping google blogs and technorati.  Taken from
    # http://blog.foozia.com/blog/2007/apr/21/ping-technorati-your-django-blog-using-xml-rpc/
    def save(self):
        if settings.CONSERVANCY_DEVEL or True: # "or True" means it is disabled always
            super(Entry, self).save()
            return

        blog_name = 'Software Freedom Law Center Blog'
        blog_url =  'http://www.softwarefreedom.org/blog/'
        post_url = ('http://www.softwarefreedom.org'
                    + self.get_absolute_url())

        import xmlrpclib

        # Ping Technorati
        j = xmlrpclib.Server('http://rpc.technorati.com/rpc/ping')
        reply = j.weblogUpdates.ping(blog_name, blog_url)

        # Ping Google Blog Search
        j = xmlrpclib.Server('http://blogsearch.google.com/ping/RPC2')
        reply = j.weblogUpdates.ping(blog_name, blog_url, post_url)

        # Call any superclass's method
        super(Entry, self).save()