Changeset - adf2229720fc
[Not reviewed]
0 9 0
Ben Sturmfels (bsturmfels) - 2 years ago 2022-01-10 22:13:46
ben@sturm.com.au
Rename __unicode__ methods to __str__ following Django upgrade.
9 files changed with 18 insertions and 14 deletions:
0 comments (0 inline, 0 general)
www/conservancy/apps/blog/models.py
Show inline comments
...
 
@@ -7,25 +7,25 @@ from conservancy import bsoup
 
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(object):
 
        db_table = 'techblog_entrytag' # legacy
 

	
 
    def __unicode__(self):
 
    def __str__(self):
 
        return self.label
 

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

	
 
class Entry(models.Model, bsoup.SoupModelMixin):
 
    """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.")
...
 
@@ -35,25 +35,25 @@ class Entry(models.Model, bsoup.SoupModelMixin):
 

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

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

	
 
    SOUP_ATTRS = ['body']
 

	
 
    def __unicode__(self):
 
    def __str__(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
www/conservancy/apps/events/models.py
Show inline comments
...
 
@@ -5,25 +5,25 @@ from conservancy.apps.worldmap.models import EarthLocation
 
from datetime import datetime, timedelta
 

	
 
class EventTag(models.Model):
 
    """Tagging for events
 

	
 
    (currently unused)
 
    """
 

	
 
    label = models.CharField(max_length=100)
 

	
 
    date_created = models.DateField(auto_now_add=True)
 

	
 
    def __unicode__(self):
 
    def __str__(self):
 
        return self.label
 

	
 
class PastEventManager(models.Manager):
 
    """Returns all past events"""
 

	
 
    def get_queryset(self):
 
        return super(PastEventManager, self).get_queryset().filter(date__lt=datetime.today())
 

	
 
class FutureEventManager(models.Manager):
 
    """Returns all future events"""
 

	
 
    def get_queryset(self):
...
 
@@ -41,25 +41,25 @@ class Event(models.Model):
 
    people = models.ManyToManyField(Person, blank=True)
 
    location = models.CharField(max_length=1000)
 
    earth_location = models.ForeignKey(EarthLocation, null=True, blank=True,
 
                                       help_text="Label will not be displayed")
 
    tags = models.ManyToManyField(EventTag, blank=True)
 

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

	
 
    class Meta(object):
 
        ordering = ("-date",)
 

	
 
    def __unicode__(self):
 
    def __str__(self):
 
        return u"%s (%s)" % (self.title, self.date)
 

	
 
    def get_absolute_url(self):
 
        return u"/events/%s/%s/" % (self.date.strftime("%Y"), self.slug)
 

	
 
    def day_after(self):
 
        return self.date + timedelta(days=1)
 

	
 
    # for aggregate feed
 
    pub_date = property(lambda self: self.date_created)
 

	
 
    objects = models.Manager()
...
 
@@ -81,15 +81,15 @@ class EventMedia(models.Model):
 
                             help_text="Local filename of the resource.  File should be uploaded into the static directory that corresponds to the event.")
 
    # verify_exists removed https://docs.djangoproject.com/en/1.7/releases/1.4/
 
    remote = models.URLField(blank=True,
 
                             help_text="Remote URL of the resource.  Required if 'local' is not given.")
 
    novel = models.BooleanField(help_text="Is it a new piece of media or another form of an old one?  If it is new it will be included in the event-media RSS feed and shown on the front page for a bit.", default=False)
 

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

	
 
    class Meta(object):
 
        verbose_name_plural = 'event media'
 

	
 
    def __unicode__(self):
 
    def __str__(self):
 
        return u"%s media: %s" % (self.event, self.format)
 

	
www/conservancy/apps/fundgoal/models.py
Show inline comments
...
 
@@ -6,25 +6,25 @@ import random
 
from django.db import models
 

	
 
class FundraisingGoal(models.Model):
 
    """Conservancy fundraiser Goal"""
 

	
 
    fundraiser_code_name = models.CharField(max_length=200, blank=False, unique=True)
 
    fundraiser_goal_amount = models.DecimalField(max_digits=10, decimal_places=2)
 
    fundraiser_so_far_amount = models.DecimalField(max_digits=10, decimal_places=2)
 
    fundraiser_donation_count = models.IntegerField()
 
    fundraiser_donation_count_disclose_threshold = models.IntegerField()
 
    fundraiser_endtime = models.DateTimeField(null=True)
 

	
 
    def __unicode__(self):
 
    def __str__(self):
 
        return self.fundraiser_code_name
 

	
 
    def percentage_there(self):
 
        return (old_div(self.fundraiser_so_far_amount, self.fundraiser_goal_amount) ) * 100
 
    
 
    class Meta(object):
 
        ordering = ('fundraiser_code_name',)
 

	
 
    def providers(self):
 
        return GoalProvider.objects.filter(fundraising_goal=self)
 

	
 
    def random_providers(self, k=None):
...
 
@@ -35,14 +35,14 @@ class FundraisingGoal(models.Model):
 
            return random.choice(providers)
 
        else:
 
            return random.sample(providers, k)
 

	
 

	
 
class GoalProvider(models.Model):
 
    fundraising_goal = models.ForeignKey(
 
        'FundraisingGoal',
 
        on_delete=models.CASCADE,
 
    )
 
    provider_name = models.CharField(max_length=512)
 

	
 
    def __unicode__(self):
 
    def __str__(self):
 
        return self.provider_name
www/conservancy/apps/news/models.py
Show inline comments
...
 
@@ -21,25 +21,25 @@ class PressRelease(models.Model, bsoup.SoupModelMixin):
 
                            blank=True)
 
    pub_date = models.DateTimeField("date [to be] published")
 
    sites = models.ManyToManyField(Site)
 

	
 
    date_last_modified = models.DateTimeField(auto_now=True)
 

	
 
    class Meta(object):
 
        ordering = ("-pub_date",)
 
        get_latest_by = "pub_date"
 

	
 
    SOUP_ATTRS = ['summary', 'body']
 

	
 
    def __unicode__(self):
 
    def __str__(self):
 
        return self.headline
 

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

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

	
 
    def is_in_past_month(self):
 
        # This function is deprecated.  Use the date_within template
...
 
@@ -67,25 +67,25 @@ class PressRelease(models.Model, bsoup.SoupModelMixin):
 
        reply = j.weblogUpdates.ping(blog_name, blog_url, post_url)
 

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

	
 
class ExternalArticleTag(models.Model):
 
    """A way to tag external articles"""
 

	
 
    label = models.CharField(max_length=100)
 

	
 
    date_created = models.DateField(auto_now_add=True)
 

	
 
    def __unicode__(self):
 
    def __str__(self):
 
        return self.label
 

	
 
class PublicExternalArticleManager(models.Manager):
 
    def get_queryset(self):
 
        return super(PublicExternalArticleManager, self).get_queryset().filter(visible=True)
 

	
 
class ExternalArticle(models.Model):
 
    """A system for displaying Conservancy news mentions on the site.
 

	
 
    (Currently unused)
 
    """
 

	
...
 
@@ -100,18 +100,18 @@ class ExternalArticle(models.Model):
 

	
 
    tags = models.ManyToManyField(ExternalArticleTag, blank=True)
 
    people = models.ManyToManyField(Person, blank=True)
 
    event = models.ForeignKey(Event, null=True, blank=True)
 
    press_release = models.ForeignKey(PressRelease, null=True, blank=True)
 

	
 
    date_created = models.DateField(auto_now_add=True)
 

	
 
    class Meta(object):
 
        ordering = ("-date_created",)
 
        get_latest_by = "date_created"
 

	
 
    def __unicode__(self):
 
    def __str__(self):
 
        return u"%s (%s)" % (self.title, self.publication)
 

	
 
    objects = models.Manager()
 
    public = PublicExternalArticleManager()
 

	
www/conservancy/apps/staff/models.py
Show inline comments
...
 
@@ -14,17 +14,17 @@ class Person(models.Model):
 
#    biography = models.TextField(blank=True)
 
#    phone = models.CharField(max_length=30, blank=True)
 
#    gpg_key = models.TextField(blank=True)
 
#    gpg_fingerprint = models.CharField(max_length=100, blank=True)
 
    currently_employed = models.BooleanField(default=True)
 

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

	
 
    class Meta(object):
 
        verbose_name_plural = 'people'
 

	
 
    def __unicode__(self):
 
    def __str__(self):
 
        return self.username
 

	
 
    def biography_url(self):
 
        return u"/about/#%s" % self.username
www/conservancy/apps/supporters/models.py
Show inline comments
 
from builtins import object
 
from django.db import models
 

	
 
class Supporter(models.Model):
 
    """Conservancy Supporter listing"""
 

	
 
    display_name = models.CharField(max_length=200, blank=False)
 
    display_until_date = models.DateTimeField("date until which this supporter name is displayed")
 
    ledger_entity_id = models.CharField(max_length=200, blank=False)
 

	
 
    def test(self):
 
        return "TESTING"
 
    def __unicode__(self):
 
    def __str__(self):
 
        return self.display_name
 

	
 
    class Meta(object):
 
        ordering = ('ledger_entity_id',)
www/conservancy/apps/worldmap/models.py
Show inline comments
...
 
@@ -5,25 +5,25 @@ class EarthLocation(models.Model):
 
    """Represents latitude and longitude, with a label"""
 

	
 
    label = models.CharField(max_length=300, unique=True)
 
    latitude = models.DecimalField(max_digits=9, decimal_places=6)
 
    longitude = models.DecimalField(max_digits=9, decimal_places=6)
 

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

	
 
    class Meta(object):
 
        unique_together = (("latitude", "longitude"),)
 

	
 
    def __unicode__(self):
 
    def __str__(self):
 
        return self.label
 

	
 
    def google_maps_link(self):
 
        return ("http://maps.google.com/maps?ll=%s,%s&z=15"
 
                % (self.latitude, self.longitude))
 

	
 
    default_map_link = google_maps_link
 

	
 
    def html_map_link(self): # for Admin, fixme: fix_ampersands
 
        return '<a href="%s">map link</a>' % self.default_map_link()
 
    html_map_link.allow_tags = True
 

	
www/conservancy/settings.py
Show inline comments
...
 
@@ -17,25 +17,25 @@
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 

	
 
import os.path
 

	
 
from djangocommonsettings import *
 

	
 
SITE_ID = 2
 
ROOT_URLCONF = 'conservancy.urls'
 

	
 
FORCE_CANONICAL_HOSTNAME = False if DEBUG else 'sfconservancy.org'
 

	
 
ALLOWED_HOSTS = [ 'www.sfconservancy.org', 'aspen.sfconservancy.org', 'sfconservancy.org',  u'104.130.70.210' ]
 
ALLOWED_HOSTS = ['www.sfconservancy.org', 'aspen.sfconservancy.org', 'sfconservancy.org',  u'104.130.70.210', '*']
 
if DEBUG:
 
    ALLOWED_HOSTS.append('localhost')
 

	
 
REDIRECT_TABLE = {
 
    'www.sf-conservancy.org': 'sfconservancy.org',
 
}
 

	
 
LOGGING = {
 
    'version': 1,
 
    'disable_existing_loggers': False,
 
    'formatters': {
 
        'default': {
www/conservancy/urls.py
Show inline comments
...
 
@@ -33,24 +33,28 @@ urlpatterns = [
 
    url(r'^sponsors/index.html$', sponsors.view),
 
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
 
    url(r'^admin/', admin.site.urls),
 
    url(r'^feeds/blog/?$', feeds.BlogFeed()),
 
    url(r'^feeds/news/?$', feeds.PressReleaseFeed()),
 
    url(r'^feeds/omnibus/?$', feeds.OmnibusFeed()),
 
    url(r'^feeds/?$', feeds.view),
 
    url(r'^news/', include('conservancy.apps.news.urls')),
 
    url(r'^blog/', include('conservancy.apps.blog.urls')),
 
    # formerly static templated things... (dirs with templates)
 
    url(r'^error/(40[134]|500)(?:/index\.html|/|)$', static_views.handler),
 
    url(r'^error', static_views.index),
 
    url(r'^admin/css/', static_views.index),
 
    url(r'^css', static_views.index),
 
    url(r'^js', static_views.index),
 
    url(r'^img', static_views.index),
 
    url(r'^about', static_views.index),
 
    url(r'^activities', static_views.index),
 
    url(r'^donate', static_views.index),
 
    url(r'^copyleft-compliance', static_views.index,
 
                           {'fundraiser_sought' : 'vmware-match-0'}),
 
    url(r'^learn', static_views.index),
 
    url(r'^press', static_views.index),
 
    url(r'^projects', static_views.index),
 
    url(r'^npoacct', static_views.index,
 
                  {'fundraiser_sought' : 'npoacct'}),
 
    url(r'^contractpatch', include('conservancy.apps.contractpatch.urls')),
 
    url(r'^overview', static_views.index),
0 comments (0 inline, 0 general)