Changeset - 31e51a774223
[Not reviewed]
www/conservancy/__init__.py
Show inline comments
 
from builtins import object
 
import hashlib
 

	
 
from django.conf import settings
 
from django.template import RequestContext
 

	
 
# This is backwards compatibilty support for a custom function we wrote
www/conservancy/apps/blog/models.py
Show inline comments
...
 
@@ -7,13 +7,13 @@ from datetime import datetime, timedelta
 
class EntryTag(models.Model):
 
    """Tagging for blog entries"""
 

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

	
 
    class Meta:
 
    class Meta(object):
 
        db_table = 'techblog_entrytag' # legacy
 

	
 
    def __unicode__(self):
 
        return self.label
 

	
 
    def get_absolute_url(self):
...
 
@@ -30,13 +30,13 @@ class Entry(models.Model, bsoup.SoupModelMixin):
 
    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:
 
    class Meta(object):
 
        db_table = 'techblog_entries' # legacy
 
        verbose_name_plural = 'entries'
 
        ordering = ('-pub_date',)
 
        get_latest_by = 'pub_date'
 

	
 
    SOUP_ATTRS = ['body']
www/conservancy/apps/contacts/models.py
Show inline comments
 
from builtins import object
 
from django.db import models
 

	
 
class ContactEntry(models.Model):
 
    """Conservancy contact system
 

	
 
    Hopefully this will be deprecated soon"""
 

	
 
    email = models.EmailField() # should make it unique, but we really cannot
 
    subscribe_conservancy = models.BooleanField(default=False)
 

	
 
    class Meta:
 
    class Meta(object):
 
        ordering = ('email',)
 

	
www/conservancy/apps/contacts/views.py
Show inline comments
 
from builtins import object
 
from django.shortcuts import render
 
from django import forms
 
from conservancy.apps.contacts.models import ContactEntry
 
from django.forms import ModelForm
 

	
 
def subscribe(request):
 
    """Mailing list subscription form
 
    """
 

	
 
    class ContactEntryForm(ModelForm):
 
        class Meta:
 
        class Meta(object):
 
            model = ContactEntry
 

	
 
    ContactEntryForm.base_fields['subscribe_conservancy'].label = 'Receive Software Freedom Conservancy updates'
 

	
 
    if request.method == 'POST':
 
        form = ContactEntryForm(request.POST)
www/conservancy/apps/events/models.py
Show inline comments
 
from builtins import object
 
from django.db import models
 
from conservancy.apps.staff.models import Person
 
from conservancy.apps.worldmap.models import EarthLocation
 
from datetime import datetime, timedelta
 

	
 
class EventTag(models.Model):
...
 
@@ -43,13 +44,13 @@ class Event(models.Model):
 
                                       help_text="Label will not be displayed")
 
    tags = models.ManyToManyField(EventTag, null=True, blank=True)
 

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

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

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

	
 
    def get_absolute_url(self):
...
 
@@ -83,12 +84,12 @@ class EventMedia(models.Model):
 
                             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:
 
    class Meta(object):
 
        verbose_name_plural = 'event media'
 

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

	
www/conservancy/apps/fundgoal/models.py
Show inline comments
 
from builtins import object
 
import random
 

	
 
from django.db import models
 

	
 
class FundraisingGoal(models.Model):
 
    """Conservancy fundraiser Goal"""
...
 
@@ -15,13 +16,13 @@ class FundraisingGoal(models.Model):
 
    def __unicode__(self):
 
        return self.fundraiser_code_name
 

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

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

	
 
    def random_providers(self, k=None):
www/conservancy/apps/news/models.py
Show inline comments
 
from builtins import object
 
from django.db import models
 
from django.conf import settings
 
from conservancy import bsoup
 
from conservancy.apps.staff.models import Person
 
from conservancy.apps.events.models import Event
 
from django.contrib.sites.models import Site
...
 
