Changeset - 462cbc396354
[Not reviewed]
0 2 5
Bradley Kuhn (bkuhn) - 7 years ago 2015-01-03 14:53:12
bkuhn@ebb.org
Supporters list built dynamically.

Hitherto the supporters list has been committed directly to the static
sponsors/index.html file. This was never ideal and a quick hack to
build Conservancy's supporters list at the beginning of the supporters
program.

With this change, a Django app now exists that dynamically generates the
supporters list.

The database rows must be built from Conservancy's internal Ledger file,
which will be done in a separate script.
7 files changed with 49 insertions and 55 deletions:
0 comments (0 inline, 0 general)
www/conservancy/apps/supporters/__init__.py
Show inline comments
 
new file 100644
www/conservancy/apps/supporters/admin.py
Show inline comments
 
new file 100644
 
from django.contrib import admin
 
from models import Supporter
 

	
 
class SupporterAdmin(admin.ModelAdmin):
 
    list_display = ('display_name', 'display_until_date')
 

	
 
admin.site.register(Supporter, SupporterAdmin)
www/conservancy/apps/supporters/models.py
Show inline comments
 
new file 100644
 
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):
 
        return self.display_name
 

	
 
    class Meta:
 
        ordering = ('-ledger_entity_id',)
www/conservancy/apps/supporters/views.py
Show inline comments
 
new file 100644
 
from models import Supporter # relative import
 
from django.views.generic.list_detail import object_list
 
from django.shortcuts import get_object_or_404, render_to_response
 

	
www/conservancy/sponsors.py
Show inline comments
 
new file 100644
 
from django.shortcuts import render_to_response
 
from conservancy.apps.supporters.models import Supporter as Supporter
 
from datetime import datetime, timedelta
 

	
 
def view(request):
 
    """Conservancy Sponsors Page view
 

	
 
    Performs object queries necessary to render the sponsors page.
 
    """
 

	
 
    supporters = Supporter.objects.all().filter(display_until_date__gte=datetime.now())
 

	
 
    c = {
 
        'supporters' : supporters
 
    }
 
    return render_to_response("sponsors.html", c)
www/conservancy/templates/sponsors.html
Show inline comments
...
 
@@ -54,65 +54,13 @@ any of its sponsors.</p>
 
<p>Conservancy Supporters are individuals who give $120 or more annually as
 
  part of <a href="/supporter/">the Official Conservancy Supporter
 
  program</a>.  Those who request public acknowledgment are listed here in
 
  alphabetical order by surname:</p>
 

	
 
<a id="supporters"></a>
 
   
 
<ul id="supporters">
 
  <li>Aleph Objects, Inc.</li>
 
  <li>Russ Allbery</li>
 
  <li>Jeremy Allison</li>
 
  <li>Christopher Aniszczyk</li>
 
  <li>Anonymous (3 people)</li>
 
  <li>Martin Ansdell-Smith</li>
 
  <li>David Ayers</li>
 
  <li>Jono Bacon</li>
 
  <li>Daniel Callahan</li>
 
  <li>Alison Chaiken</li>
 
  <li>Matthew Daniel</li>
 
  <li>Mark Cohen</li>
 
  <li>Michael Dexter</li>
 
  <li>Aurimas Fiseras</li>
 
  <li>Karl Fogel</li>
 
  <li>Richard Fontana</li>
 
  <li>Timothy Freund</li>
 
  <li>Philippe Gauthier</li>
 
  <li>Scott González</li>
 
  <li>Jared Grubb</li>
 
  <li>Steven Hamilton</li>
 
  <li>Edgar Hill</li>
 
  <li>Karl Ove Hufthammer</li>
 
  <li>Henrik Ingo</li>
 
  <li>maiki interi</li>
 
  <li>Ian Kelling</li>
 
  <li>Tom Kent</li>
 
  <li>Matt Kraai</li>
 
  <li>Johannes Krampf</li>
 
  <li>Cathy Kuhn</li>
 
  <li>Janet Shade Kuhn</li>
 
  <li>Michael Linksvayer</li>
 
  <li>Tom Marble</li>
 
  <li>Darin Miller</li>
 
  <li>Michael Miller</li>
 
  <li>Martin Michlmayr</li>
 
  <li>Pariksheet Nanda</li>
 
  <li>Deborah A. Nicholson</li>
 
  <li>Samuel and Cristine Noble</li>
 
  <li>Donald Robertson</li>
 
  <li>Ivan Sandler</li>
 
  <li>Prabowo Saputro</li>
 
  <li>Christopher Schafer</li>
 
  <li>Richard Schmeidler</li>
 
  <li>Mats Sjöberg</li>
 
  <li>W. John Sullivan</li>
 
  <li>David &rsquo;novalis&rdquo; Turner</li>
 
  <li>Kat Walsh</li>
 
  <li>Christopher Allan Webber</li>
 
  <li>Richard Wheeler</li>
 
  <li>Mark Wielaard</li>
 
  <li>Serge Wroclawski</li>
 
  <li>Seymour Zucker</li>
 
  <li>立思科技藝術有限公司</li>
 
{% for ss in supporters %}
 
<li>{{ ss.display_name|safe }}</li>
 
{% endfor %}
 
</ul>
 

	
 
{% endblock %}
www/conservancy/urls.py
Show inline comments
...
 
@@ -24,12 +24,15 @@ from conservancy.feeds import BlogFeed, PressReleaseFeed, OmnibusFeed
 
handler404 = 'modpythoncustom.view404'
 

	
 
admin.autodiscover()
 

	
 
urlpatterns = patterns('',
 
    (r'^$', 'conservancy.frontpage.view'),
 
    (r'^sponsors$', 'conservancy.frontpage.view'),
 
    (r'^sponsors/$', 'conservancy.sponsors.view'),
 
    (r'^sponsors/index.html$', 'conservancy.sponsors.view'),
 
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
 
    (r'^admin/', admin.site.urls),
 
    (r'^feeds/blog/?$', BlogFeed()),
 
    (r'^feeds/news/?$', PressReleaseFeed()),
 
    (r'^feeds/omnibus/?$', OmnibusFeed()),
 
    (r'^feeds/?$', 'conservancy.feeds.view'),
0 comments (0 inline, 0 general)