@@ -18,13 +19,13 @@ 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:
 
    class Meta(object):
 
        ordering = ("-pub_date",)
 
        get_latest_by = "pub_date"
 

	
 
    SOUP_ATTRS = ['summary', 'body']
 

	
 
    def __unicode__(self):
www/conservancy/apps/staff/models.py
Show inline comments
 
from builtins import object
 
from django.db import models
 

	
 
class Person(models.Model):
 
    """Staff members
 

	
 
    Referenced from other models (blog, events, etc)
...
 
@@ -16,13 +17,13 @@ class Person(models.Model):
 
#    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:
 
    class Meta(object):
 
        verbose_name_plural = 'people'
 

	
 
    def __unicode__(self):
 
        return self.username
 

	
 
    def biography_url(self):
www/conservancy/apps/summit_registration/models.py
Show inline comments
 
from builtins import object
 
from django.db import models
 

	
 
class SummitRegistration(models.Model):
 
    """Form fields for summit registrants"""
 

	
 
    name = models.CharField(max_length=300)
...
 
@@ -8,9 +9,9 @@ class SummitRegistration(models.Model):
 
    address = models.TextField(blank=True)
 
    email = models.EmailField(blank=True)
 
    phone = models.CharField(max_length=100, blank=True)
 
    date_created = models.DateField(auto_now_add=True)
 
    cle_credit = models.BooleanField(default=True)
 

	
 
    class Meta:
 
    class Meta(object):
 
        ordering = ('name',)
 

	
www/conservancy/apps/summit_registration/views.py
Show inline comments
 
from builtins import object
 
from django.shortcuts import render
 
from django import forms
 
from conervancy.apps.summit_registration.models import SummitRegistration
 

	
 
def register(request):
 
    """Summit registration form view
 
    """
 

	
 
    class SummitForm(ModelForm):
 
        class Meta:
 
        class Meta(object):
 
            model = SummitRegistration
 

	
 
    SummitForm.base_fields['email'].label = 'Email address'
 
    SummitForm.base_fields['phone'].label = 'Phone number'
 
    SummitForm.base_fields['address'].label = 'Mailing address'
 
    SummitForm.base_fields['cle_credit'].label = 'Attending for CLE credit?'
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)
...
 
@@ -9,8 +10,8 @@ class Supporter(models.Model):
 

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

	
 
    class Meta:
 
    class Meta(object):
 
        ordering = ('ledger_entity_id',)
www/conservancy/apps/worldmap/models.py
Show inline comments
 
from builtins import object
 
from django.db import models
 

	
 
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:
 
    class Meta(object):
 
        unique_together = (("latitude", "longitude"),)
 

	
 
    def __unicode__(self):
 
        return self.label
 

	
 
    def google_maps_link(self):
www/conservancy/bsoup.py
Show inline comments
 
# -*- encoding: utf-8 -*-
 

	
 
from builtins import object
 
import io
 
import itertools
 
import re
 

	
 
import bs4
 
import bs4.element
...
 
@@ -102,13 +103,13 @@ class BeautifulSoup(bs4.BeautifulSoup):
 

	
 
    def iter_videos(self):
 
        """Return an iterator of all video source elements in this document."""
 
        return self.find_all(self.is_video_source, src=True)
 

	
 

	
 
class SoupModelMixin:
 
class SoupModelMixin(object):
 
    """Mixin for models to parse HTML with BeautifulSoup.
 

	
 
    Classes that use this mixin must define `SOUP_ATTRS`, a list of strings
 
    that name attributes with HTML in them.  After that, all the public methods
 
    are usable.
 
    """
www/conservancy/middleware.py
Show inline comments
 
from builtins import object
 
from future.utils import raise_
 
from django import http
 
from django.conf import settings
 
from django.utils.cache import patch_response_headers
 

	
 
class ForceCanonicalHostnameMiddleware(object):
0 comments (0 inline, 0 general)